[rspec-users] Depot app, Demeter's law and troubles cleanly specing
lists at ruby-forum.com
Thu Nov 26 22:24:59 EST 2009
Fernando Perez wrote:
> Let's take the example of the depot app. In my controller I set @order.
> Then in the view comes the bad stuff:
> @order.items.each do |item|
> Now I'm having problems specing item.product.title. A quick and dirty
> fix is to trade a for for an underscore, so I create Item#product_title:
> def product_title
> The problem is that I have a few models that act the same way, so I
> would find myself writing lot's of these little instance methods, and
> the solution looks a bit stupid to me. So how do you handle such issue?
> I thought about composed_of, but AWDWR's examples still break Demeter's
> law and that annoys me.
> Thanks in advance
Hi, please try the Law of Demeter gem
Its a DRY way to apply Law of Demeter with demeter gem
Posted via http://www.ruby-forum.com/.
More information about the rspec-users