about summary refs log tree commit homepage
path: root/test/unit/test_response.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/test_response.rb')
-rw-r--r--test/unit/test_response.rb74
1 files changed, 4 insertions, 70 deletions
diff --git a/test/unit/test_response.rb b/test/unit/test_response.rb
index b49c9df..769b0d6 100644
--- a/test/unit/test_response.rb
+++ b/test/unit/test_response.rb
@@ -12,11 +12,7 @@ class ResponseTest < Test::Unit::TestCase
   
   def test_response_headers
     out = StringIO.new
-    resp = HttpResponse.new(out)
-    resp.status = 200
-    resp.header["Accept"] = "text/plain"
-    resp.header["X-Whatever"] = "stuff"
-    resp.body.write("test")
+    resp = HttpResponse.new(out,[200, {"X-Whatever" => "stuff"}, ["cool"]])
     resp.finished
 
     assert out.length > 0, "output didn't have data"
@@ -24,56 +20,7 @@ class ResponseTest < Test::Unit::TestCase
 
   def test_response_200
     io = StringIO.new
-    resp = HttpResponse.new(io)
-    resp.start do |head,out|
-      head["Accept"] = "text/plain"
-      out.write("tested")
-      out.write("hello!")
-    end
-
-    resp.finished
-    assert io.length > 0, "output didn't have data"
-  end
-
-  def test_response_duplicate_header_squash
-    io = StringIO.new
-    resp = HttpResponse.new(io)
-    resp.start do |head,out|
-      head["Content-Length"] = 30
-      head["Content-Length"] = 0
-    end
-
-    resp.finished
-
-    assert_equal io.length, 95, "too much output"
-  end
-
-
-  def test_response_some_duplicates_allowed
-    allowed_duplicates = ["Set-Cookie", "Set-Cookie2", "Warning", "WWW-Authenticate"]
-    io = StringIO.new
-    resp = HttpResponse.new(io)
-    resp.start do |head,out|
-      allowed_duplicates.each do |dup|
-        10.times do |i|
-          head[dup] = i
-        end
-      end
-    end
-
-    resp.finished
-
-    assert_equal io.length, 734, "wrong amount of output"
-  end
-
-  def test_response_404
-    io = StringIO.new
-
-    resp = HttpResponse.new(io)
-    resp.start(404) do |head,out|
-      head['Accept'] = "text/plain"
-      out.write("NOT FOUND")
-    end
+    resp = HttpResponse.new(io, [200, {}, []])
 
     resp.finished
     assert io.length > 0, "output didn't have data"
@@ -101,24 +48,11 @@ class ResponseTest < Test::Unit::TestCase
     assert io.read[-contents.length..-1] == contents, "output doesn't end with file payload"
   end
 
-  def test_response_with_custom_reason
-    reason = "You made a bad request"
-    io = StringIO.new
-    resp = HttpResponse.new(io)
-    resp.start(400, false, reason) { |head,out| }
-    resp.finished
-
-    io.rewind
-    assert_match(/.* #{reason}$/, io.readline.chomp, "wrong custom reason phrase")
-  end
-
   def test_response_with_default_reason
     code = 400
     io = StringIO.new
-    resp = HttpResponse.new(io)
-    resp.start(code) { |head,out| }
-    resp.finished
-
+    resp = HttpResponse.new(io, [code, {}, []])
+    resp.start
     io.rewind
     assert_match(/.* #{HTTP_STATUS_CODES[code]}$/, io.readline.chomp, "wrong default reason phrase")
   end