summaryrefslogtreecommitdiff
path: root/spec/unit/provider/package/rpm_spec.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2017-01-09 10:47:17 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2017-02-11 15:13:31 -0800
commit67c44883fda6097385a7d378930177a9c85643b8 (patch)
tree4ebd7be6e31182006607b360f13e763044bed136 /spec/unit/provider/package/rpm_spec.rb
parent4bea26334396755625b3094272d9852b400bb053 (diff)
downloadchef-67c44883fda6097385a7d378930177a9c85643b8.tar.gz
package provider cleanuplcg/package-cleanup
- cleans up a lot of ivar usage - converts most providers to shell_out_compact_timeout! - almost deprecates a few APIs, but can't quite yet - windows providers need mixlib-shellout to take an argv Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec/unit/provider/package/rpm_spec.rb')
-rw-r--r--spec/unit/provider/package/rpm_spec.rb46
1 files changed, 23 insertions, 23 deletions
diff --git a/spec/unit/provider/package/rpm_spec.rb b/spec/unit/provider/package/rpm_spec.rb
index 1d179edf76..3730878026 100644
--- a/spec/unit/provider/package/rpm_spec.rb
+++ b/spec/unit/provider/package/rpm_spec.rb
@@ -41,7 +41,7 @@ describe Chef::Provider::Package::Rpm do
let(:rpm_q_status) { instance_double("Mixlib::ShellOut", exitstatus: rpm_q_exitstatus, stdout: rpm_q_stdout) }
before(:each) do
- allow(::File).to receive(:exists?).with("PLEASE STUB File.exists? EXACTLY").and_return(true)
+ allow(::File).to receive(:exist?).with("PLEASE STUB File.exists? EXACTLY").and_return(true)
# Ensure all shell out usage is stubbed with exact arguments
allow(provider).to receive(:shell_out!).with("PLEASE STUB YOUR SHELLOUT CALLS").and_return(nil)
@@ -61,7 +61,7 @@ describe Chef::Provider::Package::Rpm do
context "when the source is a file that doesn't exist" do
it "should raise an exception when attempting any action" do
- allow(::File).to receive(:exists?).with(package_source).and_return(false)
+ allow(::File).to receive(:exist?).with(package_source).and_return(false)
expect { provider.run_action(:any) }.to raise_error(Chef::Exceptions::Package)
end
end
@@ -71,7 +71,7 @@ describe Chef::Provider::Package::Rpm do
let(:package_source) { "foobar://example.com/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm" }
it "should raise an exception if an uri formed source is non-supported scheme" do
- allow(::File).to receive(:exists?).with(package_source).and_return(false)
+ allow(::File).to receive(:exist?).with(package_source).and_return(false)
# verify let bindings are as we expect
expect(new_resource.source).to eq("foobar://example.com/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm")
@@ -86,18 +86,18 @@ describe Chef::Provider::Package::Rpm do
before do
expect(provider).to receive(:shell_out!).
- with("rpm -qp --queryformat '%{NAME} %{VERSION}-%{RELEASE}\n' #{package_source}", timeout: 900).
+ with("rpm", "-qp", "--queryformat", "%{NAME} %{VERSION}-%{RELEASE}\n", package_source, timeout: 900).
and_return(rpm_qp_status)
expect(provider).to receive(:shell_out).
- with("rpm -q --queryformat '%{NAME} %{VERSION}-%{RELEASE}\n' #{package_name}", timeout: 900).
+ with("rpm", "-q", "--queryformat", "%{NAME} %{VERSION}-%{RELEASE}\n", package_name, timeout: 900).
and_return(rpm_q_status)
end
context "when rpm fails when querying package installed state" do
before do
- allow(::File).to receive(:exists?).with(package_source).and_return(true)
+ allow(::File).to receive(:exist?).with(package_source).and_return(true)
end
let(:rpm_qp_stdout) { "ImageMagick-c++ 6.5.4.7-7.el6_5" }
@@ -129,7 +129,7 @@ describe Chef::Provider::Package::Rpm do
context "when the source is a file system path" do
before do
- allow(::File).to receive(:exists?).with(package_source).and_return(true)
+ allow(::File).to receive(:exist?).with(package_source).and_return(true)
provider.action = action
@@ -151,7 +151,7 @@ describe Chef::Provider::Package::Rpm do
context "when at the desired version already" do
it "does nothing when the correct version is installed" do
- expect(provider).to_not receive(:shell_out!).with("rpm -i /tmp/imagemagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
+ expect(provider).to_not receive(:shell_out!).with("rpm", "-i", "/tmp/imagemagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
provider.action_install
end
@@ -162,7 +162,7 @@ describe Chef::Provider::Package::Rpm do
let(:rpm_q_stdout) { "imagemagick-c++ 0.5.4.7-7.el6_5" }
it "runs rpm -u with the package source to upgrade" do
- expect(provider).to receive(:shell_out!).with("rpm -U /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
+ expect(provider).to receive(:shell_out!).with("rpm", "-U", "/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
provider.action_install
end
end
@@ -178,7 +178,7 @@ describe Chef::Provider::Package::Rpm do
let(:rpm_q_stdout) { "imagemagick-c++ 21.4-19.el6_5" }
it "should run rpm -u --oldpackage with the package source to downgrade" do
- expect(provider).to receive(:shell_out!).with("rpm -U --oldpackage /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
+ expect(provider).to receive(:shell_out!).with("rpm", "-U", "--oldpackage", "/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
provider.action_install
end
@@ -192,7 +192,7 @@ describe Chef::Provider::Package::Rpm do
context "when at the desired version already" do
it "does nothing when the correct version is installed" do
- expect(provider).to_not receive(:shell_out!).with("rpm -i /tmp/imagemagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
+ expect(provider).to_not receive(:shell_out!).with("rpm", "-i", "/tmp/imagemagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
provider.action_upgrade
end
@@ -203,7 +203,7 @@ describe Chef::Provider::Package::Rpm do
let(:rpm_q_stdout) { "imagemagick-c++ 0.5.4.7-7.el6_5" }
it "runs rpm -u with the package source to upgrade" do
- expect(provider).to receive(:shell_out!).with("rpm -U /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
+ expect(provider).to receive(:shell_out!).with("rpm", "-U", "/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
provider.action_upgrade
end
end
@@ -219,7 +219,7 @@ describe Chef::Provider::Package::Rpm do
let(:rpm_q_stdout) { "imagemagick-c++ 21.4-19.el6_5" }
it "should run rpm -u --oldpackage with the package source to downgrade" do
- expect(provider).to receive(:shell_out!).with("rpm -U --oldpackage /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
+ expect(provider).to receive(:shell_out!).with("rpm", "-U", "--oldpackage", "/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
provider.action_upgrade
end
@@ -231,7 +231,7 @@ describe Chef::Provider::Package::Rpm do
let(:action) { :remove }
it "should remove the package" do
- expect(provider).to receive(:shell_out!).with("rpm -e ImageMagick-c++-6.5.4.7-7.el6_5", timeout: 900)
+ expect(provider).to receive(:shell_out!).with("rpm", "-e", "ImageMagick-c++-6.5.4.7-7.el6_5", timeout: 900)
provider.action_remove
end
end
@@ -276,7 +276,7 @@ describe Chef::Provider::Package::Rpm do
context "when the source is given as an URI" do
before(:each) do
- allow(::File).to receive(:exists?).with(package_source).and_return(false)
+ allow(::File).to receive(:exist?).with(package_source).and_return(false)
provider.action = action
@@ -322,7 +322,7 @@ describe Chef::Provider::Package::Rpm do
let(:action) { :install }
before do
- allow(File).to receive(:exists?).with(package_source).and_return(true)
+ allow(File).to receive(:exist?).with(package_source).and_return(true)
provider.action = action
@@ -357,7 +357,7 @@ describe Chef::Provider::Package::Rpm do
describe "action install" do
it "installs the package" do
- expect(provider).to receive(:shell_out!).with("rpm -i #{package_source}", timeout: 900)
+ expect(provider).to receive(:shell_out!).with("rpm", "-i", package_source, timeout: 900)
provider.action_install
end
@@ -365,7 +365,7 @@ describe Chef::Provider::Package::Rpm do
context "when custom resource options are given" do
it "installs with custom options specified in the resource" do
new_resource.options("--dbpath /var/lib/rpm")
- expect(provider).to receive(:shell_out!).with("rpm --dbpath /var/lib/rpm -i #{package_source}", timeout: 900)
+ expect(provider).to receive(:shell_out!).with("rpm", "--dbpath", "/var/lib/rpm", "-i", package_source, timeout: 900)
provider.action_install
end
end
@@ -376,7 +376,7 @@ describe Chef::Provider::Package::Rpm do
let(:action) { :upgrade }
it "installs the package" do
- expect(provider).to receive(:shell_out!).with("rpm -i #{package_source}", timeout: 900)
+ expect(provider).to receive(:shell_out!).with("rpm", "-i", package_source, timeout: 900)
provider.action_upgrade
end
@@ -387,7 +387,7 @@ describe Chef::Provider::Package::Rpm do
let(:action) { :remove }
it "should do nothing" do
- expect(provider).to_not receive(:shell_out!).with("rpm -e ImageMagick-c++-6.5.4.7-7.el6_5", timeout: 900)
+ expect(provider).to_not receive(:shell_out!).with("rpm", "-e", "ImageMagick-c++-6.5.4.7-7.el6_5", timeout: 900)
provider.action_remove
end
end
@@ -404,7 +404,7 @@ describe Chef::Provider::Package::Rpm do
# provider will call File.exists?. Because of the ordering in our
# let() bindings and such, we have to set the stub here and not in a
# before block.
- allow(::File).to receive(:exists?).with(package_source).and_return(true)
+ allow(::File).to receive(:exist?).with(package_source).and_return(true)
Chef::Resource::Package.new("/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm")
end
@@ -413,7 +413,7 @@ describe Chef::Provider::Package::Rpm do
it "should install from a path when the package is a path and the source is nil" do
expect(new_resource.source).to eq("/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm")
provider.current_resource = current_resource
- expect(provider).to receive(:shell_out!).with("rpm -i /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
+ expect(provider).to receive(:shell_out!).with("rpm", "-i", "/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
provider.install_package("/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", "6.5.4.7-7.el6_5")
end
@@ -421,7 +421,7 @@ describe Chef::Provider::Package::Rpm do
expect(new_resource.source).to eq("/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm")
current_resource.version("21.4-19.el5")
provider.current_resource = current_resource
- expect(provider).to receive(:shell_out!).with("rpm -U /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
+ expect(provider).to receive(:shell_out!).with("rpm", "-U", "/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", timeout: 900)
provider.upgrade_package("/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", "6.5.4.7-7.el6_5")
end
end