[Rspec-users] do we need stubbing?

Jay Levitt lists-rspec at shopwatch.org
Thu Oct 5 00:21:06 EDT 2006


David Chelimsky wrote:

 >>
 >> The main difference between Partial Mocking and Stubbing is that Stubs
 >> don't verify.
 >>
 >> I'm wondering if we really need the stubbing facility at all, given
 >> that we can do the same thing using Partial Mocks. If we decided to
 >> yank the Stubs, we could add Partial Mocks support to objects (right
 >> now it only works on classes).

It seems to me that this is a big difference, even if it is only a 
difference of intent, not execution.  A stub is a fake object I put in 
to make things work.  A mock is a core part of my test/spec.  Since BDD 
is all about expressing intent in vocabulary, I think stubs should stay 
even if they can be accomplished another way; it's like the difference 
between "if" and "unless".

Time.stubs(:now).returns(Time.parse("Jan 1 1901")) is my most common 
stub with Mocha/Stubba.  I don't care how many times it's called, and it 
isn't actually passed any arguments to verify; I'm just, well,
killing Time.

What's the argument for yanking stubs?  Just duplicating code?  Perhaps 
stubs can be implemented in terms of mocks, or vice versa?

Jay Levitt



More information about the Rspec-users mailing list