Skip to content

Commit

Permalink
Merge pull request #1061 from postmodern/fix_async_http_client
Browse files Browse the repository at this point in the history
Fix `Async::HTTP::WebMockClientWrapper` mock interface
  • Loading branch information
bblimke committed Jul 15, 2024
2 parents 1b23927 + 9afefb5 commit 871f32e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions lib/webmock/http_lib_adapters/async_http_client_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,17 @@ 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)

@network_client = WebMockClient.new(endpoint, **options)
@webmock_client = WebMockClient.new(webmock_endpoint, **options)

@endpoint = endpoint
@scheme = scheme
@authority = authority
end
Expand Down
6 changes: 3 additions & 3 deletions spec/acceptance/async_http_client/async_http_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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}"
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 871f32e

Please sign in to comment.