Hello World!

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

UserCreator.should_receive(:new).with(params).and_return(user_creator)
*
*

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?
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to