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.34.16 test/rbbt/util/test_log.rb
rbbt-util-5.34.15 test/rbbt/util/test_log.rb
rbbt-util-5.34.14 test/rbbt/util/test_log.rb
rbbt-util-5.34.13 test/rbbt/util/test_log.rb
rbbt-util-5.34.12 test/rbbt/util/test_log.rb
rbbt-util-5.34.11 test/rbbt/util/test_log.rb
rbbt-util-5.34.10 test/rbbt/util/test_log.rb
rbbt-util-5.34.9 test/rbbt/util/test_log.rb
rbbt-util-5.34.8 test/rbbt/util/test_log.rb
rbbt-util-5.34.7 test/rbbt/util/test_log.rb
rbbt-util-5.34.5 test/rbbt/util/test_log.rb
rbbt-util-5.34.4 test/rbbt/util/test_log.rb
rbbt-util-5.34.3 test/rbbt/util/test_log.rb
rbbt-util-5.34.2 test/rbbt/util/test_log.rb
rbbt-util-5.34.1 test/rbbt/util/test_log.rb
rbbt-util-5.34.0 test/rbbt/util/test_log.rb
rbbt-util-5.33.21 test/rbbt/util/test_log.rb
rbbt-util-5.33.20 test/rbbt/util/test_log.rb
rbbt-util-5.33.19 test/rbbt/util/test_log.rb
rbbt-util-5.33.18 test/rbbt/util/test_log.rb