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.

HTH

Ash

-- 
http://www.patchspace.co.uk/
http://www.linkedin.com/in/ashleymoran

_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to