[mocha-developer] stub_everything returning self (was: something else)

Jay Fields jay at jayfields.com
Sun Oct 26 17:38:51 EDT 2008

I'm not sold on stub_everything returning self. Generally you only  
want that kind of behavior if you violate the law of demeter. There  
are cases where this is desirable, but they are few and far between in  
my experience. Changing mocha to help you violate the law of demeter  
seems like a bad idea. Although, I guess you could argue that people  
should be given all the rope they want.

Cheers, Jay

On Oct 26, 2008, at 2:16 PM, James Mead wrote:

> 2008/10/20 John Wilger <johnwilger at gmail.com>
>> Using `stub_everything` as opposed to just `stub` can alleviate  
>> that to
>> some degree, however the one thing I don't like about Mocha is
>> `stub_everything` returns nil for all calls. If it instead returned  
>> `self`
>> by default, then it would work better for this kind of situation.  
>> (If anyone
>> knows that there /is/ a way to cause Mocha to behave this way,  
>> please speak
>> up!)
> Hi John,
> Thanks for your message. There isn't currently a way to do this. I'm  
> not
> convinced that always returning "self" would be sensible, but I can  
> see the
> case for having control over the default return value. I've added a  
> feature
> request [1] to track this and I'll have a think about how the API  
> would
> work. In the meantime if you have any ideas, please let me know.
> Thanks.
> -- 
> James.
> http://blog.floehopper.org
> [1]
> http://rubyforge.org/tracker/index.php?func=detail&aid=22564&group_id=1917&atid=7480
> _______________________________________________
> mocha-developer mailing list
> mocha-developer at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mocha-developer

More information about the mocha-developer mailing list