Sha256: 9398307e0231fe62d51d2f54cbe15c49a8e8b840c2b25b1c439e56815eac3359

Contents?: true

Size: 1.14 KB

Versions: 140

Compression:

Stored size: 1.14 KB

Contents

require File.join(File.expand_path(File.dirname(__FILE__)), '../..', 'test_helper.rb')
require 'rbbt/util/log'

class TestLog < Test::Unit::TestCase
  def test_get_level
    assert_equal 0, Log.get_level(:debug)
    assert_equal 1, Log.get_level(:low)
    assert_equal 1, Log.get_level("LOW")
    assert_equal 1, Log.get_level(1)
    assert_equal 0, Log.get_level(nil)
  end

  def test_color
    assert Log.color(:green, "green")
  end

  def test_no_stderr
    Log.ignore_stderr do
      STDERR.puts "NOPRINT"
    end
  end

  def test_trap_stderr
    Log.trap_stderr do
      STDERR.puts "NOPRINT"
      STDERR.puts "NOPRINT"
      STDERR.puts "NOPRINT"
      STDOUT.puts "PRINT STDOUT"
      STDOUT.puts "PRINT STDOUT"
    end
    Log.trap_stderr do
      STDERR.puts "NOPRINT"
      STDOUT.puts "PRINT STDOUT"
    end
    Log.trap_std do
      STDERR.puts "NOPRINT"
      STDOUT.puts "NOPRINT STDOUT"
    end
  end

  def test_trap_std
    Log.trap_std do
      STDERR.puts "NOPRINT STDERR"
      STDOUT.puts "NOPRINT STDOUT"
    end
    Log.trap_std "OUT", "ERR", 4, 2 do
      STDERR.puts "NOPRINT STDERR"
      STDOUT.puts "NOPRINT STDOUT"
    end
  end
end

Version data entries

140 entries across 140 versions & 1 rubygems

Version Path
rbbt-util-5.43.0 test/rbbt/util/test_log.rb
rbbt-util-5.42.0 test/rbbt/util/test_log.rb
rbbt-util-5.41.1 test/rbbt/util/test_log.rb
rbbt-util-5.41.0 test/rbbt/util/test_log.rb
rbbt-util-5.40.5 test/rbbt/util/test_log.rb
rbbt-util-5.40.4 test/rbbt/util/test_log.rb
rbbt-util-5.40.3 test/rbbt/util/test_log.rb
rbbt-util-5.40.0 test/rbbt/util/test_log.rb
rbbt-util-5.39.0 test/rbbt/util/test_log.rb
rbbt-util-5.38.1 test/rbbt/util/test_log.rb
rbbt-util-5.38.0 test/rbbt/util/test_log.rb
rbbt-util-5.37.16 test/rbbt/util/test_log.rb
rbbt-util-5.37.15 test/rbbt/util/test_log.rb
rbbt-util-5.37.14 test/rbbt/util/test_log.rb
rbbt-util-5.37.13 test/rbbt/util/test_log.rb
rbbt-util-5.37.12 test/rbbt/util/test_log.rb
rbbt-util-5.37.11 test/rbbt/util/test_log.rb
rbbt-util-5.37.10 test/rbbt/util/test_log.rb
rbbt-util-5.37.9 test/rbbt/util/test_log.rb
rbbt-util-5.37.8 test/rbbt/util/test_log.rb