From ee03e77ebf793dddab345bc630b133099773ed55 Mon Sep 17 00:00:00 2001 From: Matt Brictson Date: Tue, 24 Oct 2023 08:19:14 -0700 Subject: [PATCH] Fix failing Async::HTTP specs due to Async API change The `async` gem recently made a breaking API change that was released in patch version 2.6.4.[^1] Following the change, async tasks that return an exception object will no longer raise that exception when `wait` is called. The `Async::HTTP` specs in webmock were written to leverage the old behavior of `wait`. Since async 2.6.4 was released, these specs have been failing in CI. This commit fixes the failing specs by updating how `wait` is used, such that exceptions are still raised as expected in async 2.6.4. This should restore CI to a working state. [^1]: https://github.com/socketry/async/pull/270 --- spec/acceptance/async_http_client/async_http_client_spec.rb | 4 +++- .../async_http_client/async_http_client_spec_helper.rb | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) 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 6196657b..43d42464 100644 --- a/spec/acceptance/async_http_client/async_http_client_spec.rb +++ b/spec/acceptance/async_http_client/async_http_client_spec.rb @@ -345,7 +345,7 @@ end def make_request(method, url, protocol: nil, headers: {}, body: nil) - Async do + result = Async do endpoint = Async::HTTP::Endpoint.parse(url) begin @@ -362,6 +362,8 @@ def make_request(method, url, protocol: nil, headers: {}, body: nil) e end end.wait + + result.is_a?(Exception) ? raise(result) : result end def response_to_hash(response) diff --git a/spec/acceptance/async_http_client/async_http_client_spec_helper.rb b/spec/acceptance/async_http_client/async_http_client_spec_helper.rb index 4f6b42c5..d465505e 100644 --- a/spec/acceptance/async_http_client/async_http_client_spec_helper.rb +++ b/spec/acceptance/async_http_client/async_http_client_spec_helper.rb @@ -16,7 +16,7 @@ def http_request(method, url, options = {}, &block) body = options[:body] - Async do + result = Async do begin Async::HTTP::Client.open(endpoint) do |client| response = client.send( @@ -34,6 +34,8 @@ def http_request(method, url, options = {}, &block) e end end.wait + + result.is_a?(Exception) ? raise(result) : result end def client_timeout_exception_class