On May 26, 2010, at 10:01 PM, rhydiant wrote:
Given that RSpec has the following methods to create test doubles …
double(), mock(), and stub() all return the same type of object: a test
double (actually, it’s a Mock, but that’s for legacy reasons - the class
name might change to Double in the future). The difference between
“mocking” and “stubbing” is at the method level. I’d actually like to
deprecate mock() and stub() in the long run to reduce the noise.
Is there a way to/ plans to introduce a similar syntax for null
You could easily do this yourself, like this:
I don’t think I’d want to add this to rspec directly, for the noise
reduction reasons I wrote above.
Instead of mock(:bar, :is_null_object => true) or
FYI - :null_object => true is deprecated (you’ll start seeing
deprecation notices in the next beta if you’re using it).
I think this would be cleaner, what do you think?
Clean is relative. It might be slightly less typing, but I don’t know
that it’s any more expressive, and IMO it increases the noise level.
Another thing to consider is that there are other “decorators” that use
this same pattern: double(name).as_something.
That all make sense?