[rspec-users] can't seem to test redirect?

Pat Maddox pergesu at gmail.com
Fri Oct 24 15:29:30 EDT 2008

>     controller.stub!(:redirect_to).with(@motion).and_return(true)

Well, I bet this is your problem.  You're stubbing redirect_to, so there
can't possibly be a redirect!

Also, the following example doesn't make any sense:

>   it "create new proposal with proposer set" do
>     do_post
>     response.should be_success
>     response.should render_template("motions/create")
>     response.should redirect_to(@motion)
>   end

Your response can be a success (HTTP 200) OR a redirect (HTTP 302), not

So there are two points you need to address right now:
* How do you want this action to behave? (success or redirect?)
* Don't stub behavior that you want to verify (if you want it to
  redirect, let it redirect)


More information about the rspec-users mailing list