Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

Standup 2010-12-14: Testing re-directs


“How can I test route redirects in Rails 3?”

Capybara (a Webrat clone for Rails 3) will do the job but we’re looking for something a little more direct. It may be possible to test this by checking location headers and disabling automatic redirects in tools might increase visibility.

  1. Cesario says:

    Are you looking for something similar to [`assert_redirected_to`]( ?

    One solution could be to monkey-patch the Rack::Test driver [`process`]( method to pass an extra argument that would conditionally call `follow_redirects!`.

  2. Jeff Dean says:

    Are you talking about controller specs? If so, you should still be able to use `response.should redirect_to(some_path)`. You can also use the new request specs in RSpec 2.x.

  3. Phil Goodwin says:

    Joelle says that she solved the problem by moving the redirection code into redirection controller. She says that she was then able to implement the exact routing algorithm she wanted and it also made it easier to test.

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *