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

Already on GitHub? Sign in to your account

Feature tests behave differently when run as part of 'rspec spec/' but not 'rspec spec/features' (Rails 4) #719

josephlord opened this Issue Mar 22, 2013 · 2 comments


None yet
2 participants

Not sure what I'm doing wrong but getting different hosts on _url methods (worked around that now) and other different behaviour.

I am currently testing on Rail 4 head (revision: 70d0537d5550958d7e006787de869ce9046101fc) and rspec-rails 2.13.0.

The _url methods are returning the URL with the host part test.host when run from 'rspec spec/' but (correctly) www.example.com when run with 'rspec spec/features'.

I think I've got round whatever the issue is by using _path methods instead of _url methods but am still surprised/puzzled by the difference in behaviour depending on how I run the test. 'rspec spec/' -> test.host and 'rspec spec/features/' -> www.example.com.


alindeman commented Apr 7, 2013

Thanks for your report.

Unfortunately I'm unable to reproduce it. I created a new Rails 3.2.13 application, brought in rspec-rails 2.13, and created a feature spec that simply prints out posts_url (I had scaffolded a Post model). It used example.com when I ran both rspec spec and rspec spec/features.

Are you able to distill what you're seeing down to an application you can push to GitHub? If so, I'd be happy to dig deeper.

That said, I think it's best to test on _path in these sorts of specs since the hostname is not relevant as far as I can tell.

@alindeman alindeman closed this Apr 7, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment