2011-12-12 17:15:31 -05:00
|
|
|
require "webrick"
|
|
|
|
require "minitest/autorun"
|
|
|
|
|
|
|
|
module WEBrick
|
|
|
|
class TestHTTPResponse < MiniTest::Unit::TestCase
|
|
|
|
class FakeLogger
|
|
|
|
attr_reader :messages
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
@messages = []
|
|
|
|
end
|
|
|
|
|
|
|
|
def warn msg
|
|
|
|
@messages << msg
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-12-12 17:33:56 -05:00
|
|
|
attr_reader :config, :logger, :res
|
|
|
|
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
@logger = FakeLogger.new
|
|
|
|
@config = Config::HTTP
|
|
|
|
@config[:Logger] = logger
|
|
|
|
@res = HTTPResponse.new config
|
|
|
|
@res.keep_alive = true
|
|
|
|
end
|
2011-12-12 17:15:31 -05:00
|
|
|
|
2011-12-12 17:33:56 -05:00
|
|
|
def test_304_does_not_log_warning
|
2011-12-12 17:15:31 -05:00
|
|
|
res.status = 304
|
|
|
|
res.setup_header
|
|
|
|
assert_equal 0, logger.messages.length
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_204_does_not_log_warning
|
|
|
|
res.status = 204
|
2011-12-12 17:33:56 -05:00
|
|
|
res.setup_header
|
|
|
|
|
|
|
|
assert_equal 0, logger.messages.length
|
|
|
|
end
|
2011-12-12 17:15:31 -05:00
|
|
|
|
2011-12-12 17:33:56 -05:00
|
|
|
def test_1xx_does_not_log_warnings
|
|
|
|
res.status = 105
|
2011-12-12 17:15:31 -05:00
|
|
|
res.setup_header
|
|
|
|
|
|
|
|
assert_equal 0, logger.messages.length
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|