rhydiant at googlemail.com
Thu May 27 01:07:20 EDT 2010
Makes sense... So would you tend to use double() in place of mock()/
On May 27, 1:22 pm, David Chelimsky <dchelim... at gmail.com> wrote:
> On May 26, 2010, at 10:01 PM, rhydiant wrote:
> > Given that RSpec has the following methods to create test doubles ...
> > double(:my_test_double)
> > mock(:my_mock_object)
> > stub(:my_stub)
> 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
> > objects?
> > null_object(:my_null_object)
> You could easily do this yourself, like this:
> def null_object(*args)
> 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
> > mock(:foo).as_null_object
> 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?
> rspec-users mailing list
> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users
More information about the rspec-users