Helps
“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.
Are you looking for something similar to [`assert_redirected_to`](http://guides.rubyonrails.org/testing.html#a-fuller-functional-test-example) ?
One solution could be to monkey-patch the Rack::Test driver [`process`](https://github.com/jnicklas/capybara/blob/master/lib/capybara/driver/rack_test_driver.rb#L177) method to pass an extra argument that would conditionally call `follow_redirects!`.
December 14, 2010 at 1:07 pm
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.
December 15, 2010 at 8:27 pm
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.
December 20, 2010 at 9:49 am