File: case_mixin.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 (35 lines) | stat: -rw-r--r-- 530 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
require 'test_helper'
require 'ansi/mixin'

testcase ANSI::Mixin do

  # TODO: subclass
  class ::String
    include ANSI::Mixin
  end

  method :red do
    test do
      str = "Hello".red
      out = "\e[31mHello\e[0m"
      out.assert == str
    end
  end

  method :blue do
    test do
      str = "World".blue
      out = "\e[34mWorld\e[0m"
      out.assert == str
    end
  end

  method :display do
    test do
      str = "Hello".display(4,10)
      out = "\e[s\e[4;10HHello\e[u"
      out.assert == str
    end
  end

end