Sha256: f3a4a00f3f85aaff27a3eb2de17b84fb52526df9592f5474b560269e5108f056

Contents?: true

Size: 1.77 KB

Versions: 63

Compression:

Stored size: 1.77 KB

Contents

require File.expand_path('setup', File.dirname(__FILE__))

module TestLogging

  class TestRootLogger < Test::Unit::TestCase
    include LoggingTestCase

    def setup
      super
      @root = ::Logging::Logger.root
    end

    def test_additive
      assert_raise(NoMethodError) {@root.additive}
    end

    def test_additive_eq
      assert_raise(NoMethodError) {@root.additive = true}
    end

    def test_level_eq
      assert_equal 0, @root.level

      assert_raise(ArgumentError) {@root.level = -1}
      assert_raise(ArgumentError) {@root.level =  6}
      assert_raise(ArgumentError) {@root.level = Object}
      assert_raise(ArgumentError) {@root.level = 'bob'}
      assert_raise(ArgumentError) {@root.level = :wtf}

      @root.level = 'INFO'
      assert_equal 1, @root.level

      @root.level = :warn
      assert_equal 2, @root.level

      @root.level = 'error'
      assert_equal 3, @root.level

      @root.level = 4
      assert_equal 4, @root.level

      @root.level = :all
      assert_equal 0, @root.level

      @root.level = 'OFF'
      assert_equal 5, @root.level

      @root.level = nil
      assert_equal 0, @root.level
    end

    def test_name
      assert_equal 'root', @root.name
    end

    def test_parent
      assert_raise(NoMethodError) {@root.parent}
    end

    def test_parent_eq
      assert_raise(NoMethodError) {@root.parent = nil}
    end

    def test_spaceship
      logs = %w(
        A  A::B  A::B::C  A::B::C::D  A::B::C::E  A::B::C::E::G  A::B::C::F
      ).map {|x| ::Logging::Logger[x]}

      logs.each do |log|
        assert_equal(-1, @root <=> log, "'root' <=> '#{log.name}'")
      end

      assert_equal 0, @root <=> @root
      assert_raise(ArgumentError) {@root <=> 'string'}
    end

  end  # class TestRootLogger
end  # module TestLogging

Version data entries

63 entries across 55 versions & 6 rubygems

Version Path
logging-2.4.0 test/test_root_logger.rb
logging-2.3.1 test/test_root_logger.rb
vagrant-unbundled-2.2.19.0 vendor/bundle/ruby/3.0.0/gems/logging-2.3.0/test/test_root_logger.rb
vagrant-unbundled-2.2.18.0 vendor/bundle/ruby/3.0.0/gems/logging-2.3.0/test/test_root_logger.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/3.0.0/gems/logging-2.3.0/test/test_root_logger.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/2.7.0/gems/logging-2.3.0/test/test_root_logger.rb
vagrant-unbundled-2.2.14.0 vendor/bundle/ruby/2.7.0/gems/logging-2.3.0/test/test_root_logger.rb
vagrant-unbundled-2.2.10.0 vendor/bundle/ruby/2.7.0/gems/logging-2.3.0/test/test_root_logger.rb
logging-2.3.0 test/test_root_logger.rb
vagrant-unbundled-2.2.9.0 vendor/bundle/ruby/2.7.0/gems/logging-2.2.2/test/test_root_logger.rb
vagrant-unbundled-2.2.8.0 vendor/bundle/ruby/2.7.0/gems/logging-2.2.2/test/test_root_logger.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/logging-2.2.2/test/test_root_logger.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/logging-2.2.2/test/test_root_logger.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/logging-2.2.2/test/test_root_logger.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/logging-2.2.2/test/test_root_logger.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/logging-2.2.2/test/test_root_logger.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/logging-2.2.2/test/test_root_logger.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/logging-2.2.2/test/test_root_logger.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/logging-2.2.2/test/test_root_logger.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/logging-2.2.2/test/test_root_logger.rb