On Wed, Jun 3, 2009 at 2:30 PM, David Chelimsky <[email protected]> wrote:
> On Wed, Jun 3, 2009 at 1:26 PM, Rick DeNatale <[email protected]> wrote:
>> On Wed, Jun 3, 2009 at 2:01 PM, David Chelimsky <[email protected]> wrote:
>>> On Wed, Jun 3, 2009 at 12:46 PM, Sebastian W. <[email protected]> wrote:
>>>> Hello all,
>>>> Is there a way to explicitly tell a mock to expect no messages and give
>>>> an error if it does? I believe this is the default behavior, but thought
>>>> it might be nice for code readers to see.
>>>
>>> You can tell it to expect not to receive a specific message, but there
>>> is no way to say that it should not receive any messages.
>>
>> Maybe not explicitly but doesn't isn't making a mock with no
>> expectations effectively the same thing:
>>
>> describe "an object which should not get any messages" do
>> it "should not receive any messages" do
>> o = mock("Object")
>> o.foo
>> end
>> end
>>
>> Mock 'Object' received unexpected message :foo with (no args)
>
> Right - Sebastian noted that in the original post - but he's looking
> for something explicit.
Well how about:
describe "an object which should not get any messages" do
it "should not receive any messages" do
o = mock("Object")
o.should_not_receive(:a_damned_thing)
o.foo
end
end
<G>
--
Rick DeNatale
Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users