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

James Mead 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
> something-or-other).
> -hume.
>
> 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
> 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.
>
> --
> http://elhumidor.blogspot.com/
> _______________________________________________
> mocha-developer mailing list
> mocha-developer at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mocha-developer
>

Hi John,

Another belated reply, I'm afraid - I'm doing a bit of catching up after a
hectic December.

I think your suggestion makes a lot of sense i.e. returning another
"stub_everything" that has knowledge of its provenance.

The ticket [1] has now moved to Lighthouse, but I'll add a comment to
reflect your suggestion.

Cheers, James.
http://blog.floehopper.org

[1] http://floehopper.lighthouseapp.com/projects/22289/tickets/13


More information about the mocha-developer mailing list