Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
850 views
in Technique[技术] by (71.8m points)

ruby on rails - Capybara webkit invalid response error, how to debug?

I'm trying to write a request spec for a web page.

This page works in development without error.

But running in capybara webkit I get this error after trying to submit the form:

 Failure/Error: Unable to find matching line from backtrace
 Capybara::Driver::Webkit::WebkitInvalidResponseError:
   Unable to load URL: https://127.0.0.1:33416/sign_in

In an effort to find out the cause I've started stripping out markup and JavaScript on the page. To the point where it is an empty form with a plain submit button. I still get the above error!

The test is now literally:

it "should be able create a new foo", :js, :focus do
  visit new_foo_path
  find('#submit').click
end

This test does however work if I remove the :js option:

it "should be able create a new foo", :focus do
  visit new_foo_path
  find('#submit').click
end

Javascript tests do work in other pages on this application...

This is making no sense to me. Does anyone have any suggestions how to debug from here?

Thanks for any help

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Add the following to your capybara config.

require 'rack/utils'
Capybara.app = Rack::ShowExceptions.new(NameOfYourRailsApp::Application)

When you get an error now you'll see it on stdout and rack will render a page with details about the environment(cookies etc.) and the backtrace.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...