diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 19fdc49943..40551b096e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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]) }