Skip to content

Commit

Permalink
Merge pull request #643 from JoshCheek/issue642-rack-solution
Browse files Browse the repository at this point in the history
RackResponse includes the reason phrase
  • Loading branch information
bblimke committed Aug 6, 2016
2 parents 4ecb5c1 + 1fcc7f4 commit a4aad22
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/webmock/rack_response.rb
Expand Up @@ -12,7 +12,7 @@ def evaluate(request)
Response.new(
body: body_from_rack_response(response),
headers: headers,
status: status
status: [status, Rack::Utils::HTTP_STATUS_CODES[status]]
)
end

Expand Down
10 changes: 10 additions & 0 deletions spec/unit/rack_response_spec.rb
Expand Up @@ -14,6 +14,16 @@
expect(response.body).to include('This is my root!')
end

it "should set the reason phrase based on the status code" do
request = WebMock::RequestSignature.new(:get, 'www.example.com')
response = @rack_response.evaluate(request)
expect(response.status).to eq([200, "OK"])

request = WebMock::RequestSignature.new(:get, 'www.example.com/error')
response = @rack_response.evaluate(request)
expect(response.status).to eq([500, "Internal Server Error"])
end

it "should behave correctly when the rack response is not a simple array of strings" do
request = WebMock::RequestSignature.new(:get, 'www.example.com/non_array_response')
response = @rack_response.evaluate(request)
Expand Down

0 comments on commit a4aad22

Please sign in to comment.