[rspec-users] How are people speccing Rails 3 ActiveRecord queries?

Ashley Moran ashley.moran at patchspace.co.uk
Sat Jul 17 13:41:08 EDT 2010

On 17 Jul 2010, at 4:37 PM, doug livesey wrote:
> At the minute I'm chaining a load of should_receive calls on mock relation objects

I've found this can cause pain in so many ways:

* Your tests end up coupled to the database structure (as that's how most associations are inferred)
* You're at the mercy of the implementation of the association proxy (I've found this more problematic with DataMapper, whose associations haven't always behaved quite how I expected them to...)
* You can easily end up with a lot of setup duplication

I've had enough pain from this that I now refuse to mock *any* ActiveRecord (the library or the pattern) code.  It's arguably a violation of Don't Mock Types You Don't Own anyway.




More information about the rspec-users mailing list