diff options
| author | danielsdeleo <dan@opscode.com> | 2012-11-13 13:19:04 -0800 |
|---|---|---|
| committer | danielsdeleo <dan@opscode.com> | 2012-11-20 20:00:26 -0800 |
| commit | 41a1471ccda66947793e6597fa1f19d0a351e215 (patch) | |
| tree | ec2ec7e614a687849a309b8e2868c1602b18e751 /spec/unit/application_spec.rb | |
| parent | 832674e6254b287a9cd188d5a1756955bee45c6c (diff) | |
| download | chef-41a1471ccda66947793e6597fa1f19d0a351e215.tar.gz | |
Change default output to formatters when in console
Diffstat (limited to 'spec/unit/application_spec.rb')
| -rw-r--r-- | spec/unit/application_spec.rb | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb index c89bc27d4f..e0b0ab7568 100644 --- a/spec/unit/application_spec.rb +++ b/spec/unit/application_spec.rb @@ -20,12 +20,17 @@ require 'spec_helper' describe Chef::Application do before do + @original_conf = Chef::Config.configuration Chef::Log.logger = Logger.new(StringIO.new) @app = Chef::Application.new Dir.stub!(:chdir).and_return(0) @app.stub!(:reconfigure) end + after do + Chef::Config.configuration.replace(@original_conf) + end + describe "reconfigure" do before do @app = Chef::Application.new @@ -170,14 +175,14 @@ describe Chef::Application do end end - describe "configure_logging" do + describe "when configuring the logger" do before do @app = Chef::Application.new Chef::Log.stub!(:init) - Chef::Log.stub!(:level=) end it "should initialise the chef logger" do + Chef::Log.stub!(:level=) Chef::Log.should_receive(:init).with(Chef::Config[:log_location]).and_return(true) @app.configure_logging end @@ -187,6 +192,56 @@ describe Chef::Application do @app.configure_logging end + context "and log_level is :auto" do + before do + Chef::Config[:log_level] = :auto + end + + context "and STDOUT is to a tty" do + before do + STDOUT.stub!(:tty?).and_return(true) + end + + it "configures the log level to :warn" do + @app.configure_logging + Chef::Log.level.should == :warn + end + + context "and force_logger is configured" do + before do + Chef::Config[:force_logger] = true + end + + it "configures the log level to info" do + @app.configure_logging + Chef::Log.level.should == :info + end + end + end + + context "and STDOUT is not to a tty" do + before do + STDOUT.stub!(:tty?).and_return(false) + end + + it "configures the log level to :info" do + @app.configure_logging + Chef::Log.level.should == :info + end + + context "and force_formatter is configured" do + before do + Chef::Config[:force_formatter] = true + end + it "sets the log level to :warn" do + @app.configure_logging + Chef::Log.level.should == :warn + end + end + end + + + end end describe "class method: fatal!" do |
