Skip to content

Commit ee62f81

Browse files
committed
Move RackTestClient#headers to Headers#headers_to_env
1 parent 5c32aec commit ee62f81

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

lib/rspec_api_documentation/headers.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ def env_to_headers(env)
1414
headers
1515
end
1616

17+
def headers_to_env(headers)
18+
headers.inject({}) do |hsh, (k, v)|
19+
new_key = k.upcase.gsub("-", "_")
20+
new_key = "HTTP_#{new_key}" unless new_key == "CONTENT_TYPE"
21+
hsh[new_key] = v
22+
hsh
23+
end
24+
end
25+
1726
def format_headers(headers)
1827
headers.map do |key, value|
1928
"#{key}: #{value}"

lib/rspec_api_documentation/rack_test_client.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,7 @@ def do_request(method, path, params, request_headers)
3939
end
4040

4141
def headers(*args)
42-
super.inject({}) do |hsh, (k, v)|
43-
new_key = k.upcase.gsub("-", "_")
44-
new_key = "HTTP_#{new_key}" unless new_key == "CONTENT_TYPE"
45-
hsh[new_key] = v
46-
hsh
47-
end
42+
headers_to_env(super)
4843
end
4944

5045
private

0 commit comments

Comments
 (0)