diff options
Diffstat (limited to 'test/test_response.rb')
-rw-r--r-- | test/test_response.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/test_response.rb b/test/test_response.rb new file mode 100644 index 0000000..f033ba6 --- /dev/null +++ b/test/test_response.rb @@ -0,0 +1,48 @@ +require 'test/unit' +require 'mongrel' + +include Mongrel + +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.out.write("test") + resp.finished + + out.rewind + puts out.read + end + + 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 + + io.rewind + puts io.read + 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 + + io.rewind + puts io.read + end + +end + |