[rspec-users] ActiveRecord, spec'ing find has right :order parameter

Rick DeNatale rick.denatale at gmail.com
Wed Mar 5 12:28:17 EST 2008


I'm wanting to write a spec that a model is applying an :order option
to a find call, but I don't want to completely specify all of the find
parameters.

So I want to write something like this, say in a controller spec

   User.should_receive(:find).with(:all, hash_with_at_least(:order =>
'user.name ASC'))
   get 'index', :sort => 'up'

This ability to partially specify the contents of a hash argument
seems to be generally useful, particularly for Rails, and was
wondering if anyone had done this. I don't think it would be too hard.

-- 
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/


More information about the rspec-users mailing list