httpx/standalone_tests/faraday_with_webmock_test.rb
HoneyryderChuck 1cf8c68ac6 fix: do not subclass session class to make it play along with default
class overrides

the faraday adapter was relying on subclassing the session to load
custom plugins. this doesn't play well with other integrations
monkeypatching the original session class, such as datadog or webmock,
which redefine it. from now on, we not only defer the creation of the
custom until necessary, we also use Session#plugin

Fixes #187
2022-04-04 12:54:33 +01:00

33 lines
772 B
Ruby

# frozen_string_literal: true
require "test_helper"
require "support/http_helpers"
require "support/minitest_extensions"
require "httpx/adapters/faraday"
require "webmock/minitest"
require "httpx/adapters/webmock"
class FaradayWithWebmockTest < Minitest::Test
include HTTPHelpers
def setup
super
WebMock.enable!
WebMock.disable_net_connect!
end
def teardown
super
WebMock.reset!
WebMock.allow_net_connect!
WebMock.disable!
end
def test_0_19_5_bug_faraday_and_webmock_dont_play_along
stub_http_request(:any, "https://www.smthfishy.com").to_return(status: 200)
faraday = Faraday.new { |builder| builder.adapter :httpx }
response = faraday.get("https://www.smthfishy.com/")
assert response.status == 200
end
end