[rspec-users] Dreading Controller Specs
pergesu at gmail.com
Wed Oct 29 00:39:54 EDT 2008
Jonathan Linowes <jonathan at parkerhill.com> writes:
> On Oct 22, 2008, at 4:32 PM, Pat Maddox wrote:
>> I think any app with a rich domain model benefits from a service layer
>> that uses that model. When building Rails apps, stuff is relatively
>> simple and the controllers *are* the service layer. That's how I
>> of it, anyway. Most of the time that's sufficient, but sometimes it
>> gets complex enough that you want to split out some of the logic.
> Reflecting on this thread, I'm realizing I put a lot of these kind of
> things into application.rb. Maybe I should think about how to make
> them into objects in a service layer, but presently they're doing
> fine where they are: split out from the controller, and independently
> testable. hmm...
Okay, but I just want to restate that you usually don't need that extra
layer. Like I said, I've done that maybe four or five times over the
past three years. Basically, if it seems to fit okay in the controller,
there's no need to create a service layer. It's really only when the
controller stuff gets awkward to test.
More information about the rspec-users