On Jan 30, 2008 12:54 PM, Chris Olsen <[EMAIL PROTECTED]> wrote:
> Just out of curiosity, why is that the following .should calls have to
> differ to work?
>
> The first is a normal check on the if the user is redirected if not
> logged in
> =========
> it "should redirect the user to the login screen" do
>     do_get
>     response.should redirect_to(new_session_url)
>   end

Because the response object doesn't exist before the 'get'.


> The second is checking to ensure that the proper user validation method
> is called
> =========
> it "should validate the user" do
>     controller.should_receive(:authorized?).and_return(true)
>     do_get
>   end

Because we need to stub the method on the controller before the request is run.
i.e., prevent it from running.

The former is checking that something happened, which didn't exist before the
call was run.  Whereas the latter is stubbing the method as well as
raising if it doesn't.



Courtenay
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to