[rspec-users] Depot app, Demeter's law and troubles cleanly specing

Fernando Perez lists at ruby-forum.com
Sat Apr 18 13:17:44 EDT 2009


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
Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list