Skip to content
This repository

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

Closed
josephlord opened this Issue · 2 comments

2 participants

Joseph Lord Andy Lindeman
Joseph Lord

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: 70d0537) 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'.

Joseph Lord

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.

Andy Lindeman
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.