diff options
Diffstat (limited to 'test/test_color_scheme.rb')
-rw-r--r-- | test/test_color_scheme.rb | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/test/test_color_scheme.rb b/test/test_color_scheme.rb index 9b4d61b..0716327 100644 --- a/test/test_color_scheme.rb +++ b/test/test_color_scheme.rb @@ -3,7 +3,7 @@ # tc_color_scheme.rb # -# Created by Jeremy Hinegardner on 2007-01-24. +# Created by Jeremy Hinegardner on 2007-01-24. # Copyright 2007 Jeremy Hinegardner. All rights reserved. # # This is Free Software. See LICENSE and COPYING for details. @@ -22,32 +22,37 @@ class TestColorScheme < Minitest::Test end def test_using_color_scheme - assert_equal(false,HighLine.using_color_scheme?) + refute(HighLine.using_color_scheme?) HighLine.color_scheme = HighLine::ColorScheme.new - assert_equal(true,HighLine.using_color_scheme?) + assert(true, HighLine.using_color_scheme?) end def test_scheme HighLine.color_scheme = HighLine::SampleColorScheme.new @terminal.say("This should be <%= color('warning yellow', :warning) %>.") - assert_equal("This should be \e[1m\e[33mwarning yellow\e[0m.\n",@output.string) + assert_equal("This should be \e[1m\e[33mwarning yellow\e[0m.\n", + @output.string) @output.rewind - + @terminal.say("This should be <%= color('warning yellow', 'warning') %>.") - assert_equal("This should be \e[1m\e[33mwarning yellow\e[0m.\n",@output.string) + assert_equal("This should be \e[1m\e[33mwarning yellow\e[0m.\n", + @output.string) @output.rewind @terminal.say("This should be <%= color('warning yellow', 'WarNing') %>.") - assert_equal("This should be \e[1m\e[33mwarning yellow\e[0m.\n",@output.string) + assert_equal("This should be \e[1m\e[33mwarning yellow\e[0m.\n", + @output.string) @output.rewind - + # Check that keys are available, and as expected - assert_equal ["critical", "error", "warning", "notice", "info", "debug", "row_even", "row_odd"].sort, + assert_equal %w[critical error warning notice + info debug row_even row_odd].sort, HighLine.color_scheme.keys.sort - - # Color scheme doesn't care if we use symbols or strings, and is case-insensitive + + # Color scheme doesn't care if we use symbols or strings. + # And it isn't case-sensitive warning1 = HighLine.color_scheme[:warning] warning2 = HighLine.color_scheme["warning"] warning3 = HighLine.color_scheme[:wArning] @@ -62,7 +67,7 @@ class TestColorScheme < Minitest::Test # Nonexistent keys return nil assert_nil HighLine.color_scheme[:nonexistent] - + # Same as above, for definitions defn1 = HighLine.color_scheme.definition(:warning) defn2 = HighLine.color_scheme.definition("warning") @@ -77,18 +82,19 @@ class TestColorScheme < Minitest::Test assert_equal [:bold, :yellow], defn3 assert_equal [:bold, :yellow], defn4 assert_nil HighLine.color_scheme.definition(:nonexistent) - + color_scheme_hash = HighLine.color_scheme.to_hash assert_instance_of Hash, color_scheme_hash - assert_equal ["critical", "error", "warning", "notice", "info", "debug", "row_even", "row_odd"].sort, + assert_equal %w[critical error warning notice + info debug row_even row_odd].sort, color_scheme_hash.keys.sort assert_instance_of Array, HighLine.color_scheme.definition(:warning) assert_equal [:bold, :yellow], HighLine.color_scheme.definition(:warning) # turn it back off, should raise an exception HighLine.color_scheme = nil - assert_raises(NameError) { + assert_raises(NameError) do @terminal.say("This should be <%= color('nothing at all', :error) %>.") - } + end end -end +end |