Question

In using capybara and selenium to run integration tests in rails, if an exception is raised a blank white page is shown instead of the usual exception screen with the stack trace. Is there a way to get capybara to show the stack trace pages?

Was it helpful?

Solution

I was not able to get the stack traces to show with Webrick or Thin, but my eventual workaround was to use Mongrel, which properly prints the stack traces to stderr.

With capybara 0.4.1.2 or later, you can configure capybara to use mongrel like so:

Capybara.server do |app, port|
  require 'rack/handler/mongrel'
  Rack::Handler::Mongrel.run(app, :Port => port)
end

OTHER TIPS

Matt's solution didn't work for me, but precisely this gist https://gist.github.com/1443408 did.

https://github.com/thoughtbot/capybara-webkit/issues/226 explains in more detail why it happens and provides explanation on what given gist does.

this is most likely because the stack trace is only shown in the development execution mode (or 'environment'), and your integration tests are run within the production environment.

Of course, by tweaking the production mode settings, you may be able to make it show the exception. But it would not be the correct way. The best way is to :

  • log the exception and stack trace in a file or in a log server (hoptoad ?) where the user cannot see it but you can
  • catch the exception and render an error page

Hope this helps. Best regards.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top