From c048e1111284e4f15fed28bea05dfaf47eb5e448 Mon Sep 17 00:00:00 2001 From: Christophe Bliard Date: Mon, 24 Jun 2024 18:14:56 +0200 Subject: [PATCH] Simplify the patch code Co-authored-by: Ivan Kuchin --- spec/support/have_http_status_with_rack_response.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/spec/support/have_http_status_with_rack_response.rb b/spec/support/have_http_status_with_rack_response.rb index 47dfd80c791a..f933d04d1b90 100644 --- a/spec/support/have_http_status_with_rack_response.rb +++ b/spec/support/have_http_status_with_rack_response.rb @@ -32,10 +32,9 @@ def as_test_response(obj) # `have_http_status` matcher would fail if the response object is a # `Rack::MockResponse`. Hack to disguise `Rack::MockResponse` into a # `ActionDispatch::TestResponse` object. - obj = ActionDispatch::Response.new(obj.status, obj.headers, obj.body).tap do |resp| - resp.request = ActionDispatch::Request.new({}) - end - ::ActionDispatch::TestResponse.from_response(obj) + response = ActionDispatch::Response.new(obj.status, obj.headers, obj.body) + response.request = ActionDispatch::Request.new({}) + ::ActionDispatch::TestResponse.from_response(response) else super end