[rspec-users] Dreading Controller Specs

Stephen Eley sfeley at gmail.com
Tue Oct 21 17:13:09 EDT 2008

On Tue, Oct 21, 2008 at 3:57 PM, Rahoul Baruah <baz at madeofstone.net> wrote:
> * the presenter/service's role is to coordinate the models - so its specs
> are purely about mocking the associations and the calls inbetween them
> * the presenter/service isn't a model (not ActiveRecord::Base) - so it's not
> adding extra responsibilities to the models
> * it is pretty much a service layer sat between controllers and models

There seems to be some overload on the word "Presenter" in Railsspeak.
 As best I can tell, people are using it to refer to two or more
totally different patterns.  Initially I thought presenters were for
encapsulating limited-domain *controller and view logic* in such a way
that they could be embedded in other controllers, thus allowing
composition in views.  Things like sidebar widgets, or components of a
dashboard, or a reusable address box, etc.  Stuff that benefits from
maintaining its own data so you can't just a partial, but it's still
more about the view than the model.

On Googling this post, however, I've found that some people do use it
that way, but other people talk about the Presenter pattern as a class
to aggregate data before sending it to (or split data after receiving
it from) the controller.  I.e., what you're saying.  I think Jay
Fields confused the issue by talking about presenters in this way, but
saying you're doing it for the sake of the *view.*

All of this has convinced me that the name "Presenter" sucks and
nobody should use it.  My thinking this is unlikely to change
anything, but at least people ought to agree on what they are.  What
you're talking about, Rahoul, at least one or two people are calling a

Personally I prefer handling it in the model, and letting models act
as compositions of other models if need be, but that's just me.

Have Fun,
   Steve Eley (sfeley at gmail.com)
   ESCAPE POD - The Science Fiction Podcast Magazine

More information about the rspec-users mailing list