summaryrefslogtreecommitdiff
path: root/spec/support/webmock.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/webmock.rb')
-rw-r--r--spec/support/webmock.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/spec/support/webmock.rb b/spec/support/webmock.rb
index 57acc3b63b1..f952f7f0985 100644
--- a/spec/support/webmock.rb
+++ b/spec/support/webmock.rb
@@ -15,4 +15,20 @@ def webmock_allowed_hosts
end.compact.uniq
end
-WebMock.disable_net_connect!(allow_localhost: true, allow: webmock_allowed_hosts)
+# This prevents Selenium/WebMock from spawning thousands of connections
+# while waiting for an element to appear via Capybara's find:
+# https://github.com/teamcapybara/capybara/issues/2322#issuecomment-619321520
+def webmock_enable_with_http_connect_on_start!
+ webmock_enable!(net_http_connect_on_start: true)
+end
+
+def webmock_enable!(options = {})
+ WebMock.disable_net_connect!(
+ {
+ allow_localhost: true,
+ allow: webmock_allowed_hosts
+ }.merge(options)
+ )
+end
+
+webmock_enable!