From 559c2b9ab0fb2618e159a8d0ab189a6c2dbc211a Mon Sep 17 00:00:00 2001 From: Henne Vogelsang Date: Mon, 24 Jun 2024 15:24:42 +0200 Subject: [PATCH] Allow more Webdrivers update URLs in spec Follow advise from the webdrivers wiki --- spec/support/external_request.rb | 4 ---- spec/support/webmock.rb | 13 +++++++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 spec/support/webmock.rb diff --git a/spec/support/external_request.rb b/spec/support/external_request.rb index a3ebf939..74d70d4f 100644 --- a/spec/support/external_request.rb +++ b/spec/support/external_request.rb @@ -2,10 +2,6 @@ # Mock external requests to youtube require 'webmock/rspec' -driver_urls = Webdrivers::Common.subclasses.map do |driver| - Addressable::URI.parse(driver.base_url).host -end -WebMock.disable_net_connect!(allow_localhost: true, allow: [*driver_urls, /stripe.com/]) RSpec.configure do |config| config.before(:each) do diff --git a/spec/support/webmock.rb b/spec/support/webmock.rb new file mode 100644 index 00000000..29af2a1b --- /dev/null +++ b/spec/support/webmock.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +# Allow webdriver update urls +# from https://github.com/titusfortner/webdrivers/wiki/Using-with-VCR-or-WebMock +allowed_urls = Webdrivers::Common.subclasses.map(&:base_url) +allowed_urls << /geckodriver/ +# We've seen [a redirect](https://github.com/titusfortner/webdrivers/issues/204) to this domain +allowed_urls += ['github-releases.githubusercontent.com'] + +# Allow stripe.com for stripe integration tests +allowed_urls += ['stripe.com'] + +WebMock.disable_net_connect!(allow_localhost: true, allow: allowed_urls)