Add specs for Response#finish, including status code 205

This commit is contained in:
Yosuke Kabuto 2016-06-19 22:03:03 +09:00 committed by Zachary Scott
parent c0a0ec60cc
commit 16d8a5cd58
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