[rspec-users] What is the best practices for controller specs?

Guirec Corbel guirec.corbel at gmail.com
Fri Jun 28 13:52:41 UTC 2013

Hello World!

I have a question about controllers specs.For now, in my specs, I have
something like this :


So, I think some people can find than I test the wrong thing. I test the
implementation of the controller and not a real specification.

In this article
http://kpumuk.info/ruby-on-rails/my-top-7-rspec-best-practices/, the author
say to not over mock. In this other article :
http://solnic.eu/2012/02/02/yes-you-should-write-controller-tests.html, the
author is mocking everythings.

My own way is to test controllers, models, services, etc... in complete
isolation. Isolation is a good way to have fast tests and test only the
responsability of the object. I have acceptance tests which test the
integration. The bad part is than I have less flexibility and I can't
change a method or a class name without to break some tests.

So, my question is : What's your way and why?

Is it good to tests only if the controller render a template or redirect to
another action?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20130628/afe7b413/attachment.html>

More information about the rspec-users mailing list