From 9fb6bf1cab1bdbacf43264ca4a4793b117f52d88 Mon Sep 17 00:00:00 2001 From: Postmodern Date: Thu, 11 Jul 2024 19:03:56 -0700 Subject: [PATCH 1/2] `Async::HTTP::Client#initialize` uses keyword arguments. * https://socketry.github.io/async-http/source/Async/HTTP/Client/index.html --- lib/webmock/http_lib_adapters/async_http_client_adapter.rb | 6 +++--- spec/acceptance/async_http_client/async_http_client_spec.rb | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/webmock/http_lib_adapters/async_http_client_adapter.rb b/lib/webmock/http_lib_adapters/async_http_client_adapter.rb index 65910901..5825f47e 100644 --- a/lib/webmock/http_lib_adapters/async_http_client_adapter.rb +++ b/lib/webmock/http_lib_adapters/async_http_client_adapter.rb @@ -35,9 +35,9 @@ module HTTP class WebMockClientWrapper < Client def initialize( endpoint, - protocol = endpoint.protocol, - scheme = endpoint.scheme, - authority = endpoint.authority, + protocol: endpoint.protocol, + scheme: endpoint.scheme, + authority: endpoint.authority, **options ) webmock_endpoint = WebMockEndpoint.new(scheme, authority, protocol) diff --git a/spec/acceptance/async_http_client/async_http_client_spec.rb b/spec/acceptance/async_http_client/async_http_client_spec.rb index 43d42464..8b2fd354 100644 --- a/spec/acceptance/async_http_client/async_http_client_spec.rb +++ b/spec/acceptance/async_http_client/async_http_client_spec.rb @@ -289,7 +289,7 @@ subject do responses = {} Async do |task| - Async::HTTP::Client.open(endpoint, protocol) do |client| + Async::HTTP::Client.open(endpoint, protocol: protocol) do |client| requests_count.times do |index| response = client.get "/foo#{index}" responses[index] = response_to_hash(response) @@ -316,7 +316,7 @@ subject do responses = {} Async do |task| - Async::HTTP::Client.open(endpoint, protocol) do |client| + Async::HTTP::Client.open(endpoint, protocol: protocol) do |client| tasks = requests_count.times.map do |index| task.async do response = client.get "/foo#{index}" @@ -349,7 +349,7 @@ def make_request(method, url, protocol: nil, headers: {}, body: nil) endpoint = Async::HTTP::Endpoint.parse(url) begin - Async::HTTP::Client.open(endpoint, protocol || endpoint.protocol) do |client| + Async::HTTP::Client.open(endpoint, protocol: protocol || endpoint.protocol) do |client| response = client.send( method, endpoint.path, From 9afefb55f07ee1be8768e397fe1a9060c47d4291 Mon Sep 17 00:00:00 2001 From: Postmodern Date: Thu, 11 Jul 2024 19:06:05 -0700 Subject: [PATCH 2/2] Also initialize `Async::HTTP::WebMockClientWrapper#endpoint` (closes #1060). --- lib/webmock/http_lib_adapters/async_http_client_adapter.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/webmock/http_lib_adapters/async_http_client_adapter.rb b/lib/webmock/http_lib_adapters/async_http_client_adapter.rb index 5825f47e..696752e1 100644 --- a/lib/webmock/http_lib_adapters/async_http_client_adapter.rb +++ b/lib/webmock/http_lib_adapters/async_http_client_adapter.rb @@ -45,6 +45,7 @@ def initialize( @network_client = WebMockClient.new(endpoint, **options) @webmock_client = WebMockClient.new(webmock_endpoint, **options) + @endpoint = endpoint @scheme = scheme @authority = authority end