On Sat, May 14, 2011 at 12:13 AM, arunsark <arun.vydianathan at
gmail.com>wrote:
> Hi
>
> I am using Mongoid. In Mongoid while saving a record we typically give
> like in the controller
> @post.safely.save
> For a model class Post
>
> I am writing rspecs for my controller and want to mock the model. So
> what I am doing is
>
> let(:post) { mock_model(Post).as_null_object }
>
> before(:each) do
> Post.stub(:new).and_return(post)
> end
> it "creates new post"
> Post.should_receive(:new).and_return(post)
> end
>
> #how do I stub safely.save also here and test whether it receives save
> call?
>
> Thanks
> Arun
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
Hi, check out "stub_chain"
http://relishapp.com/rspec/rspec-mocks/v/2-6/dir/method-stubs/stub-a-chain-of-methods
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/rspec-users/attachments/20110517/4cfd148a/attachment.html>