summaryrefslogtreecommitdiff
path: root/test/tc_highline.rb
diff options
context:
space:
mode:
authorRichard LeBer <richard.leber@gmail.com>2011-06-27 10:09:32 -0400
committerRichard LeBer <richard.leber@gmail.com>2011-06-27 10:09:32 -0400
commit7a0d90856343999bb40dd754c422cafd990f3f55 (patch)
tree812fa8cda22139d887fce8839b612556a11e8dcd /test/tc_highline.rb
parentf853f4a534374ddb4df9f828fa63d3ef2d167d75 (diff)
downloadhighline-7a0d90856343999bb40dd754c422cafd990f3f55.tar.gz
Add uncolor method and tests
Diffstat (limited to 'test/tc_highline.rb')
-rw-r--r--test/tc_highline.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/tc_highline.rb b/test/tc_highline.rb
index b118ae4..745c0b3 100644
--- a/test/tc_highline.rb
+++ b/test/tc_highline.rb
@@ -207,6 +207,13 @@ class TestHighLine < Test::Unit::TestCase
assert_equal("This should be \e[38;5;137mrgb_906030\e[0m!\n", @output.string)
@output.truncate(@output.rewind)
+
+ # Does class method work, too?
+ @terminal.say("This should be <%= HighLine.color('reverse underlined magenta', :reverse, :underline, :magenta) %>!")
+ assert_equal( "This should be \e[7m\e[4m\e[35mreverse underlined magenta\e[0m!\n",
+ @output.string )
+
+ @output.truncate(@output.rewind)
# turn off color
old_setting = HighLine.use_color?
@@ -215,6 +222,27 @@ class TestHighLine < Test::Unit::TestCase
assert_equal("This should be cyan!\n", @output.string)
HighLine.use_color = old_setting
end
+
+ def test_uncolor
+ # instance method
+ assert_equal( "This should be reverse underlined magenta!\n",
+ @terminal.uncolor("This should be \e[7m\e[4m\e[35mreverse underlined magenta\e[0m!\n")
+ )
+
+ @output.truncate(@output.rewind)
+
+ # class method
+ assert_equal( "This should be reverse underlined magenta!\n",
+ HighLine.uncolor("This should be \e[7m\e[4m\e[35mreverse underlined magenta\e[0m!\n")
+ )
+
+ @output.truncate(@output.rewind)
+
+ # RGB color
+ assert_equal( "This should be rgb_906030!\n",
+ @terminal.uncolor("This should be \e[38;5;137mrgb_906030\e[0m!\n")
+ )
+ end
def test_confirm
@input << "junk.txt\nno\nsave.txt\ny\n"