Merge pull request #6134 from Matt-Yorkley/webmock-helper

Improve Webmock debugging
This commit is contained in:
Pau Pérez Fabregat
2020-11-05 13:11:02 +01:00
committed by GitHub

View File

@@ -121,6 +121,7 @@ RSpec.configure do |config|
.select { |s| s.driver.is_a?(Capybara::Selenium::Driver) }
.each { |s| s.driver.reset! }
end
config.before(:all) { restart_driver }
# Enable caching in any specs tagged with `caching: true`. Usage is exactly the same as the
# well-known `js: true` tag used to enable javascript in feature specs.
@@ -140,7 +141,18 @@ RSpec.configure do |config|
end
end
config.before(:all) { restart_driver }
# Webmock raises errors that inherit directly from Exception (not StandardError).
# The messages contain useful information for debugging stubbed requests to external
# services (in tests), but they normally don't appear in the test output.
config.before(:all) do
ApplicationController.class_eval do
rescue_from WebMock::NetConnectNotAllowedError, with: :handle_webmock_error
def handle_webmock_error(exception)
raise exception.message
end
end
end
# Geocoding
config.before(:each) { allow_any_instance_of(Spree::Address).to receive(:geocode).and_return([1, 1]) }