I have a test program that mimics a user's iOS device by sending chunks of data to a rails server. This program works fine outside of testing. Inside of testing, the program immediately times out since it cannot find the server.
My configuration, in env.rb:
require 'capybara/poltergeist'
Capybara.javascript_driver = :poltergeist
Capybara.server_port = 3123
Capybara.app_host = "http://0.0.0.0:3123"
Inside the test, I've tried things like
puts Capybara.current_session.current_host
puts Capybara.current_session.current_url
and so forth, but those are all blank. Doing:
puts Capybara.current_session
produces a memory address, so I know that the current session is working.
This is with Capybara set up like so in the gemfile:
gem 'capybara', '~> 2.0.2
I've seen several questions based on this, but their answers just don't work for me. Specifically, Capybara does not appear to be setting the current host or url as I've specified, nor is it actually allowing me to see the contents of the current session. So how can I fix this and specify a particular port and url?
For capybara < 2.0:
Capybara.current_session.driver.rack_server.host
Capybara.current_session.driver.rack_server.port
Capybara 2.0:
Capybara.current_session.server.host
Capybara.current_session.server.port
I found the answer here: Cucumber / Capybara -- how to get the host and port of the current execution
Capybara.current_session.driver.server.port
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With