Move rackify headers to RequestFactory + other minor refactors

This commit is contained in:
domaindrivendev
2017-07-21 13:49:01 -07:00
parent 6ee53b08ae
commit e18a001e9b
3 changed files with 66 additions and 57 deletions

View File

@@ -12,15 +12,15 @@ module Rswag
send(
request[:verb],
request[:path],
request[:body],
rackify_headers(request[:headers]) # Rails test infrastructure requires Rack headers
request[:payload],
request[:headers]
)
else
send(
request[:verb],
request[:path],
{
params: request[:body],
params: request[:payload],
headers: request[:headers]
}
)
@@ -30,24 +30,6 @@ module Rswag
def assert_response_matches_metadata(metadata, &block)
ResponseValidator.new.validate!(metadata, response, &block)
end
private
def rackify_headers(headers)
name_value_pairs = headers.map do |name, value|
[
case name
when 'Accept' then 'HTTP_ACCEPT'
when 'Content-Type' then 'CONTENT_TYPE'
when 'Authorization' then 'HTTP_AUTHORIZATION'
else name
end,
value
]
end
Hash[ name_value_pairs ]
end
end
end
end