test/appenders/test_console.rb in logging-2.2.2 vs test/appenders/test_console.rb in logging-2.3.0
- old
+ new
@@ -18,15 +18,14 @@
def test_initialize
Logging::Repository.instance
appender = Logging.appenders.stdout
assert_equal 'stdout', appender.name
- assert_same STDOUT, appender.instance_variable_get(:@io)
- appender.close
- assert_equal true, appender.closed?
- assert_equal false, STDOUT.closed?
+ io = appender.instance_variable_get(:@io)
+ refute_same STDOUT, io
+ assert_equal STDOUT.fileno, io.fileno
appender = Logging.appenders.stdout('foo')
assert_equal 'foo', appender.name
appender = Logging.appenders.stdout(:level => :warn)
@@ -36,25 +35,43 @@
appender = Logging.appenders.stdout('bar', :level => :error)
assert_equal 'bar', appender.name
assert_equal 3, appender.level
end
- end # class TestStdout
+ def test_reopen
+ Logging::Repository.instance
+ appender = Logging.appenders.stdout
+ io = appender.instance_variable_get(:@io)
+
+ appender.close
+ assert appender.closed?
+ assert io.closed?
+ refute STDOUT.closed?
+
+ appender.reopen
+ refute appender.closed?
+
+ new_io = appender.instance_variable_get(:@io)
+ refute_same io, new_io
+ refute new_io.closed?
+ assert io.closed?
+ end
+ end
+
class TestStderr < Test::Unit::TestCase
include LoggingTestCase
def test_initialize
Logging::Repository.instance
appender = Logging.appenders.stderr
assert_equal 'stderr', appender.name
- assert_same STDERR, appender.instance_variable_get(:@io)
- appender.close
- assert_equal true, appender.closed?
- assert_equal false, STDERR.closed?
+ io = appender.instance_variable_get(:@io)
+ refute_same STDERR, io
+ assert_same STDERR.fileno, io.fileno
appender = Logging.appenders.stderr('foo')
assert_equal 'foo', appender.name
appender = Logging.appenders.stderr(:level => :warn)
@@ -64,10 +81,28 @@
appender = Logging.appenders.stderr('bar', :level => :error)
assert_equal 'bar', appender.name
assert_equal 3, appender.level
end
- end # class TestStderr
+ def test_reopen
+ Logging::Repository.instance
-end # module TestAppenders
-end # module TestLogging
+ appender = Logging.appenders.stderr
+ io = appender.instance_variable_get(:@io)
+
+ appender.close
+ assert appender.closed?
+ assert io.closed?
+ refute STDERR.closed?
+
+ appender.reopen
+ refute appender.closed?
+
+ new_io = appender.instance_variable_get(:@io)
+ refute_same io, new_io
+ refute new_io.closed?
+ assert io.closed?
+ end
+ end
+end
+end