From jamesmead44 at gmail.com Sun Jan 4 13:29:18 2009 From: jamesmead44 at gmail.com (James Mead) Date: Sun, 4 Jan 2009 18:29:18 +0000 Subject: [mocha-developer] stub_everything returning self (was: something else) In-Reply-To: References: <1A4AE300-95AF-4F7A-A099-65871DD07832@gmail.com> <62EE37E7-2910-4589-9553-91B2D2332A5D@gmail.com> <20EDDE95-0A45-41A1-8933-65375D034997@gmail.com> <1db558f00810261216g20085a6euad57b81534b9be36@mail.gmail.com> <70D9E647-A83F-4B6E-970C-AA12ACDCDA68@gmail.com> Message-ID: <1db558f00901041029i115e513bp799703b4deedc740@mail.gmail.com> 2008/11/1 John D. Hume > 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 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 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