[mocha-developer] stub_everything returning self (was: something else)
jamesmead44 at gmail.com
Sun Jan 4 13:29:18 EST 2009
2008/11/1 John D. Hume <duelin.markers at gmail.com>
> I'd probably vote against this feature, but if mocha were going to
> offer that sort of message eating behavior, I'd prefer that each
> message eater return a new message eater that knew what method it was
> the return value for, the benefit being that it could report that in
> to_s and/or inspect (rather than have you scratching your head at how
> such-and-such a piece of code got a hold of the stub you passed to
> On Sun, Oct 26, 2008 at 9:22 PM, John Wilger <johnwilger at gmail.com> wrote:
> > Where it comes in handy is when you have to work with poorly written
> > dependencies that violate LoD and you don't have a good way to either
> > replace them or adapt them. It definitely should /not/ be the default
> > behavior to return self, but the option to do so would be helpful in some
> > cicumstances.
> > On Oct 26, 2008, at 2:38 PM, Jay Fields <jay at jayfields.com> wrote:
> >> 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
> >> Changing mocha to help you violate the law of demeter seems like a bad
> >> Although, I guess you could argue that people should be given all the
> >> they want.
> mocha-developer mailing list
> mocha-developer at rubyforge.org
Another belated reply, I'm afraid - I'm doing a bit of catching up after a
I think your suggestion makes a lot of sense i.e. returning another
"stub_everything" that has knowledge of its provenance.
The ticket  has now moved to Lighthouse, but I'll add a comment to
reflect your suggestion.
More information about the mocha-developer