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

Support http.rb 5.x #941

Merged
merged 1 commit into from May 14, 2021
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
15 changes: 13 additions & 2 deletions lib/webmock/http_lib_adapters/http_rb/response.rb
Expand Up @@ -11,7 +11,7 @@ def to_webmock
end

class << self
def from_webmock(webmock_response, request_signature = nil)
def from_webmock(request, webmock_response, request_signature = nil)
status = Status.new(webmock_response.status.first)
headers = webmock_response.headers || {}
uri = normalize_uri(request_signature && request_signature.uri)
Expand All @@ -29,12 +29,23 @@ def from_webmock(webmock_response, request_signature = nil)

return new(status, "1.1", headers, body, uri) if HTTP::VERSION < "1.0.0"

# 5.0.0 had a breaking change to require request instead of uri.
if HTTP::VERSION < '5.0.0'
return new({
status: status,
version: "1.1",
headers: headers,
body: body,
uri: uri
})
end

new({
status: status,
version: "1.1",
headers: headers,
body: body,
uri: uri
request: request,
})
end

Expand Down
2 changes: 1 addition & 1 deletion lib/webmock/http_lib_adapters/http_rb/webmock.rb
Expand Up @@ -38,7 +38,7 @@ def replay
webmock_response.raise_error_if_any

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

def raise_timeout_error
Expand Down