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

Hi – is there an equivalent to the anything() method to use with Hash
parameters?
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
grateful!
Cheers,
Doug.

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

‘name’
} )

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.

Cheers,
David

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

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

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:

http://rubyforge.org/pipermail/rspec-users/2008-March/006137.html
http://rubyforge.org/pipermail/rspec-users/2008-March/006139.html

Cheers,
-Tom

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

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.
Doug.

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