lib/httpx/adapters/webmock.rb in httpx-1.1.4 vs lib/httpx/adapters/webmock.rb in httpx-1.1.5

- old
+ new

@@ -36,16 +36,14 @@ def build_from_webmock_response(request, webmock_response) return build_error_response(request, HTTPX::TimeoutError.new(1, "Timed out")) if webmock_response.should_timeout return build_error_response(request, webmock_response.exception) if webmock_response.exception - response = request.options.response_class.new(request, - webmock_response.status[0], - "2.0", - webmock_response.headers) - response << webmock_response.body.dup - response + request.options.response_class.new(request, + webmock_response.status[0], + "2.0", + webmock_response.headers) end def build_error_response(request, exception) HTTPX::ErrorResponse.new(request, exception, request.options) end @@ -88,9 +86,10 @@ response = Plugin.build_from_webmock_response(request, mock_response) WebMock::CallbackRegistry.invoke_callbacks({ lib: :httpx }, request_signature, mock_response) log { "mocking #{request.uri} with #{mock_response.inspect}" } request.response = response request.emit(:response, response) + response << mock_response.body.dup unless response.is_a?(HTTPX::ErrorResponse) elsif WebMock.net_connect_allowed?(request_signature.uri) if WebMock::CallbackRegistry.any_callbacks? request.on(:response) do |resp| unless resp.is_a?(HTTPX::ErrorResponse) webmock_response = Plugin.build_webmock_response(request, resp)