Skip to content

Commit

Permalink
Merge pull request #956 from michaelfairley/prevent_http_rb_double_wrap
Browse files Browse the repository at this point in the history
Prevent double-wrapping http.rb features on non-stubbed requests
  • Loading branch information
bblimke committed Aug 2, 2022
2 parents 7b9e1c0 + b722fe1 commit 1d2cdc7
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 1d2cdc7

Please sign in to comment.