[rspec-users] how to mock/stub when there are multiple model objects?

S Ahmed sahmed1020 at gmail.com
Thu Jun 23 16:55:45 EDT 2011


Thanks.

I'm trying this now on a Model that is using Mongoid.

I have tried:

it "should ..." do

   User.stub(:some_call).and_return(User.new(:name => "blah"))

end

And when running spec on this file I get:

NoMethodError, undefined method "stub" for User:Class

I also tried:

User.stub!(:some_call)....

Does this not work on mongoid objects?

On Fri, Jun 17, 2011 at 7:39 PM, Patrick J. Collins <
patrick at collinatorstudios.com> wrote:

> > but what if my method looks like:
> >
> >    user = User.where("...")
> >    user2 = User.where("...")
> User.should_receive(:where).with("...").and_return(...)
> http://apidock.com/rspec/Spec/Mocks
>
> Patrick J. Collins
> http://collinatorstudios.com
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110623/c0232589/attachment.html>


More information about the rspec-users mailing list