diff options
Diffstat (limited to 'Library/Homebrew/test/test_utils.rb')
| -rw-r--r-- | Library/Homebrew/test/test_utils.rb | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/Library/Homebrew/test/test_utils.rb b/Library/Homebrew/test/test_utils.rb index c88c0f416..a40a56775 100644 --- a/Library/Homebrew/test/test_utils.rb +++ b/Library/Homebrew/test/test_utils.rb @@ -5,8 +5,11 @@ require "utils/shell" class TtyTests < Homebrew::TestCase def test_strip_ansi - assert_equal "hello", - Tty.strip_ansi("\033\[36;7mhello\033\[0m") + assert_equal "hello", Tty.strip_ansi("\033\[36;7mhello\033\[0m") + end + + def test_width + assert_kind_of Integer, Tty.width end def test_truncate @@ -21,15 +24,26 @@ class TtyTests < Homebrew::TestCase def test_no_tty_formatting $stdout.stubs(:tty?).returns false - assert_nil Tty.blue - assert_nil Tty.white - assert_nil Tty.red - assert_nil Tty.green - assert_nil Tty.gray - assert_nil Tty.yellow - assert_nil Tty.reset - assert_nil Tty.em - assert_nil Tty.highlight + assert_equal "", Tty.to_s + assert_equal "", Tty.red.to_s + assert_equal "", Tty.green.to_s + assert_equal "", Tty.yellow.to_s + assert_equal "", Tty.blue.to_s + assert_equal "", Tty.magenta.to_s + assert_equal "", Tty.cyan.to_s + assert_equal "", Tty.default.to_s + end + + def test_formatting + $stdout.stubs(:tty?).returns(true) + assert_equal "", Tty.to_s + assert_equal "\033[31m", Tty.red.to_s + assert_equal "\033[32m", Tty.green.to_s + assert_equal "\033[33m", Tty.yellow.to_s + assert_equal "\033[34m", Tty.blue.to_s + assert_equal "\033[35m", Tty.magenta.to_s + assert_equal "\033[36m", Tty.cyan.to_s + assert_equal "\033[39m", Tty.default.to_s end end |
