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

System specs broken with Rails 6.0.1+ #2327

Closed
nnc opened this issue May 7, 2020 · 7 comments · May be fixed by #2329
Closed

System specs broken with Rails 6.0.1+ #2327

nnc opened this issue May 7, 2020 · 7 comments · May be fixed by #2329

Comments

@nnc
Copy link

nnc commented May 7, 2020

What Ruby, Rails and RSpec versions are you using?

Ruby version: 2.6.5p114
Rails version: Rails 6.0.1.rc1
RSpec version: RSpec 3.9 (rspec-rails 4.0.0)

Observed behaviour

Starting with Rails 6.0.1.rc1 urls in system specs are being generated by Rails url helpers for host www.example.com instead of http://127.0.0.1 as was the case in Rails 6.0.0 and before. Due to this change, all system specs fail with timeout errors.

failures_r_spec_example_groups_website_works_939

Specifically this line and commit introduced this change in RSpec system specs behavior.

Expected behaviour

Urls should be generated with host set to http://127.0.0.1.

Can you provide an example app?

https://github.com/nnc/rspec_system_specs_bug

Test app includes both a system test and a system spec, just to show that system tests continue working fine before and after the offending commit.

This issue is the same in all Rails versions after 6.0.1.rc1 so I didn't include those. But there is a commit in test app with Rails 6.0.0 (last Rails release before rails/rails@ea77dbf) where system spec is passing.

@benoittgt
Copy link
Member

Thanks for the detail issue and the example app that will help us to tackle this. I'm gonna try to look at it today.

@JonRowe
Copy link
Member

JonRowe commented May 9, 2020

Can you try the branch in #2329? I think thats the fix required.

@nnc
Copy link
Author

nnc commented May 9, 2020

Hi @JonRowe,

I just tried the branch on my real app and on my example app but it's still failing in the same way in both cases. That is, host is still being set to www.example.com.

If it helps, I verified that www.example.com is coming from here.

@JonRowe
Copy link
Member

JonRowe commented May 9, 2020

Hm, I just tried your reproduction without root_url and it works fine, this suggests it is actually root_url that is the problem, (which is probably a side effect of the change with default_url_options).

@nnc
Copy link
Author

nnc commented May 9, 2020

@JonRowe I added a spec with posts_url instead of root_url, but I still see this consistently fail with the same error as before. Though, now that I reread what you wrote, I'm not sure that's what you meant by "without root_url".

I've also updated my example app to use rspec-rails from #2329 and to fail early if host is not set to http://127.0.0.1/ to avoid waiting for the timeout.

@JonRowe
Copy link
Member

JonRowe commented May 9, 2020

You should find that posts_path and root_path work fine

@nnc
Copy link
Author

nnc commented May 10, 2020

Thanks @JonRowe! Using _path instead of _url helpers does solve this problem, even without the changes in #2329.

@nnc nnc closed this as completed May 10, 2020
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

Successfully merging a pull request may close this issue.

3 participants