[rspec-users] Is there an equivalent to anything() for Hash parameters?

David Chelimsky dchelimsky at gmail.com
Fri May 23 06:00:52 EDT 2008


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

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

>
>
> If anyone knew a way of generating that sort of behaviour, I'd be  
> *very*
> grateful!
> Cheers,
>   Doug.
> -- 
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users



More information about the rspec-users mailing list