File: test_color_scheme.rb

package info (click to toggle)
ruby-logging 2.2.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 660 kB
  • sloc: ruby: 6,139; sh: 11; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 1,086 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

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

module TestLogging

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

    def setup
      super
      ::Logging.init
    end

    def test_default_color_scheme
      scheme = Logging.color_scheme :default
      assert_instance_of ::Logging::ColorScheme, scheme

      assert_equal false, scheme.include?(:debug)
      assert scheme.include?(:info)
      assert scheme.include?(:warn)
      assert scheme.include?(:error)
      assert scheme.include?(:fatal)
    end

    def test_lines_levels_exclusivity
      assert_raise(ArgumentError) { Logging.color_scheme(:error, :lines => {}, :levels => {}) }
    end

    def test_colorization
      scheme = Logging.color_scheme :default

      assert_equal "no change", scheme.color('no change', :debug)
      assert_equal "\e[32minfo is green\e[0m", scheme.color('info is green', :info)
      assert_equal "\e[37m\e[41mfatal has multiple color codes\e[0m", scheme.color('fatal has multiple color codes', :fatal)
    end

  end  # TestColorScheme
end  # TestLogging