Merge pull request #1127 from zzak/response

Moar Response#finish specs
This commit is contained in:
Zachary Scott 2016-06-24 17:23:55 +09:00 committed by GitHub
commit 5fcb1e1bd4
1 changed files with 14 additions and 1 deletions

View File

@ -27,7 +27,7 @@ class ResponseTest < Minitest::Test
assert_equal 'Hello World', @response.body.join
end
[204, 304].each do |status_code|
[204, 205, 304].each do |status_code|
it "removes the Content-Type header and body when response status is #{status_code}" do
@response.status = status_code
@response.body = ['Hello World']
@ -35,6 +35,19 @@ class ResponseTest < Minitest::Test
end
end
[200, 201, 202, 301, 302, 400, 401, 403, 404, 500].each do |status_code|
it "will not removes the Content-Type header and body when response status
is #{status_code}" do
@response.status = status_code
@response.body = ['Hello World']
assert_equal [
status_code,
{ 'Content-Type' => 'text/html', 'Content-Length' => '11' },
['Hello World']
], @response.finish
end
end
it 'Calculates the Content-Length using the bytesize of the body' do
@response.body = ['Hello', 'World!', '✈']
_, headers, body = @response.finish