HttpResponse: remove crack-addled HTTP_STATUS_HEADERS hash
[unicorn.git] / test / unit / test_response.rb
blobc30a141a3681a39916f96ad72d8f109c08454dc9
1 # Copyright (c) 2005 Zed A. Shaw 
2 # You can redistribute it and/or modify it under the same terms as Ruby.
4 # Additional work donated by contributors.  See http://mongrel.rubyforge.org/attributions.html 
5 # for more information.
7 require 'test/test_helper'
9 include Unicorn
11 class ResponseTest < Test::Unit::TestCase
12   
13   def test_response_headers
14     out = StringIO.new
15     HttpResponse.write(out,[200, {"X-Whatever" => "stuff"}, ["cool"]])
17     assert out.length > 0, "output didn't have data"
18   end
20   def test_response_OFS_set
21     old_ofs = $,
22     $, = "\f\v"
23     out = StringIO.new
24     HttpResponse.write(out,[200, {"X-Whatever" => "stuff"}, ["cool"]])
25     resp = out.read
26     assert ! resp.include?("\f\v"), "output didn't use $, ($OFS)"
27     ensure
28       $, = old_ofs
29   end
31   def test_response_200
32     io = StringIO.new
33     HttpResponse.write(io, [200, {}, []])
34     assert io.length > 0, "output didn't have data"
35   end
37   def test_response_with_default_reason
38     code = 400
39     io = StringIO.new
40     HttpResponse.write(io, [code, {}, []])
41     io.rewind
42     assert_match(/.* #{HTTP_STATUS_CODES[code]}$/, io.readline.chomp, "wrong default reason phrase")
43   end
44 end