Sha256: 15b0d9b2fbb5f3ef3b1b6a729eac6db91c0b9208b9891b73a0544cb710bf7485

Contents?: true

Size: 1.77 KB

Versions: 43

Compression:

Stored size: 1.77 KB

Contents

require File.join(File.dirname(__FILE__), %w[setup])

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

# EOF

Version data entries

43 entries across 43 versions & 6 rubygems

Version Path
TwP-logging-0.9.7 test/test_root_logger.rb
TwP-logging-0.9.8.1 test/test_root_logger.rb
TwP-logging-0.9.8.2 test/test_root_logger.rb
TwP-logging-0.9.8 test/test_root_logger.rb
TwP-logging-1.0.0 test/test_root_logger.rb
TwP-logging-1.1.0 test/test_root_logger.rb
TwP-logging-1.1.1 test/test_root_logger.rb
TwP-logging-1.1.2 test/test_root_logger.rb
TwP-logging-1.1.3 test/test_root_logger.rb
TwP-logging-1.1.4 test/test_root_logger.rb
TwP-logging-1.2.0 test/test_root_logger.rb
TwP-logging-1.2.2 test/test_root_logger.rb
ottobar-logging-0.9.5.1 test/test_root_logger.rb
pjstadig-logging-1.1.4.1 test/test_root_logger.rb
logging-1.4.3 test/test_root_logger.rb
sgeorgi-logging-1.4.2 test/test_root_logger.rb
logging-1.4.2 test/test_root_logger.rb
logging-1.4.1 test/test_root_logger.rb
logging-1.4.0 test/test_root_logger.rb
redcar-0.3.1dev lib/logging/test/test_root_logger.rb