On 21 Oct 2008, at 13:08, Rahoul Baruah wrote:
On 21 Oct 2008, at 10:45, Rob Lacey wrote:
I almost am tempted to simplify the controller by using only the
User model and moving most of the checks out of the controller
action entirely and putting all into User, although that would mean
that the user model, single_sign_on and music_service would then be
really tightly coupled which wouldn't be great either. I
Then you can RSpec your SingleSignOnPresenter separately, in much
the same way as you would spec a model, and keep the associations
(and implementation details) away from your controller.
Doesn't this just end up shifting the ugly mocking code into the
Presenter specs though?
The stock answer to this question is to move this logic down into the
model layer, so that the interface the Presenter / Controller uses to
work with the database is simpler. This is what people call 'listening
to your tests' - if it's hard to mock, it's probably indicative of a
problem in your design.
However, I worry about this 'skinny controller, fat model' advice, it
still doesn't feel like the final answer. To me, ActiveRecord classes
already have too many responsibilities, without making them also
orchestrate calls to other models.
I have been thinking about this a lot lately, and I am starting to
feel like I also need a Service layer between the Controller /
Presenters and the 'Data Access Layer' (Models) to orchestrate the work.
cheers,
Matt
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users