[rspec-users] Mocking User.find( :all, :limit => 10 )

Johan Sørensen johan at johansorensen.com
Mon Jul 9 11:33:28 EDT 2007


On Jul 9, 2007, at 5:00 PM, Daniel N wrote:

> My Bad... Please ignore
>
> On 7/10/07, Daniel N <has.sox at gmail.com> wrote:
>   it "should find all users" do
>     User.should_receive(:find).with( :all, :limit => 10 ).and_return 
> ([@user])
>     do_get
>   end

Sorry for piggybacking on your post, but since you've apparantly  
figured out your isssue I have a slightly similar question; sometimes  
I have (in ActiveRecord) a verbose #find I want to mock out using  
should_receive, maybe looking something along this:
Foo.find(:all, :select => "foos.*, bars.*, :joins => "join bazzers on  
foos.baz_id = ..", :conditions => "quux = 1", etc etc)
... But all I really may care about with a specific mock expectation  
is that it gets the right :conditions key in the passed-in hash.

Is there a way in RSpec to check for a specific hash key (or  
evaluating other things along those lines) in the parameter  
expectation using the should_receive(:find).with(...) construct?

JS

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070709/1bfa23f9/attachment.html 


More information about the rspec-users mailing list