From 16d8a5cd58c26ba303c7c62a883202694f7edf79 Mon Sep 17 00:00:00 2001 From: Yosuke Kabuto Date: Sun, 19 Jun 2016 22:03:03 +0900 Subject: [PATCH] Add specs for Response#finish, including status code 205 --- test/response_test.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/response_test.rb b/test/response_test.rb index ae4608d7..64b5e0ee 100644 --- a/test/response_test.rb +++ b/test/response_test.rb @@ -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