Doug Livesey
2008-May-23 09:56 UTC
[rspec-users] 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. -- Posted via http://www.ruby-forum.com/.
David Chelimsky
2008-May-23 10:00 UTC
[rspec-users] Is there an equivalent to anything() for Hash parameters?
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
Tom Stuart
2008-May-23 10:06 UTC
[rspec-users] Is there an equivalent to anything() for Hash parameters?
On 23 May 2008, at 10:56, Doug Livesey 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
Doug Livesey
2008-May-23 10:20 UTC
[rspec-users] Is there an equivalent to anything() for Hash parameters
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. -- Posted via http://www.ruby-forum.com/.