diff options
author | Serdar Sutay <serdar@opscode.com> | 2015-05-22 12:27:09 -0700 |
---|---|---|
committer | Serdar Sutay <serdar@opscode.com> | 2015-05-29 08:41:40 -0700 |
commit | 3ed66239de9c65e1e6515332b187de6988725ec2 (patch) | |
tree | 4139ff8e0abe7e7775ab6e15bdcf4efda302d0c8 | |
parent | 676342c040a2e282425648e6e833047c048fea7b (diff) | |
download | chef-sd/CI-31.tar.gz |
Minor updates for PR comments.sd/CI-31
-rw-r--r-- | lib/chef/audit/logger.rb | 6 | ||||
-rw-r--r-- | lib/chef/client.rb | 2 | ||||
-rw-r--r-- | spec/support/shared/context/client.rb | 5 |
3 files changed, 5 insertions, 8 deletions
diff --git a/lib/chef/audit/logger.rb b/lib/chef/audit/logger.rb index c5c9f5c8a2..e46f54e582 100644 --- a/lib/chef/audit/logger.rb +++ b/lib/chef/audit/logger.rb @@ -21,11 +21,9 @@ class Chef class Audit class Logger def self.puts(message="") - if @buffer.nil? - @buffer = StringIO.new - end - + @buffer ||= StringIO.new @buffer.puts(message) + Chef::Log.info(message) end diff --git a/lib/chef/client.rb b/lib/chef/client.rb index 9f16efb31e..141827e65b 100644 --- a/lib/chef/client.rb +++ b/lib/chef/client.rb @@ -723,7 +723,7 @@ class Chef auditor.run if auditor.failed? audit_exception = Chef::Exceptions::AuditsFailed.new(auditor.num_failed, auditor.num_total) - events.audit_phase_failed(audit_exception) + @events.audit_phase_failed(audit_exception, Chef::Audit::Logger.read_buffer) else @events.audit_phase_complete(Chef::Audit::Logger.read_buffer) end diff --git a/spec/support/shared/context/client.rb b/spec/support/shared/context/client.rb index f5c21a3c65..eb537e9889 100644 --- a/spec/support/shared/context/client.rb +++ b/spec/support/shared/context/client.rb @@ -201,7 +201,6 @@ shared_context "audit phase completed" do def stub_for_audit # -- Client#run_audits expect(Chef::Audit::Runner).to receive(:new).and_return(audit_runner) - expect(Chef::Audit::Logger).to receive(:read_buffer).and_return("Audit mode output!") expect(audit_runner).to receive(:run).and_return(true) expect(client.events).to receive(:audit_phase_complete) end @@ -218,7 +217,7 @@ shared_context "audit phase failed with error" do expect(Chef::Audit::Runner).to receive(:new).and_return(audit_runner) expect(Chef::Audit::Logger).to receive(:read_buffer).and_return("Audit mode output!") expect(audit_runner).to receive(:run).and_raise(audit_error) - expect(client.events).to receive(:audit_phase_failed).with(audit_error) + expect(client.events).to receive(:audit_phase_failed).with(audit_error, "Audit mode output!") end end @@ -239,7 +238,7 @@ shared_context "audit phase completed with failed controls" do expect(Chef::Exceptions::AuditsFailed).to receive(:new).with( audit_runner.num_failed, audit_runner.num_total ).and_return(audit_error) - expect(client.events).to receive(:audit_phase_failed).with(audit_error) + expect(client.events).to receive(:audit_phase_failed).with(audit_error, "Audit mode output!") end end |