diff --git a/test/helper.rb b/test/helper.rb new file mode 100644 index 0000000000..d29332104b --- /dev/null +++ b/test/helper.rb @@ -0,0 +1,5 @@ +ROOT_DIR = File.dirname(__dir__) +$LOAD_PATH.unshift File.join(ROOT_DIR, 'lib') # to use logger in this repo instead of ruby built-in logger +$LOAD_PATH.unshift File.join(ROOT_DIR, 'test', 'lib') # to use custom test-unit in this repo +require 'logger' +require 'test/unit' diff --git a/test/logger/test_logdevice.rb b/test/logger/test_logdevice.rb index 7d5bf9ac81..30047f89b1 100644 --- a/test/logger/test_logdevice.rb +++ b/test/logger/test_logdevice.rb @@ -1,7 +1,6 @@ # coding: US-ASCII # frozen_string_literal: false -require 'test/unit' -require 'logger' +require_relative '../helper' require 'tempfile' require 'tmpdir' diff --git a/test/logger/test_logger.rb b/test/logger/test_logger.rb index 3f2319b961..5806e0c685 100644 --- a/test/logger/test_logger.rb +++ b/test/logger/test_logger.rb @@ -1,7 +1,6 @@ # coding: US-ASCII # frozen_string_literal: false -require 'test/unit' -require 'logger' +require_relative '../helper' require 'tempfile' class TestLogger < Test::Unit::TestCase diff --git a/test/logger/test_severity.rb b/test/logger/test_severity.rb index 8889a1dc52..4da23cdd0f 100644 --- a/test/logger/test_severity.rb +++ b/test/logger/test_severity.rb @@ -1,7 +1,6 @@ # coding: US-ASCII # frozen_string_literal: false -require 'test/unit' -require 'logger' +require_relative '../helper' class TestLoggerSeverity < Test::Unit::TestCase def test_enum @@ -13,13 +12,13 @@ class TestLoggerSeverity < Test::Unit::TestCase end assert_equal(levels.size, Logger::Severity.constants.size) end - + def test_level_assignment logger = Logger.new(nil) - + Logger::Severity.constants.each do |level| next if level == :UNKNOWN - + logger.send("#{level.downcase}!") assert(logger.level) == Logger::Severity.const_get(level) end