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

2009-11-27 Thread David Chelimsky
On Thu, Nov 26, 2009 at 9:24 PM, Emerson Macedo wrote: > Fernando Perez wrote: > > Hi, > > > > 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| > > item.product.title > > end > > > > Now I'm havi

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

2009-11-26 Thread Emerson Macedo
Fernando Perez wrote: > Hi, > > 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| > item.product.title > end > > Now I'm having problems specing item.product.title. A quick and dirty > fix is to trade

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

2009-04-20 Thread Pat Maddox
I wrote a blog post that may be helpful. http://www.patmaddox.com/blog/demeter-is-for-encapsulation Basically, when you have structural objects as in this case, demeter isn't useful. Luke Redpath wrote something called Demeter's Revenge which you might want to look at. I've not used it though so

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

2009-04-19 Thread Andrew Premdas
+1 what we are doing here is rendering resources in different contexts. In the original example we are rendering product resources in an order context. We should let the product define how it should be viewed - after all it knows best. If we need different views in different contexts then just crea

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

2009-04-19 Thread BJ Clark
The way I go about this is, IMO, pretty straight forward. I cringe when people start talking about generating html in models, since I think separation of concerns is much more important than law of demeter, and I think that the model most definitely shouldn't be concerned with how it needs

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

2009-04-19 Thread Matt Wynne
On 19 Apr 2009, at 19:54, David Chelimsky wrote: On Sun, Apr 19, 2009 at 11:24 AM, Mark Wilden wrote: On Sun, Apr 19, 2009 at 3:51 AM, Matt Wynne wrote: @order_presenter.product_titles do |product_title, url| <%= link_to product_title, url %> end The presentation of an order in most

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

2009-04-19 Thread Fernando Perez
>http://spin.atomicobject.com/2008/01/27/the-exceptional-presenter Interesting idea too. So basically I need to totally rethink and refactor the way my views display the information to the customer: Let's see how I currently display or not an add to cart button depending whether or not the

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

2009-04-19 Thread David Chelimsky
On Sun, Apr 19, 2009 at 11:24 AM, Mark Wilden wrote: > On Sun, Apr 19, 2009 at 3:51 AM, Matt Wynne wrote: > >> @order_presenter.product_titles do |product_title, url| >>  <%= link_to product_title, url %> >> end > > The presentation of an order in most apps will be constructed from > additional c

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

2009-04-19 Thread Zach Dennis
On Sun, Apr 19, 2009 at 12:24 PM, Mark Wilden wrote: > On Sun, Apr 19, 2009 at 3:51 AM, Matt Wynne wrote: > >> @order_presenter.product_titles do |product_title, url| >>  <%= link_to product_title, url %> >> end > > The presentation of an order in most apps will be constructed from > additional c

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

2009-04-19 Thread Fernando Perez
> This is where I start to introduce a presenter layer in between the > view and the models. Very interesting. Thank you very much. -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/ma

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

2009-04-19 Thread Mark Wilden
On Sun, Apr 19, 2009 at 3:51 AM, Matt Wynne wrote: > @order_presenter.product_titles do |product_title, url| >  <%= link_to product_title, url %> > end The presentation of an order in most apps will be constructed from additional columns (e.g., color, size, price, extended price). These columns

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

2009-04-19 Thread Matt Wynne
On 19 Apr 2009, at 11:08, Fernando Perez wrote: @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 othe

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

2009-04-19 Thread Fernando Perez
>@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 u

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

2009-04-19 Thread Matt Wynne
On 18 Apr 2009, at 23:08, Lenny Marks wrote: On Apr 18, 2009, at 1:17 PM, Fernando Perez wrote: Hi, 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| item.product.title end Now I'm having problems s

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

2009-04-18 Thread Lenny Marks
On Apr 18, 2009, at 1:17 PM, Fernando Perez wrote: Hi, 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| item.product.title end Now I'm having problems specing item.product.title. A quick and dirty fi

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

2009-04-18 Thread Mark Wilden
On Sat, Apr 18, 2009 at 10:17 AM, Fernando Perez 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.

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

2009-04-18 Thread Fernando Perez
Hi, 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| 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#p