diff options
author | John Keiser <john@johnkeiser.com> | 2015-12-18 14:48:45 -0800 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2016-01-27 10:23:20 -0800 |
commit | 7520f3d36d2c8029c6c2996dd9289e9f74b9e6d3 (patch) | |
tree | 8e9aa1e623d3c92794dfc502be7350e8aa760e92 /spec/unit/provider/package | |
parent | c3f1021fc6107808826461279cfd6eb055aa6162 (diff) | |
download | chef-7520f3d36d2c8029c6c2996dd9289e9f74b9e6d3.tar.gz |
Fix nil with properties:
1. Warn when default values are invalid.
2. Never validate nil (on set or get) if there is no default.
3. Emit "will be invalid in Chef 13" warning when setting an invalid nil value.
Diffstat (limited to 'spec/unit/provider/package')
-rw-r--r-- | spec/unit/provider/package/dpkg_spec.rb | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/spec/unit/provider/package/dpkg_spec.rb b/spec/unit/provider/package/dpkg_spec.rb index e0bf2accde..f4c938ac7a 100644 --- a/spec/unit/provider/package/dpkg_spec.rb +++ b/spec/unit/provider/package/dpkg_spec.rb @@ -80,30 +80,26 @@ Conflicts: wget-ssl expect { provider.run_action(:purge) }.not_to raise_error end - it "should raise an exception if a source is nil when :install" do - new_resource.source nil - allow(::File).to receive(:exist?).with(source).and_return(false) - expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package) - end + context "when source is nil" do + let(:source) { nil } - it "should raise an exception if a source is nil when :upgrade" do - new_resource.source nil - allow(::File).to receive(:exist?).with(source).and_return(false) - expect { provider.run_action(:upgrade) }.to raise_error(Chef::Exceptions::Package) - end + it "should raise an exception if a source is nil when :install" do + expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package) + end - it "should not raise an exception if a source is nil when :remove" do - new_resource.source nil - allow(::File).to receive(:exist?).with(source).and_return(false) - expect(provider).to receive(:action_remove) - expect { provider.run_action(:remove) }.not_to raise_error - end + it "should raise an exception if a source is nil when :upgrade" do + expect { provider.run_action(:upgrade) }.to raise_error(Chef::Exceptions::Package) + end - it "should not raise an exception if a source is nil when :purge" do - new_resource.source nil - allow(::File).to receive(:exist?).with(source).and_return(false) - expect(provider).to receive(:action_purge) - expect { provider.run_action(:purge) }.not_to raise_error + it "should not raise an exception if a source is nil when :remove" do + expect(provider).to receive(:action_remove) + expect { provider.run_action(:remove) }.not_to raise_error + end + + it "should not raise an exception if a source is nil when :purge" do + expect(provider).to receive(:action_purge) + expect { provider.run_action(:purge) }.not_to raise_error + end end end |