[rspec-users] How to test/spec an ActiveRecord find that uses :include

Phlip phlip2005 at gmail.com
Wed Apr 15 10:30:43 EDT 2009


Fernando Perez wrote:

> I was refactoring my model specs so that they don't hit the database,
> but how to handle a custom find that uses :joins or :include with some
> important :conditions? I can't see a way to not hit the database.

What's wrong with hitting the database?

When high-end consultants like Mike Feathers tell you not to hit the database, 
what they are really saying is that programmers using big iron languages like 
C++ or Java should start decoupling by any means necessary. It's just a mind-game.

At the other extreme, systems like Rails and its test fixtures have illustrated 
how you can leverage the database for a pool of stub objects. It doesn't lead to 
bad design, or slow tests down.

-- 
   Phlip



More information about the rspec-users mailing list