[rspec-users] How to test update_attribute with mocha?

Phlip phlip2005 at gmail.com
Thu May 14 09:20:54 EDT 2009

Matt Wynne wrote:

> I've got a reason. You're coupling the tests for this simple little 
> controller class to all the infrastructure and dependencies needed to 
> write the record to the database and reload it again. As easy as Rails 
> makes it for us to manage our database schemas, gratuitously introducing 
> dependencies in your code like this is a bad habit to get into. It can 
> lead to tests that are fragile to failing when code is changed far away 
> from the place they're apparently testing. The tests also run slowly, 
> which makes working on systems written like this boring.

The point of unit tests (which include the alleged "functional tests" in Rails) 
is to fail more often than production code would fail. Not less often.


More information about the rspec-users mailing list