Sha256: 53d67d1d218e3de3783de21aa79f8a09abfd3e35a579db0b9701f8fbcbd1f3fc

Contents?: true

Size: 952 Bytes

Versions: 3

Compression:

Stored size: 952 Bytes

Contents

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

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

class TestLogger < MiniTest::Unit::TestCase

  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

3 entries across 3 versions & 1 rubygems

Version Path
webgen-1.0.0.beta3 test/webgen/cli/test_logger.rb
webgen-1.0.0.beta2 test/webgen/cli/test_logger.rb
webgen-1.0.0.beta1 test/webgen/cli/test_logger.rb