diff options
| author | Markus Reiter | 2016-08-26 16:04:47 +0200 |
|---|---|---|
| committer | Markus Reiter | 2016-10-01 20:00:49 +0200 |
| commit | 6d8ee395fa5878282a1ce3975b632103448be042 (patch) | |
| tree | 557520df749494a6a58ee54a139d4238ad41380d /Library/Homebrew/test | |
| parent | 19e633f1900ea910c2a9db85dc7c7bea0825676d (diff) | |
| download | brew-6d8ee395fa5878282a1ce3975b632103448be042.tar.bz2 | |
Refactor Tty.
Diffstat (limited to 'Library/Homebrew/test')
| -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 |
