On Jul 13, 2010, at 11:29 AM, Benyi Wang wrote:

> 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?

Yes.

> Is there any guide how to use stub and message expectation?

any_number_of_times was introduced before we introduced stubs, way back, way 
back. I use stub() rather than should_receive + any_number_of_times.

HTH,
David

_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to