On 10/16/07, Chris Olsen <[EMAIL PROTECTED]> wrote:
> I am a little confused to the what happens with the following:
>
> before do
> @site = mock_model(Site, :to_param => "1")
> Site.stub!(:new).and_return(@site)
> end
>
> def post_with_successful_save
> @site.should_receive(:save).and_return(true)
> post :create, :site => {}
> end
>
> I understand that the "@site.should_receive(:save)..." places a check to
> whether the method is called and that it should return "true"
This is a bit tricky. What you're setting up here (which is true of
message expectations in general, not must mock_model) is an
expectation that @site will receive the message :save and that when it
does receive it, you are instructing it to return true (not expecting
that the real :save method returns true).
The real :save method is not called.
Make sense?
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users