Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to test for redirect in capybara? #1149

Closed
justin808 opened this issue Aug 21, 2013 · 1 comment
Closed

How to test for redirect in capybara? #1149

justin808 opened this issue Aug 21, 2013 · 1 comment

Comments

@justin808
Copy link

Is this possibly a capybara issue?

http://stackoverflow.com/questions/18030507/how-to-verify-301-status-code-using-capybara-webkit

Capybara-Webkit (and poltergeist) works fine to confirm a status code of 200 or 404, but when I do a redirect (301), I get back a status code of 200.

So this always fails

expect(page.status_code).to eq(301)

I can verify that the right page is shown with the redirect:

expect(page.current_url).to eq(expected_uri)

Any advice? Skip the check on the 301 status?

@twalpole
Copy link
Member

Capybara is for simulating user experience, since a user never sees a 301 I wouldnt expect to test that with Capybara. You'll get more complete answers by positing to the mailing list mentioned in the README, but if you really need to verify a 301 is sent (instead of a 302 or something) rather than just the result of the url changing then you probably just need a standard controller spec and dont involve capybara at all - https://www.relishapp.com/rspec/rspec-rails/docs/controller-specs

@lock lock bot locked and limited conversation to collaborators Aug 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants