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

`expect(response).to_eq('something') hangs if it's a redirect #667

Closed
nathanl opened this issue Jan 8, 2013 · 3 comments
Closed

`expect(response).to_eq('something') hangs if it's a redirect #667

nathanl opened this issue Jan 8, 2013 · 3 comments

Comments

@nathanl
Copy link

nathanl commented Jan 8, 2013

In my tests, expect(response).to_eq('something') was hanging. I determined that this only happens when the response is a redirect. expect(response).to be_ok fails as expected in this case.

I'm guessing that to_eq is trying to look at the response body, and since a redirect doesn't have one, it hangs? Could it be patched to fail instead, saying that it expected 'something' and got nil?

@myronmarston
Copy link
Member

I believe this is a duplicate of #613, which is caused by rack/rack#419. It's been fixed in rack but I don't think there's a rack release with it yet.

For now, use something like expect(response.body).to eq('something').

@alindeman
Copy link
Contributor

Thanks for the report! This is a yucky issue, agreed.

tldr: You want to assert on response.body, not response (which is a Rack::Response, not a String).

The underlying issue is in Rack. See rack/rack#419 and previous rspec issues rspec/rspec-expectations#166 and #601

@nathanl
Copy link
Author

nathanl commented Jan 9, 2013

Good to know. Thanks for the quick response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants