[rspec-users] should_redirect_to in rspec-0.8.0 / rspec_on_rails 1453

Robert Martin unclebob at objectmentor.com
Thu Feb 1 16:20:04 EST 2007


The "should-redirect-to" has to be called before the 'post'.  I think  
it's setting up a mock.
On Feb 1, 2007, at 1:23 PM, s.ross wrote:

> I have a spec:
>
>    specify "a post with no user id should add a record" do
>      post :edit_or_create, :user => {:login => 'joeschmoe', :email =>
> 'joe at shmoe.com', :email_confirmation => 'joe at shmoe.com', :full_name
> => 'Joe Schmoe'}
>      assigns[:user].should_not_be_nil
>      assigns[:user].new_record?.should_not_be(true)
>      flash[:notice].should_match(/user added/)
>      response.should_be_redirect
>      puts "redirecting to #{response.redirect_url}"
>      puts "this response was #{response.redirect?}"
>      controller.should_redirect_to 'http://test.host/user'
>    end
>
> the puts statements output the following:
>
> redirecting to http://test.host/user
> this response was true
>
> Any idea why this line:
>
> controller.should_redirect_to 'http://test.host/user'
>
> would fail with the message:
>
> 'Given a UserController edit a post with no user id should add a
> record' FAILED
> controller expected call to redirect_to "http://test.host/user" but
> it was never received
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users


----
Robert C. Martin (Uncle Bob)  | email: unclebob at objectmentor.com
Object Mentor Inc.            | blog:  www.butunclebob.com
The Agile Transition Experts  | web:   www.objectmentor.com
800-338-6716                  |




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070201/04ad8626/attachment.html 


More information about the rspec-users mailing list