diff options
| author | Jesse Wolfe <jes5199@gmail.com> | 2009-10-25 22:36:53 -0700 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-10-26 21:00:38 +1100 |
| commit | febe7074d2188e1133503ebc5eade5403a6e271e (patch) | |
| tree | d94608aa6e9fa49b931a2593b39c5d8da53363dd /spec | |
| parent | d383ab897937a7e7e5fcf2929a63241e894f7616 (diff) | |
| download | puppet-febe7074d2188e1133503ebc5eade5403a6e271e.tar.gz puppet-febe7074d2188e1133503ebc5eade5403a6e271e.tar.xz puppet-febe7074d2188e1133503ebc5eade5403a6e271e.zip | |
Bug #1742 Invalid params to --color outputs 'nil'
This patches fixes a bug where setting an invalid option for "--color"
caused the word "nil" to be printed on every line of the log, instead
of printing out log messages.
Invalid color options now just produce uncolored output.
It seems to me that this isn't important enough to issue a warning
about an invalid setting.
Signed-off-by: Jesse Wolfe <jes5199@gmail.com>
Diffstat (limited to 'spec')
| -rwxr-xr-x | spec/unit/util/log.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/unit/util/log.rb b/spec/unit/util/log.rb index 4e2c8dcc5..35e6a71e8 100755 --- a/spec/unit/util/log.rb +++ b/spec/unit/util/log.rb @@ -13,6 +13,42 @@ describe Puppet::Util::Log do Puppet::Util::Log.close_all end + describe Puppet::Util::Log::DestConsole do + before do + @console = Puppet::Util::Log::DestConsole.new + end + + it "should colorize if Puppet[:color] is :ansi" do + Puppet[:color] = :ansi + + @console.colorize(:alert, "abc").should == "\e[0;31mabc\e[0m" + end + + it "should colorize if Puppet[:color] is 'yes'" do + Puppet[:color] = "yes" + + @console.colorize(:alert, "abc").should == "\e[0;31mabc\e[0m" + end + + it "should htmlize if Puppet[:color] is :html" do + Puppet[:color] = :html + + @console.colorize(:alert, "abc").should == "<span style=\"color: FFA0A0\">abc</span>" + end + + it "should do nothing if Puppet[:color] is false" do + Puppet[:color] = false + + @console.colorize(:alert, "abc").should == "abc" + end + + it "should do nothing if Puppet[:color] is invalid" do + Puppet[:color] = "invalid option" + + @console.colorize(:alert, "abc").should == "abc" + end + end + describe "instances" do before do Puppet::Util::Log.stubs(:newmessage) |
