summaryrefslogtreecommitdiff
path: root/spec/unit/provider/cron/unix_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/provider/cron/unix_spec.rb')
-rw-r--r--spec/unit/provider/cron/unix_spec.rb19
1 files changed, 12 insertions, 7 deletions
diff --git a/spec/unit/provider/cron/unix_spec.rb b/spec/unit/provider/cron/unix_spec.rb
index 83e0f431bf..62b941c4aa 100644
--- a/spec/unit/provider/cron/unix_spec.rb
+++ b/spec/unit/provider/cron/unix_spec.rb
@@ -41,10 +41,15 @@ describe Chef::Provider::Cron::Unix do
let(:exitstatus) { 0 }
let(:shell_out) { double("Mixlib::ShellOut", :status => status, :stdout => stdout, :stderr => stderr) }
+ let(:logger) { double("Mixlib::Log::Child").as_null_object }
+
it "is a Chef::Provider:Cron" do
expect(provider).to be_a(Chef::Provider::Cron)
end
+ before do
+ allow(run_context).to receive(:logger).and_return(logger)
+ end
describe "read_crontab" do
let(:stderr) { "" }
let(:stdout) do
@@ -59,7 +64,7 @@ describe Chef::Provider::Cron::Unix do
end
before do
- allow(Chef::Log).to receive(:debug)
+ allow(logger).to receive(:trace)
allow(shell_out).to receive(:format_for_exception).and_return("formatted command output")
allow(provider).to receive(:shell_out).with("/usr/bin/crontab -l", :user => username).and_return(shell_out)
end
@@ -83,7 +88,7 @@ describe Chef::Provider::Cron::Unix do
it "logs the crontab output to debug" do
provider.send(:read_crontab)
- expect(Chef::Log).to have_received(:debug).with("formatted command output")
+ expect(logger).to have_received(:trace).with("formatted command output")
end
end
@@ -91,14 +96,14 @@ describe Chef::Provider::Cron::Unix do
let (:exitstatus) { 2 }
it "should raise an exception if another error occurs" do
- expect {
+ expect do
provider.send(:read_crontab)
- }.to raise_error(Chef::Exceptions::Cron, "Error determining state of #{new_resource.name}, exit: 2")
+ end.to raise_error(Chef::Exceptions::Cron, "Error determining state of #{new_resource.name}, exit: 2")
end
it "logs the crontab output to debug" do
provider.send(:read_crontab) rescue nil
- expect(Chef::Log).to have_received(:debug).with("formatted command output")
+ expect(logger).to have_received(:trace).with("formatted command output")
end
end
end
@@ -130,9 +135,9 @@ describe Chef::Provider::Cron::Unix do
context "when writing the crontab fails" do
let(:exitstatus) { 1 }
it "should raise an exception if the command returns non-zero" do
- expect {
+ expect do
provider.send(:write_crontab, "Foo")
- }.to raise_error(Chef::Exceptions::Cron, /Error updating state of #{new_resource.name}, exit: 1/)
+ end.to raise_error(Chef::Exceptions::Cron, /Error updating state of #{new_resource.name}, exit: 1/)
end
end
end