Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 4.x exceptions won't be re-raised #12

Open
jarmo opened this issue May 13, 2015 · 3 comments
Open

Rails 4.x exceptions won't be re-raised #12

jarmo opened this issue May 13, 2015 · 3 comments

Comments

@jarmo
Copy link
Member

jarmo commented May 13, 2015

watir-rails will not re-raise exceptions thrown by Rails Rack::App when using Rails 4.x.

Code responsible for this behavior is in Watir::Rails::Middleware#call.

Exceptions won't be even raised when Rails has action_dispatch.show_exceptions set to false and Watir::Rails.ignore_exceptions? is false.

The problem seems to be in Rails and/or Rack because enabling Thin or WEBrick logging will make everything work.

The following monkey-patch is a temporary solution until newer version of gem has been released.

Add it into your spec_helper.rb or similar file:

require "watir/rails"

class Watir::Rails
  def self.run_default_server(app, port)
    require 'rack/handler/thin'
    Rack::Handler::Thin.run(app, :Port => port)
  rescue LoadError
    require 'rack/handler/webrick'
    Rack::Handler::WEBrick.run(app, :Port => port)
  end
end
@jarmo
Copy link
Member Author

jarmo commented May 13, 2015

PS! The solution above does not seem to work with Thin < 1.6.x

@jarmo
Copy link
Member Author

jarmo commented Jun 11, 2017

Is this still relevant with Rails 5.x?

@jarmo
Copy link
Member Author

jarmo commented Dec 3, 2020

Or 6.x?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant