-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Can no longer set host! in before block for request specs #1662
Comments
Whats defining |
@JonRowe |
Are you resetting the session anywhere? We did ship a load ordering change in 3.5 that shouldn't have been breaking but might be in your scenario, as if the session is reset between your hook and your spec it would exhibit this behaviour... |
I have a feeling that I know what this is, some of the ways we interface with ActionDispatch::TestRequest were changed in 3.4 -> 3.5 to support rails 5. @mrageh is it easy for you to give us a sample rails app which shows the issue? Here are the usual steps I ask people to follow: Could you please provide us with a rails app that we can clone that demonstrates the issue. Specifically it'd be great if
then, provide us with a description of how to clone your application and reproduce the issue. Thanks :) |
Hi @samphippen , I have a repo at https://github.com/wassimk/rspec-rails-1665-issue and I made a short screencast walking through what I'm experiencing at http://www.screencast.com/t/nyZ2jKQi Thanks for your help! |
fa63448420d3385dbd043aca22dba973b45b8bb2 is the commit a git bisect points to in rails. |
…egration::Runner. In commit fa63448, @tenderlove changed the behaviour of the way `integration_session` is set up in this object. It used to be the case that the first time it was accessed, it was memoized with nil, however, this means that if it had already been set it was not replaced. After that commit, it is now always set to `nil` in the execution of `before_setup`. In RSpec, users are able to invoke `host!` in `before(:all)` blocks, which execute well before `before_setup` is ever invoked (which happens in what is equivalent to a `before(:each)` block, for each test. `host!` causes the integration session to be set up to correctly change the host, but after fa63448 the `integration_session` gets overwritten, meaning that users lose their `host!` configuration (see rspec/rspec-rails#1662). This commit changes the behaviour back to memoizing with `nil`, as opposed to directly overwriting with `nil`. This causes the correct behaviour to occur in RSpec, and unless I'm mistaken will also ensure that users who want to modify their integration sessions early in rails will also be able to do so.
I have opened a pull request on rails to fix this, see rails/rails#26235. In the mean time, setting |
@samphippen since you've fixed the underlying problem causing this issue in Rails, do you think we should close this issue? |
Yeah. This can be closed now. |
I just upgraded to Rails 5 and Rspec 3.5 All my tests are passing except request specs. My request specs are testing API interactions. The API is scoped to the subdomain
api
. I have a before block that sets thehost!
. I see the block is executing and host is setting but when the actual test is executing the host change reverts towww.example.com
and I get a routing error.Within this block
host
is set and working.The test, host is no longer set. If I set it manually in this code the test will pass:
What am I doing wrong here?
The text was updated successfully, but these errors were encountered: