"Chris Flipse" <[EMAIL PROTECTED]> writes: > I dunno ... creating a bunch of joining methods seems to be an awfully > disjoint way to deal with something that is, admittedly, designed to > laugh in the face of the Law of Demeter. > > I've been handling chains through some heavy use of null_object stubs ... > but, I've been doing that sort of manually. Could be rolled up, > at least. > > I'm kind of spitballing something that might be somewhat less manual ... > > foo.stub_chains :method_1, :method_2 do |chain| > end > > def stub_chains(*args) > hades = stub("chain", :null_object => true) > args.each do|chain| > hades.stub!(chain).and_return(hades) > self.stub!(chain).and_return(hades) > end > end
Yeah, that's cool. In regards to Demeter, one of my former coworkers argued that if you don't gain much by that encapsulation, you should default to following the ontological structure. Makes a lot of sense to me. Pat _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users