[rspec-users] stub vs stub!

David Chelimsky dchelimsky at gmail.com
Sat Mar 20 06:43:45 EDT 2010

On Fri, Mar 19, 2010 at 1:39 PM, David Chelimsky <dchelimsky at gmail.com> wrote:
> 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().

D'oh - stub!() - that's the one I plan to remove. So we would only
have stub(). There is no need to have both, since they do the same
thing, and there is nothing particularly bangy about the stub method.

> 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 :)
> Cheers,
> David

More information about the rspec-users mailing list