diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-11-06 12:23:22 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-11-06 12:23:22 +0000 |
commit | 600b9132327f6e643e4f7707c982230405a6eb2f (patch) | |
tree | 8ace82a6955df4256119abdc6c9390a4c3323a35 /test | |
parent | 1b7bb04e1c0ff4466552c261621c45a5fb89142c (diff) | |
download | ruby-600b9132327f6e643e4f7707c982230405a6eb2f.tar.gz |
* test/open-uri/test_open-uri.rb: Check empty webrick log.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/open-uri/test_open-uri.rb | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/test/open-uri/test_open-uri.rb b/test/open-uri/test_open-uri.rb index ce00b343f7..d30d89831e 100644 --- a/test/open-uri/test_open-uri.rb +++ b/test/open-uri/test_open-uri.rb @@ -13,14 +13,9 @@ class TestOpenURI < Test::Unit::TestCase def NullLog.<<(arg) end - def with_http(capture_log=false) - if capture_log - log = StringIO.new('') - logger = WEBrick::Log.new(log, WEBrick::BasicLog::WARN) - else - log = nil - logger = WEBrick::Log.new($stdout, WEBrick::BasicLog::WARN) - end + def with_http(log_is_empty=true) + log = StringIO.new('') + logger = WEBrick::Log.new(log, WEBrick::BasicLog::WARN) Dir.mktmpdir {|dr| srv = WEBrick::HTTPServer.new({ :DocumentRoot => dr, @@ -38,6 +33,9 @@ class TestOpenURI < Test::Unit::TestCase th.join end } + if log_is_empty + assert_equal("", log.string) + end end def with_env(h) @@ -83,7 +81,7 @@ class TestOpenURI < Test::Unit::TestCase end def test_404 - with_http(true) {|srv, dr, url, log| + with_http(false) {|srv, dr, url, log| exc = assert_raise(OpenURI::HTTPError) { open("#{url}/not-exist") {} } assert_equal("404", exc.io.status[0]) assert_match(%r{ERROR `/not-exist' not found}, log.string) @@ -408,7 +406,7 @@ class TestOpenURI < Test::Unit::TestCase end def test_redirect_auth - with_http(true) {|srv, dr, url, log| + with_http(false) {|srv, dr, url, log| srv.mount_proc("/r1/") {|req, res| res.status = 301; res["location"] = "#{url}/r2" } srv.mount_proc("/r2/") {|req, res| if req["Authorization"] != "Basic #{['user:pass'].pack('m').chomp}" |