File: case_ansicode.rb

package info (click to toggle)
ruby-ansi 1.5.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 404 kB
  • sloc: ruby: 1,880; makefile: 5
file content (43 lines) | stat: -rw-r--r-- 703 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
40
41
42
43
require 'test_helper'
require 'ansi/code'

testcase ANSI::Code do

  method :red do
    test do
      str = ANSI::Code.red
      out = "\e[31m"
      out.assert == str
    end

    test "with block notation" do
      str = ANSI::Code.red { "Hello" }
      out = "\e[31mHello\e[0m"
      out.assert == str
    end
  end

  method :blue do
    test do
      str = ANSI::Code.blue
      out = "\e[34m"
      out.assert == str
    end

    test "with block notation" do
      str = ANSI::Code.blue { "World" }
      out = "\e[34mWorld\e[0m"
      out.assert == str
    end
  end

  method :hex do
    test do
      str = ANSI::Code.hex("#000000")
      out = "0"
      out.assert == str
    end
  end

end