On Sat, Apr 18, 2009 at 10:17 AM, Fernando Perez <li...@ruby-forum.com> wrote:
>
> @order.items.each do |item|
>  item.product.title
> end
>
> 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
>  product.title
> end

And this still doesn't satifsy the "Law" of Demeter because you're
still calling order.items[x].product_title. Simply adding a method
call in between doesn't obviate the fact that you need the order's
item's product's title.

I would split the difference and have an orders helper that knew how
to format each component of a displayed item.

///ark
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to