Is there an equivalent to anything() for Hash parameters?

Hi – is there an equivalent to the anything() method to use with Hash
So that the following call:
Model.find( :all, :conditions => “name LIKE ‘%rt%’”, :order => ‘name’

Could have the two following successful examples:
Model.should_receive( :find ).with( :all, { :conditions => “name LIKE
'%rt%”, anything } )
Model.should_receive( :find ).with( :all, { anything, :order => ‘name’
} )

If anyone knew a way of generating that sort of behaviour, I’d be very

On May 23, 2008, at 4:56 AM, Doug L. wrote:

} )

If you’re using the latest from github:

Model.should_receive(:find).with(:all, hash_including(:order => ‘name’))

This only verifies the specified key/value pairs and ignores
everything else.


On 23 May 2008, at 10:56, Doug L. wrote:

Hi – is there an equivalent to the anything() method to use with Hash

FYI this was discussed in March, so you might be able to find
something useful in the list archive if you’d rather roll your own
parameter matcher than switch to bleeding-edge RSpec:


Just a final word – updated to the latest RSpec, and have been loving
Cheers again for those responses!

Cheers for both of those responses!
I think I might try to get onto the bleeding edge of RSpec, although I
am currently having some issues doing so.
If I don’t get that fixed in the next half hour or so, I reckon I’ll go
w/ the custom matcher – it’s probably about time I refreshed my memory
on matchers, anyway!
Thanks again for the help, there.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs