Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent double-wrapping http.rb features on non-stubbed requests #956

Merged
merged 1 commit into from Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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