[rspec-users] Mocking Models in Controller Specs...

Mark Dodwell lists at ruby-forum.com
Tue May 27 03:48:23 EDT 2008


Many thanks for your replies.

David Chelimsky wrote:

> Use stub_model instead (if you're using source from github - if not
> the 1.4 release is coming soon).

Thanks - that helps a great deal.

Scott Taylor wrote:

> I would highly suggest using :null_object => true in view specs (or
> controller specs with integrate_views):

Thanks, that's interesting, I didn't know about that option... Are there 
any advantages of using this approach over #stub_model?

Bart Zonneveld (bartz) wrote:

> Or, consider moving code into the model, and test it there. See
> http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model

I agree, but in this case the controller really only does CRUD, and it 
couldn't really be any skinnier or it might die! Also, I don't think 
that it is the main source of the problem here, rather the fact that I 
am using integrate_views which means I have to have a reasonably full 
mock of any models wherever I have a form for that model.

~ Mark


-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list