summaryrefslogtreecommitdiff
path: root/test/webrick
diff options
context:
space:
mode:
Diffstat (limited to 'test/webrick')
-rw-r--r--test/webrick/test_httpauth.rb2
-rw-r--r--test/webrick/test_server.rb5
-rw-r--r--test/webrick/utils.rb14
3 files changed, 8 insertions, 13 deletions
diff --git a/test/webrick/test_httpauth.rb b/test/webrick/test_httpauth.rb
index bf47656a20..051e252fec 100644
--- a/test/webrick/test_httpauth.rb
+++ b/test/webrick/test_httpauth.rb
@@ -61,7 +61,6 @@ class TestWEBrickHTTPAuth < Test::Unit::TestCase
http.request(g){|res| assert_not_equal("hoge", res.body, log.call)}
}
}
- log = log.lines.to_a
log.reject! {|line| /\A\s*\z/ =~ line }
pats = [
/ERROR Basic WEBrick's realm: webrick: password unmatch\./,
@@ -154,7 +153,6 @@ class TestWEBrickHTTPAuth < Test::Unit::TestCase
end
}
}
- log = log.lines.to_a
log.reject! {|line| /\A\s*\z/ =~ line }
pats = [
/ERROR Digest WEBrick's realm: no credentials in the request\./,
diff --git a/test/webrick/test_server.rb b/test/webrick/test_server.rb
index 40afdb050e..e46494a132 100644
--- a/test/webrick/test_server.rb
+++ b/test/webrick/test_server.rb
@@ -26,7 +26,7 @@ class TestWEBrickServer < Test::Unit::TestCase
def test_start_exception
stopped = 0
- log = StringIO.new('')
+ log = []
logger = WEBrick::Log.new(log, WEBrick::BasicLog::WARN)
assert_raises(SignalException) do
@@ -47,7 +47,8 @@ class TestWEBrickServer < Test::Unit::TestCase
end
assert_equal(stopped, 1)
- assert_match(/FATAL SignalException: SIGTERM/, log.string)
+ assert_equal(1, log.length)
+ assert_match(/FATAL SignalException: SIGTERM/, log[0])
end
def test_callbacks
diff --git a/test/webrick/utils.rb b/test/webrick/utils.rb
index b15ef9a408..e1c2344fb1 100644
--- a/test/webrick/utils.rb
+++ b/test/webrick/utils.rb
@@ -32,17 +32,13 @@ module TestWEBrick
module_function
def start_server(klass, config={}, &block)
- log_string = ""
- logger = Object.new
- logger.instance_eval do
- define_singleton_method(:<<) {|msg| log_string << msg }
- end
- log = proc { "webrick log start:\n" + log_string.gsub(/^/, " ").chomp + "\nwebrick log end" }
+ log_ary = []
+ log = proc { "webrick log start:\n" + log_ary.join.gsub(/^/, " ").chomp + "\nwebrick log end" }
server = klass.new({
:BindAddress => "127.0.0.1", :Port => 0,
:ServerType => Thread,
- :Logger => WEBrick::Log.new(logger, WEBrick::BasicLog::WARN),
- :AccessLog => [[logger, ""]]
+ :Logger => WEBrick::Log.new(log_ary, WEBrick::BasicLog::WARN),
+ :AccessLog => [[log_ary, ""]]
}.update(config))
server_thread = server.start
addr = server.listeners[0].addr
@@ -54,7 +50,7 @@ module TestWEBrick
end
}
assert_join_threads([client_thread, server_thread])
- log_string
+ log_ary
end
def start_httpserver(config={}, &block)