Sha256: 8bc96a1898c4800de8e0b94cac2835f6e9214a1286656b0d7be1a92b6933a81c

Contents?: true

Size: 1.78 KB

Versions: 2

Compression:

Stored size: 1.78 KB

Contents

# $Id$

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

2 entries across 2 versions & 2 rubygems

Version Path
filterfish-logging-0.9.8 test/test_root_logger.rb
logging-0.8.0 test/test_root_logger.rb