diff options
author | Julian C. Dunn <jdunn@getchef.com> | 2014-08-03 21:36:33 -0400 |
---|---|---|
committer | Julian C. Dunn <jdunn@getchef.com> | 2014-08-03 21:37:30 -0400 |
commit | fd6b23e91244b0d2b9adfd33fa48d266f56914c3 (patch) | |
tree | a978ec84f39cca9e9b602009489a33c377accbab /spec/unit/provider | |
parent | ca6107a28d675e9d09626958d58e344d969e7e86 (diff) | |
download | chef-fd6b23e91244b0d2b9adfd33fa48d266f56914c3.tar.gz |
Add unit test for #1174
Diffstat (limited to 'spec/unit/provider')
-rw-r--r-- | spec/unit/provider/package/zypper_spec.rb | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/spec/unit/provider/package/zypper_spec.rb b/spec/unit/provider/package/zypper_spec.rb index c437631309..87f02d7794 100644 --- a/spec/unit/provider/package/zypper_spec.rb +++ b/spec/unit/provider/package/zypper_spec.rb @@ -146,25 +146,37 @@ describe Chef::Provider::Package::Zypper do end describe "remove_package" do - it "should run zypper remove with the package name" do - Chef::Config.stub(:[]).with(:zypper_check_gpg).and_return(true) - @provider.should_receive(:shell_out!).with( - "zypper --non-interactive remove emacs=1.0") - @provider.remove_package("emacs", "1.0") + + context "when package version is not explicitly specified" do + it "should run zypper remove with the package name" do + Chef::Config.stub(:[]).with(:zypper_check_gpg).and_return(true) + @provider.should_receive(:shell_out!).with( + "zypper --non-interactive remove emacs") + @provider.remove_package("emacs", nil) + end end - it "should run zypper remove without gpg checks" do - Chef::Config.stub(:[]).with(:zypper_check_gpg).and_return(false) - @provider.should_receive(:shell_out!).with( + + context "when package version is explicitly specified" do + it "should run zypper remove with the package name" do + Chef::Config.stub(:[]).with(:zypper_check_gpg).and_return(true) + @provider.should_receive(:shell_out!).with( + "zypper --non-interactive remove emacs=1.0") + @provider.remove_package("emacs", "1.0") + end + it "should run zypper remove without gpg checks" do + Chef::Config.stub(:[]).with(:zypper_check_gpg).and_return(false) + @provider.should_receive(:shell_out!).with( + "zypper --non-interactive --no-gpg-checks remove emacs=1.0") + @provider.remove_package("emacs", "1.0") + end + it "should warn about gpg checks on zypper remove" do + Chef::Log.should_receive(:warn).with( + /All packages will be installed without gpg signature checks/) + @provider.should_receive(:shell_out!).with( "zypper --non-interactive --no-gpg-checks remove emacs=1.0") - @provider.remove_package("emacs", "1.0") - end - it "should warn about gpg checks on zypper remove" do - Chef::Log.should_receive(:warn).with( - /All packages will be installed without gpg signature checks/) - @provider.should_receive(:shell_out!).with( - "zypper --non-interactive --no-gpg-checks remove emacs=1.0") - @provider.remove_package("emacs", "1.0") + @provider.remove_package("emacs", "1.0") + end end end |