Reputation: 287400
Is there a way to get, in the test, the port in which the rails app is running during cucumber test? I tried Capybara.server_port but that's nil.
Thanks.
Upvotes: 3
Views: 3367
Reputation: 287400
When using the selenium driver, the port can be found on:
Capybara.current_session.driver.rack_server.port
and when using the webkit driver, it can be found on:
Capybara.current_session.driver.server_port
Alternative, you can set
Capybara.server_port
to a known value and use that.
Upvotes: 5
Reputation: 11076
My understanding is that if you're using rack-test, the default Capybara driver, then there's isn't actually any real web server running to make requests to.
If you want to view your app as Cucumber/Capybara would, then you'd need to start it up manually on a chosen port:
$ RAILS_ENV=test rails s -p 4000
And then have something like this in env.rb:
Capybara.configure do |config|
config.run_server = false
config.app_host = "http://localhost:4000"
end
Upvotes: 3