diff options
Diffstat (limited to 'spec/unit/provider/log_spec.rb')
-rw-r--r-- | spec/unit/provider/log_spec.rb | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/spec/unit/provider/log_spec.rb b/spec/unit/provider/log_spec.rb index ce7b1af55a..deb2024640 100644 --- a/spec/unit/provider/log_spec.rb +++ b/spec/unit/provider/log_spec.rb @@ -32,44 +32,49 @@ describe Chef::Provider::Log::ChefLog do let(:provider) { Chef::Provider::Log::ChefLog.new(new_resource, run_context) } - it "should write the string to the Chef::Log object at default level (info)" do - expect(Chef::Log).to receive(:info).with(log_str).and_return(true) + let(:logger) { double("Mixlib::Log::Child").as_null_object } + before do + allow(run_context).to receive(:logger).and_return(logger) + end + + it "should write the string to the logger object at default level (info)" do + expect(logger).to receive(:info).with(log_str).and_return(true) provider.run_action(:write) end - it "should write the string to the Chef::Log object at debug level" do + it "should write the string to the logger object at debug level" do new_resource.level :debug - expect(Chef::Log).to receive(:debug).with(log_str).and_return(true) + expect(logger).to receive(:debug).with(log_str).and_return(true) provider.run_action(:write) end - it "should write the string to the Chef::Log object at info level" do + it "should write the string to the logger object at info level" do new_resource.level :info - expect(Chef::Log).to receive(:info).with(log_str).and_return(true) + expect(logger).to receive(:info).with(log_str).and_return(true) provider.run_action(:write) end - it "should write the string to the Chef::Log object at warn level" do + it "should write the string to the logger object at warn level" do new_resource.level :warn - expect(Chef::Log).to receive(:warn).with(log_str).and_return(true) + expect(logger).to receive(:warn).with(log_str).and_return(true) provider.run_action(:write) end - it "should write the string to the Chef::Log object at error level" do + it "should write the string to the logger object at error level" do new_resource.level :error - expect(Chef::Log).to receive(:error).with(log_str).and_return(true) + expect(logger).to receive(:error).with(log_str).and_return(true) provider.run_action(:write) end - it "should write the string to the Chef::Log object at fatal level" do + it "should write the string to the logger object at fatal level" do new_resource.level :fatal - expect(Chef::Log).to receive(:fatal).with(log_str).and_return(true) + expect(logger).to receive(:fatal).with(log_str).and_return(true) provider.run_action(:write) end it "should print the string in why-run mode" do Chef::Config[:why_run] = true - expect(Chef::Log).to receive(:info).with(log_str).and_return(true) + expect(logger).to receive(:info).with(log_str).and_return(true) provider.run_action(:write) end |