Pivotal Labs

Main menu

Skip to primary content
Skip to secondary content
  • About
  • Case Studies
  • Team
    • Executives
    • Locations
      • San Francisco (HQ)
      • Boston
      • Boulder
      • Denver
      • London
      • Los Angeles
      • New York
  • Community
    • Blogs
    • Tech Talks
    • Events
  • Careers
    • Lifestyle
    • Principles & Practices
    • Benefits
    • FAQ
    • Apply
  • Contact
    • Press Room
    • Press Releases
    • In The News
    • Press Kit
  • All
  • Labs
  • Standup
  • Tracker

Standup 2010-12-14: Testing re-directs

Phil Goodwin
Tuesday, December 14, 2010

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.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

3 Comments

  1. Cesario says:

    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

  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.

    December 15, 2010 at 8:27 pm

  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.

    December 20, 2010 at 9:49 am

Add New Comment Cancel reply

Your email address will not be published.

Phil Goodwin

Phil Goodwin
San Francisco

Recent Posts

  • “expect errors”
  • Standup 5/3/2012 Time, time and more time
  • Standup 5/2/2012 A hack a day…
Subscribe to Phil's Feed

Author Topics

agile (8)
clang (1)
db (1)
party (1)
rack (1)
ruby (1)
ccrb (3)
events (1)
jasmine (1)
jenkins (1)
open source (1)
ci (1)
database (1)
git (1)
headless (1)
rvm (1)
selenium (1)
shell (1)
  • About
  • Case Studies
  • Team
  • Community
  • Careers
  • Contact
  • Labs
  • Events

Contact Us

contact@pivotallabs.com
+1 415-77-PIVOT
TwitterLinkedInFacebook

Pivotal Tracker

Tracker is the award-winning agile project management tool that enables real-time collaboration around a shared, prioritized backlog.
Visit pivotaltracker.com >