Skip to content

Commit 4e0c865

Browse files
author
Sam Phippen
committed
Clear and merge test response headers instead of assigning.
Rails 5 removes the attr_writer for this method, but clearing the hash and writing to it is essentially equivalent to assigning it.
1 parent b4c00c4 commit 4e0c865

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/rspec/rails/matchers/have_http_status.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def as_test_response(obj)
4343
# Capybara or catch `NameError`s for the undefined constants
4444
obj = ActionDispatch::Response.new.tap do |resp|
4545
resp.status = obj.status_code
46-
resp.headers = obj.response_headers
46+
resp.headers.clear
47+
resp.headers.merge!(obj.response_headers)
4748
resp.body = obj.body
4849
end
4950
::ActionDispatch::TestResponse.from_response(obj)

0 commit comments

Comments
 (0)