[rspec-users] [Rspec] Difference between stub and message expectation with any_number_of_times

Benyi Wang bewang.tech at gmail.com
Tue Jul 13 12:29:53 EDT 2010


I'm wondering what's the difference between stub and message expectation
with any_number_of_times, for example:

myMock = mock("mymock")
myMock.stub!(:is_a?).with(MyClass).and_return(false)

and

myMock = mock("mymock")
myMock.should_receive(:is_a?).with(MyClass).any_number_of_times.and_return(false)

because is_a? may not be called at all, it just like a stub. Is my
understanding correct?

Is there any guide how to use stub and message expectation?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20100713/94a480e3/attachment.html>


More information about the rspec-users mailing list