Skip to content

Commit

Permalink
Prevent double-wrapping http.rb features on non-stubbed requests
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfairley committed Oct 15, 2021
1 parent 867f4b2 commit b722fe1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 1 addition & 3 deletions lib/webmock/http_lib_adapters/http_rb/client.rb
Expand Up @@ -5,9 +5,7 @@ class Client
def perform(request, options)
return __perform__(request, options) unless webmock_enabled?

response = WebMockPerform.new(request) { __perform__(request, options) }.exec
options.features.each { |_name, feature| response = feature.wrap_response(response) }
response
WebMockPerform.new(request, options) { __perform__(request, options) }.exec
end

def webmock_enabled?
Expand Down
8 changes: 6 additions & 2 deletions lib/webmock/http_lib_adapters/http_rb/webmock.rb
@@ -1,7 +1,8 @@
module HTTP
class WebMockPerform
def initialize(request, &perform)
def initialize(request, options, &perform)
@request = request
@options = options
@perform = perform
@request_signature = nil
end
Expand Down Expand Up @@ -38,7 +39,10 @@ def replay
webmock_response.raise_error_if_any

invoke_callbacks(webmock_response, real_request: false)
::HTTP::Response.from_webmock @request, webmock_response, request_signature
response = ::HTTP::Response.from_webmock @request, webmock_response, request_signature

@options.features.each { |_name, feature| response = feature.wrap_response(response) }
response
end

def raise_timeout_error
Expand Down

0 comments on commit b722fe1

Please sign in to comment.