[rspec-users] stub vs stub!

David Chelimsky dchelimsky at gmail.com
Fri Mar 19 14:39:50 EDT 2010

On Mar 19, 2010, at 1:27 PM, Nick Hoffman wrote:

> Pat Maddox wrote:
>> I've never heard of CurbFu, but according to 
>> http://github.com/gdi/curb-fu/blob/master/lib/curb-fu.rb#L43 it defines 
>> a stub method already.  So you're hitting that one, which expects two 
>> arguments.  stub! goes to RSpec's mocking framework.
>> Pat
> Good catch! Thanks, Pat.

This presents an interesting dilemma, in that I (now not so) secretly plan to deprecate and remove stub().

I also plan to offer up a mode in which you don't get stub and should_receive added to every object, but instead have to wrap each object you want to set stubs/message expectations on. i.e.

double(Foo).stub(:bar) { return value }

This is how flexmock works, and it helps to avoid problems exactly like the one you've uncovered.

I guess these two changes will need to ship together :)


More information about the rspec-users mailing list