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

Fernando Perez lists at ruby-forum.com
Sun Apr 19 06:08:02 EDT 2009

>    @order.product_titles do |product_title|
>      <%= product_title %>
>    end

Another problem, is that not only do I need the title, but also a 
clickable permalink which uses a url helper (not available to models), 
the product price, and maybe other stuff in the future. So I might end 
up with a nice messy code.

For the time being I use delegate, so I traded a dot for an underscore. 
It's easy to spec, and after all, an item only exists in the context of 
an Order, so I think it's fine to break Demeter's 'guideline' and say 
that it's cool that Order knows a little bit stuff about Item's 
internal. However a Product can exist without an Order, so Order doesn't 
need to know anything about Product and vice versa.

But I'll have to think more about it, because as you said making a 
little change in a model can result in having to fix places that are far 
far away and totoally unexpected.
Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list