Merge branch 'fix-webmock-adapter-enable-disable-issue' into 'master'

Fix WebMock adapter so that it gets disabled when WebMock gets disabled

See merge request os85/httpx!247
This commit is contained in:
HoneyryderChuck 2023-04-25 07:25:08 +00:00
commit 8db1557827
2 changed files with 11 additions and 1 deletions

View File

@ -204,6 +204,16 @@ class WebmockTest < Minitest::Test
WebMock.disable_net_connect!
end
def test_webmock_disable_after_enable
WebMock.disable!
# WebMock is disabled so this will make a real http request
http_request(:get, "http://#{httpbin}")
# WebMock is disabled so it should not have registered the request
assert_not_requested(:get, "http://#{httpbin}")
end
private
def assert_raise_with_message(e, message, &block)

View File

@ -122,7 +122,7 @@ module WebMock
class << self
def enable!
@original_session = HTTPX::Session
@original_session ||= HTTPX::Session
webmock_session = HTTPX.plugin(Plugin)