diff options
author | Adam Edwards <adamed@opscode.com> | 2014-10-09 11:50:32 -0700 |
---|---|---|
committer | Adam Edwards <adamed@opscode.com> | 2014-10-09 11:50:32 -0700 |
commit | e544bcbbe323d090a2e3d0c506aa966421370f55 (patch) | |
tree | 7c3d3a28d583d4df6467cde146792497560ac8e5 | |
parent | d75c5b69de9ec183a0ba1c90c6dc5e3c58799301 (diff) | |
parent | a048beaf9cc44433e85fc2f8f5ebdfcc908ba0da (diff) | |
download | chef-e544bcbbe323d090a2e3d0c506aa966421370f55.tar.gz |
Merge pull request #1905 from opscode/adamedx/windows-knife-color
Stop ignoring colored knife output config on Windows
-rw-r--r-- | lib/chef/knife/core/ui.rb | 2 | ||||
-rw-r--r-- | spec/unit/knife/core/ui_spec.rb | 28 |
2 files changed, 29 insertions, 1 deletions
diff --git a/lib/chef/knife/core/ui.rb b/lib/chef/knife/core/ui.rb index 0007480ea2..f3ecfbcae8 100644 --- a/lib/chef/knife/core/ui.rb +++ b/lib/chef/knife/core/ui.rb @@ -113,7 +113,7 @@ class Chef # determined by the value of `config[:color]`. When output is not to a # terminal, colored output is never used def color? - Chef::Config[:color] && stdout.tty? && !Chef::Platform.windows? + Chef::Config[:color] && stdout.tty? end def ask(*args, &block) diff --git a/spec/unit/knife/core/ui_spec.rb b/spec/unit/knife/core/ui_spec.rb index 9044bc2f2f..ed1037ebd5 100644 --- a/spec/unit/knife/core/ui_spec.rb +++ b/spec/unit/knife/core/ui_spec.rb @@ -403,6 +403,34 @@ EOM @ui.format_cookbook_list_for_display(@item).should == response end end + + context "when running on Windows" do + before(:each) do + stdout = double('StringIO', :tty? => true) + @ui.stub(:stdout).and_return(stdout) + Chef::Platform.stub(:windows?) { true } + Chef::Config.reset + end + + after(:each) do + Chef::Config.reset + end + + it "should have color set to true if knife config has color explicitly set to true" do + Chef::Config[:color] = true + @ui.config[:color] = true + expect(@ui.color?).to eql(true) + end + + it "should have color set to false if knife config has color explicitly set to false" do + Chef::Config[:color] = false + expect(@ui.color?).to eql(false) + end + + it "should not have color set to false by default" do + expect(@ui.color?).to eql(false) + end + end end describe "confirm" do |