1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00
puma--puma/test/test_response.rb

50 lines
966 B
Ruby
Raw Normal View History

require 'test/unit'
require 'mongrel'
require 'benchmark'
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.body.write("test")
resp.finished
assert out.length > 0, "output didn't have data"
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
resp.finished
assert io.length > 0, "output didn't have data"
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.finished
assert io.length > 0, "output didn't have data"
end
end