Sha256: 35e102cfdf74fc0ce89a99530d726725fa169bb3f55276c588787efbee954604

Contents?: true

Size: 943 Bytes

Versions: 9

Compression:

Stored size: 943 Bytes

Contents

# -*- encoding: utf-8 -*-

require 'minitest/autorun'
require 'webgen/cli/logger'

class TestLogger < Minitest::Test

  def test_initialize
    l = Webgen::CLI::Logger.new
    assert_equal(::Logger::INFO, l.level)
  end

  def test_log_output
    original = Webgen::CLI::Utils.use_colors
    Webgen::CLI::Utils.use_colors = false
    out, _err = capture_io do
      l = Webgen::CLI::Logger.new
      l.level = ::Logger::DEBUG
      l.info { "information" }
      l.info { "[create] information" }
      l.info { "[update] information" }
      l.info { "[delete] information" }
      l.warn { "warning" }
      l.error{ "error" }
      l.debug('program') { "debug" }
    end
    expected = <<EOF
INFO  information
INFO  [create] information
INFO  [update] information
INFO  [delete] information
WARN  warning
ERROR error
DEBUG (program) debug
EOF
    assert_equal(expected, out)
  ensure
    Webgen::CLI::Utils.use_colors = original
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
webgen-1.7.3 test/webgen/cli/test_logger.rb
webgen-1.7.2 test/webgen/cli/test_logger.rb
webgen-1.7.1 test/webgen/cli/test_logger.rb
webgen-1.7.0 test/webgen/cli/test_logger.rb
webgen-1.6.0 test/webgen/cli/test_logger.rb
webgen-1.5.2 test/webgen/cli/test_logger.rb
webgen-1.5.1 test/webgen/cli/test_logger.rb
webgen-1.5.0 test/webgen/cli/test_logger.rb
webgen-1.4.1 test/webgen/cli/test_logger.rb