I'm hitting an issue with Capybara Webkit where it raises the following exception when I try to run a feature spec.
Failure/Error: visit root_path Capybara::Webkit::InvalidResponseError: Unable to load URL: http://test.unbound.com:4040/ because of error loading http://test.unbound.com:4040/: Unknown error The failing spec looks like this:
it "should render a page", js: true do visit root_path current_path.should == root_path end This is the output when I use the :webkit_debug driver:
Run options: include {:line_numbers=>[72]} Finished "EnableLogging" with response "Success()" Wrote response true "" Received "Visit" Started "Visit" Load started "Visit" started page load Started request to "http://test.unbound.com:4040/" Finished "Visit" with response "Success()" Received 0 from "http://test.unbound.com:4040/" Page finished with false Load finished Page load from command finished Wrote response false "{"class":"InvalidResponseError","message":"Unable to load URL: http://test.unbound.com:4040/ because of error loading http://test.unbound.com:4040/: Unknown error"}" Received "Reset" Started "Reset" undefined|0|SECURITY_ERR: DOM Exception 18: An attempt was made to break through the security policy of the user agent. Finished "Reset" with response "Success()" Wrote response true "" The non-JS equivalent will pass with no exceptions raised. This version uses regular Capybara rather than Capybara webkit.
it "should render a page" do visit root_path current_path.should == root_path end It might be relevant that I'm forcing the host before each test like so:
# default_host_and_port will equal: "test.unbound.com:4040" default_url_options[:host] = Rails.configuration.default_host_and_port Capybara.app_host = "http://#{Rails.configuration.default_host_and_port}" If I don't do that then I get issues running feature specs with regular Capybara.
Some things I've tried:
- Running the server in the test environment and visiting the
root_pathin the browser (as suggested in this SO answer). It loads fine. There will be a JS console error becausemixpanelcannot be found but I think it is unlikely that is causing the problem. - Using
Rack::ShowExceptionsto try to get a more detailed exception. Still get the same exception and backtrace. - Running rspec with the
-bflag. No difference. - Adding
test.unbound.comto my/etc/hosts. No difference. - Telling Capybara to ignore SSL errors like this.
One clue:
- When I tail the test log, I never see a request to
GET /come through.