Sometimes you need complex expectations on method arguments like this
SomeApi.should_receive(:find).with(:query => '*foo*', :sort => 'timestamp ASC', :limit => 100).and_return(['some result'])
This is not very flexible, and failure messages will be hard to read.
Instead, consider doing this:
SomeApi.should_receive(:find) do |params|
params[:query].should == '*foo*'
params[:sort].should == 'timestamp ASC'
params[:limit].should == 100
['some result']
end
Posted by Tobias Kraze to makandra dev (2014-08-25 08:42)