Search code examples
ruby-on-rails-3capybaracapybara-webkit

Capybara-webkit tries to open example.com


I'm using capybara, capybara-webkit, capybara-screenshot together with cucumber. (Ruby 1.9.3, Rails 3.1.3) and Capybara.javascript_driver = :webkit is also set env.rb

Unfortunately running a cucumber spec with @javascript will never succeed for some reason and the error screenshots just capture example.com.

The URL which I actually try to open is generated with a rails router result for one of my models e.g. with visit products_url

So how can I avoid that it ends up querying example.com?

Any input is very welcome.


Just because the comment is messed up - here's what I found was the solution:

Capybara.run_server = true
Capybara.server_port = 7787
Before '@javascript' do
  Capybara.app_host = "http://127.0.0.1:#{Capybara.server_port}"
end

Solution

  • Try using visit products_path instead. They do not recommend using absolute URLs in "Gotchas" section of README.