Sha256: a4dfc5f29565c16629806fe0bc789dfa701df4769556a3495e6bd56dd754a665

Contents?: true

Size: 1.57 KB

Versions: 6

Compression:

Stored size: 1.57 KB

Contents

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

module TestLogging
module TestConfig

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

    def test_configuration
      begin
        load Logging.path(%w[data logging.rb])
      rescue Exception => err
        flunk err.inspect
      end

      levels = {
        'deb' => 0,
        'inf' => 1,
        'prt' => 2,
        'wrn' => 3,
        'err' => 4,
        'fat' => 5
      }
      assert_equal levels, Logging::LEVELS
      assert_equal :inspect, Logging::OBJ_FORMAT

      hash = Logging::Repository.instance.instance_variable_get(:@h)
      assert hash.has_key?('A::B::C')
      assert hash.has_key?('yourlogger')
    end

    def test_simple_configuration
      begin
        load Logging.path(%w[data simple_logging.rb])
      rescue Exception => err
        flunk err.inspect
      end

      levels = {
        'debug' => 0,
        'info'  => 1,
        'warn'  => 2,
        'error' => 3,
        'fatal' => 4
      }
      assert_equal levels, Logging::LEVELS
      assert_equal false, Logging.const_defined?('OBJ_FORMAT')

      root = Logging::Logger.root
      assert_equal 1, root.level
    end

    def test_bad_appender_configuration
      assert_raise(Logging::Config::Configurator::Error) {
        load Logging.path(%w[data bad_logging_1.rb])
      }
    end

    def test_bad_layout_configuration
      assert_raise(Logging::Config::Configurator::Error) {
        load Logging.path(%w[data bad_logging_2.rb])
      }
    end
  end

end  # module TestConfig
end  # module TestLogging

# EOF

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
logging-1.6.2 test/config/test_configurator.rb
logging-1.6.1 test/config/test_configurator.rb
logging-1.6.0 test/config/test_configurator.rb
logging-1.5.2 test/config/test_configurator.rb
logging-1.5.1 test/config/test_configurator.rb
logging-1.5.0 test/config/test_configurator.rb