diff options
Diffstat (limited to 'spec/unit/provider/package/yum_spec.rb')
-rw-r--r-- | spec/unit/provider/package/yum_spec.rb | 234 |
1 files changed, 117 insertions, 117 deletions
diff --git a/spec/unit/provider/package/yum_spec.rb b/spec/unit/provider/package/yum_spec.rb index 70ab257a54..efbbdf6450 100644 --- a/spec/unit/provider/package/yum_spec.rb +++ b/spec/unit/provider/package/yum_spec.rb @@ -16,18 +16,18 @@ # limitations under the License. # -require 'spec_helper' -require 'securerandom' +require "spec_helper" +require "securerandom" describe Chef::Provider::Package::Yum do before(:each) do @node = Chef::Node.new @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - @new_resource = Chef::Resource::YumPackage.new('cups') + @new_resource = Chef::Resource::YumPackage.new("cups") @status = double("Status", :exitstatus => 0) @yum_cache = double( - 'Chef::Provider::Yum::YumCache', + "Chef::Provider::Yum::YumCache", :reload_installed => true, :reset => true, :installed_version => "1.2.4-11.18.el5", @@ -77,15 +77,15 @@ describe Chef::Provider::Package::Yum do describe "when source is provided" do it "should set the candidate version" do - @new_resource = Chef::Resource::YumPackage.new('testing.source') + @new_resource = Chef::Resource::YumPackage.new("testing.source") @new_resource.source "chef-server-core-12.0.5-1.rpm" @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) allow(File).to receive(:exists?).with(@new_resource.source).and_return(true) allow(@yum_cache).to receive(:installed_version).and_return(nil) - shellout_double = double(:stdout => 'chef-server-core 12.0.5-1') + shellout_double = double(:stdout => "chef-server-core 12.0.5-1") allow(@provider).to receive(:shell_out!).and_return(shellout_double) @provider.load_current_resource - expect(@provider.candidate_version).to eql('12.0.5-1') + expect(@provider.candidate_version).to eql("12.0.5-1") end end @@ -113,7 +113,7 @@ describe Chef::Provider::Package::Yum do end it "when the new_resource is a vanilla package class and yum-deprecated exists" do - @new_resource = Chef::Resource::Package.new('cups') + @new_resource = Chef::Resource::Package.new("cups") expect(File).to receive(:exist?).with("/usr/bin/yum-deprecated").and_return(true) expect(@yum_cache).to receive(:yum_binary=).with("yum-deprecated") @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @@ -121,7 +121,7 @@ describe Chef::Provider::Package::Yum do end it "when the new_resource is a vanilla package class and yum-deprecated does not exist" do - @new_resource = Chef::Resource::Package.new('cups') + @new_resource = Chef::Resource::Package.new("cups") expect(File).to receive(:exist?).with("/usr/bin/yum-deprecated").and_return(false) expect(@yum_cache).to receive(:yum_binary=).with("yum") @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @@ -131,9 +131,9 @@ describe Chef::Provider::Package::Yum do describe "when arch in package_name" do it "should set the arch if no existing package_name is found and new_package_name+new_arch is available" do - @new_resource = Chef::Resource::YumPackage.new('testing.noarch') + @new_resource = Chef::Resource::YumPackage.new("testing.noarch") @yum_cache = double( - 'Chef::Provider::Yum::YumCache' + "Chef::Provider::Yum::YumCache" ) allow(@yum_cache).to receive(:installed_version) do |package_name, arch| # nothing installed for package_name/new_package_name @@ -157,7 +157,7 @@ describe Chef::Provider::Package::Yum do expect(@provider.new_resource.arch).to eq("noarch") expect(@provider.arch).to eq("noarch") - @new_resource = Chef::Resource::YumPackage.new('testing.more.noarch') + @new_resource = Chef::Resource::YumPackage.new("testing.more.noarch") @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource expect(@provider.new_resource.package_name).to eq("testing.more") @@ -167,9 +167,9 @@ describe Chef::Provider::Package::Yum do describe "when version constraint in package_name" do it "should set package_version if no existing package_name is found and new_package_name is available" do - @new_resource = Chef::Resource::Package.new('cups = 1.2.4-11.18.el5_2.3') + @new_resource = Chef::Resource::Package.new("cups = 1.2.4-11.18.el5_2.3") @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) - allow(@yum_cache).to receive(:package_available?) { |pkg| pkg == 'cups' ? true : false } + allow(@yum_cache).to receive(:package_available?) { |pkg| pkg == "cups" ? true : false } allow(@yum_cache).to receive(:packages_from_require) do |pkg| [Chef::Provider::Package::Yum::RPMDbPackage.new("cups", "1.2.4-11.18.el5_2.3", "noarch", [], false, true, "base"), Chef::Provider::Package::Yum::RPMDbPackage.new("cups", "1.2.4-11.18.el5_2.2", "noarch", [], false, true, "base")] @@ -186,9 +186,9 @@ describe Chef::Provider::Package::Yum do end it "should not set the arch when an existing package_name is found" do - @new_resource = Chef::Resource::YumPackage.new('testing.beta3') + @new_resource = Chef::Resource::YumPackage.new("testing.beta3") @yum_cache = double( - 'Chef::Provider::Yum::YumCache' + "Chef::Provider::Yum::YumCache" ) allow(@yum_cache).to receive(:installed_version) do |package_name, arch| # installed for package_name @@ -213,7 +213,7 @@ describe Chef::Provider::Package::Yum do expect(@provider.new_resource.arch).to eq(nil) expect(@provider.arch).to eq(nil) - @new_resource = Chef::Resource::YumPackage.new('testing.beta3.more') + @new_resource = Chef::Resource::YumPackage.new("testing.beta3.more") @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource expect(@provider.new_resource.package_name).to eq("testing.beta3.more") @@ -222,9 +222,9 @@ describe Chef::Provider::Package::Yum do end it "should not set the arch when no existing package_name or new_package_name+new_arch is found" do - @new_resource = Chef::Resource::YumPackage.new('testing.beta3') + @new_resource = Chef::Resource::YumPackage.new("testing.beta3") @yum_cache = double( - 'Chef::Provider::Yum::YumCache' + "Chef::Provider::Yum::YumCache" ) allow(@yum_cache).to receive(:installed_version) do |package_name, arch| # nothing installed for package_name/new_package_name @@ -244,7 +244,7 @@ describe Chef::Provider::Package::Yum do expect(@provider.new_resource.arch).to eq(nil) expect(@provider.arch).to eq(nil) - @new_resource = Chef::Resource::YumPackage.new('testing.beta3.more') + @new_resource = Chef::Resource::YumPackage.new("testing.beta3.more") @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource expect(@provider.new_resource.package_name).to eq("testing.beta3.more") @@ -253,10 +253,10 @@ describe Chef::Provider::Package::Yum do end it "should ensure it doesn't clobber an existing arch if passed" do - @new_resource = Chef::Resource::YumPackage.new('testing.i386') + @new_resource = Chef::Resource::YumPackage.new("testing.i386") @new_resource.arch("x86_64") @yum_cache = double( - 'Chef::Provider::Yum::YumCache' + "Chef::Provider::Yum::YumCache" ) allow(@yum_cache).to receive(:installed_version) do |package_name, arch| # nothing installed for package_name/new_package_name @@ -313,7 +313,7 @@ describe Chef::Provider::Package::Yum do context "when the package name isn't found" do let(:yum_cache) { double( - 'Chef::Provider::Yum::YumCache', + "Chef::Provider::Yum::YumCache", :reload_installed => true, :reset => true, :installed_version => "1.0.1.el5", @@ -334,61 +334,61 @@ describe Chef::Provider::Package::Yum do it "should search provides then set package_name to match" do @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource - expect(@new_resource.package_name).to eq('test-package') + expect(@new_resource.package_name).to eq("test-package") expect(@new_resource.version).to eq(nil) end it "should search provides then set version to match if a requirement was passed in the package name" do - @new_resource = Chef::Resource::YumPackage.new('test-package = 2.0.1.el5') + @new_resource = Chef::Resource::YumPackage.new("test-package = 2.0.1.el5") @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource - expect(@new_resource.package_name).to eq('test-package') - expect(@new_resource.version).to eq('2.0.1.el5') + expect(@new_resource.package_name).to eq("test-package") + expect(@new_resource.version).to eq("2.0.1.el5") end it "should search provides then set version to match if a requirement was passed in the version" do - @new_resource = Chef::Resource::YumPackage.new('test-package') - @new_resource.version('= 2.0.1.el5') + @new_resource = Chef::Resource::YumPackage.new("test-package") + @new_resource.version("= 2.0.1.el5") @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource - expect(@new_resource.package_name).to eq('test-package') - expect(@new_resource.version).to eq('2.0.1.el5') + expect(@new_resource.package_name).to eq("test-package") + expect(@new_resource.version).to eq("2.0.1.el5") end it "should search provides and not set the version to match if a specific version was requested" do - @new_resource = Chef::Resource::YumPackage.new('test-package') - @new_resource.version('3.0.1.el5') + @new_resource = Chef::Resource::YumPackage.new("test-package") + @new_resource.version("3.0.1.el5") @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource - expect(@new_resource.package_name).to eq('test-package') - expect(@new_resource.version).to eq('3.0.1.el5') + expect(@new_resource.package_name).to eq("test-package") + expect(@new_resource.version).to eq("3.0.1.el5") end it "should search provides then set versions to match if requirements were passed in the package name as an array" do - @new_resource = Chef::Resource::YumPackage.new(['test-package = 2.0.1.el5']) + @new_resource = Chef::Resource::YumPackage.new(["test-package = 2.0.1.el5"]) @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource - expect(@new_resource.package_name).to eq(['test-package']) - expect(@new_resource.version).to eq(['2.0.1.el5']) + expect(@new_resource.package_name).to eq(["test-package"]) + expect(@new_resource.version).to eq(["2.0.1.el5"]) end it "should search provides and not set the versions to match if specific versions were requested in an array" do - @new_resource = Chef::Resource::YumPackage.new(['test-package']) - @new_resource.version(['3.0.1.el5']) + @new_resource = Chef::Resource::YumPackage.new(["test-package"]) + @new_resource.version(["3.0.1.el5"]) @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource - expect(@new_resource.package_name).to eq(['test-package']) - expect(@new_resource.version).to eq(['3.0.1.el5']) + expect(@new_resource.package_name).to eq(["test-package"]) + expect(@new_resource.version).to eq(["3.0.1.el5"]) end end it "should not return an error if no version number is specified in the resource" do - @new_resource = Chef::Resource::YumPackage.new('test-package') + @new_resource = Chef::Resource::YumPackage.new("test-package") @yum_cache = double( - 'Chef::Provider::Yum::YumCache', + "Chef::Provider::Yum::YumCache", :reload_installed => true, :reset => true, :installed_version => "1.0.1.el5", @@ -408,9 +408,9 @@ describe Chef::Provider::Package::Yum do end it "should give precedence to the version attribute when both a requirement in the resource name and a version attribute are specified" do - @new_resource = Chef::Resource::YumPackage.new('test-package') + @new_resource = Chef::Resource::YumPackage.new("test-package") @yum_cache = double( - 'Chef::Provider::Yum::YumCache', + "Chef::Provider::Yum::YumCache", :reload_installed => true, :reset => true, :installed_version => "1.2.4-11.18.el5", @@ -423,17 +423,17 @@ describe Chef::Provider::Package::Yum do allow(@yum_cache).to receive(:yum_binary=).with("yum") pkg = Chef::Provider::Package::Yum::RPMPackage.new("test-package", "2.0.1.el5", "x86_64", []) expect(@yum_cache).to receive(:packages_from_require).and_return([pkg]) - @new_resource = Chef::Resource::YumPackage.new('test-package = 2.0.1.el5') - @new_resource.version('3.0.1.el5') + @new_resource = Chef::Resource::YumPackage.new("test-package = 2.0.1.el5") + @new_resource.version("3.0.1.el5") @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource - expect(@new_resource.package_name).to eq('test-package') - expect(@new_resource.version).to eq('3.0.1.el5') + expect(@new_resource.package_name).to eq("test-package") + expect(@new_resource.version).to eq("3.0.1.el5") end it "should correctly detect the installed states of an array of package names and version numbers" do @yum_cache = double( - 'Chef::Provider::Yum::YumCache', + "Chef::Provider::Yum::YumCache", :reload_installed => true, :reset => true, :installed_version => "1.0.1.el5", @@ -448,17 +448,17 @@ describe Chef::Provider::Package::Yum do expect(@yum_cache).to receive(:packages_from_require).exactly(4).times.and_return([]) expect(@yum_cache).to receive(:reload_provides).twice - @new_resource = Chef::Resource::YumPackage.new(['test-package','test-package2']) - @new_resource.version(['2.0.1.el5','3.0.1.el5']) + @new_resource = Chef::Resource::YumPackage.new(["test-package","test-package2"]) + @new_resource.version(["2.0.1.el5","3.0.1.el5"]) @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource - expect(@new_resource.package_name).to eq(['test-package','test-package2']) - expect(@new_resource.version).to eq(['2.0.1.el5','3.0.1.el5']) + expect(@new_resource.package_name).to eq(["test-package","test-package2"]) + expect(@new_resource.version).to eq(["2.0.1.el5","3.0.1.el5"]) end it "should search provides if no package is available - if no match in installed provides then load the complete set" do @yum_cache = double( - 'Chef::Provider::Yum::YumCache', + "Chef::Provider::Yum::YumCache", :reload_installed => true, :reset => true, :installed_version => "1.2.4-11.18.el5", @@ -478,7 +478,7 @@ describe Chef::Provider::Package::Yum do it "should search provides if no package is available and not load the complete set if action is :remove or :purge" do @yum_cache = double( - 'Chef::Provider::Yum::YumCache', + "Chef::Provider::Yum::YumCache", :reload_installed => true, :reset => true, :installed_version => "1.2.4-11.18.el5", @@ -502,7 +502,7 @@ describe Chef::Provider::Package::Yum do it "should search provides if no package is available - if no match in provides leave the name intact" do @yum_cache = double( - 'Chef::Provider::Yum::YumCache', + "Chef::Provider::Yum::YumCache", :reload_provides => true, :reload_installed => true, :reset => true, @@ -562,7 +562,7 @@ describe Chef::Provider::Package::Yum do it "installs the package with the options given in the resource" do @provider.load_current_resource - allow(@provider).to receive(:candidate_version).and_return('11') + allow(@provider).to receive(:candidate_version).and_return("11") allow(@new_resource).to receive(:options).and_return("--disablerepo epmd") allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1) expect(@provider).to receive(:yum_command).with( @@ -573,7 +573,7 @@ describe Chef::Provider::Package::Yum do it "should raise an exception if the package is not available" do @yum_cache = double( - 'Chef::Provider::Yum::YumCache', + "Chef::Provider::Yum::YumCache", :reload_from_cache => true, :reset => true, :installed_version => "1.2.4-11.18.el5", @@ -591,7 +591,7 @@ describe Chef::Provider::Package::Yum do it "should raise an exception if candidate version is older than the installed version and allow_downgrade is false" do allow(@new_resource).to receive(:allow_downgrade).and_return(false) @yum_cache = double( - 'Chef::Provider::Yum::YumCache', + "Chef::Provider::Yum::YumCache", :reload_installed => true, :reset => true, :installed_version => "1.2.4-11.18.el5", @@ -610,7 +610,7 @@ describe Chef::Provider::Package::Yum do it "should not raise an exception if candidate version is older than the installed version and the package is list in yum's installonlypkg option" do @yum_cache = double( - 'Chef::Provider::Yum::YumCache', + "Chef::Provider::Yum::YumCache", :reload_installed => true, :reset => true, :installed_version => "1.2.4-11.18.el5", @@ -634,7 +634,7 @@ describe Chef::Provider::Package::Yum do it "should run yum downgrade if candidate version is older than the installed version and allow_downgrade is true" do allow(@new_resource).to receive(:allow_downgrade).and_return(true) @yum_cache = double( - 'Chef::Provider::Yum::YumCache', + "Chef::Provider::Yum::YumCache", :reload_installed => true, :reset => true, :installed_version => "1.2.4-11.18.el5", @@ -681,7 +681,7 @@ describe Chef::Provider::Package::Yum do describe "when upgrading a package" do it "should run yum install if the package is installed and a version is given" do @provider.load_current_resource - allow(@provider).to receive(:candidate_version).and_return('11') + allow(@provider).to receive(:candidate_version).and_return("11") allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1) expect(@provider).to receive(:yum_command).with( "-d0 -e0 -y install cups-11" @@ -691,8 +691,8 @@ describe Chef::Provider::Package::Yum do it "should run yum install if the package is not installed" do @provider.load_current_resource - @current_resource = Chef::Resource::Package.new('cups') - allow(@provider).to receive(:candidate_version).and_return('11') + @current_resource = Chef::Resource::Package.new("cups") + allow(@provider).to receive(:candidate_version).and_return("11") allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1) expect(@provider).to receive(:yum_command).with( "-d0 -e0 -y install cups-11" @@ -702,7 +702,7 @@ describe Chef::Provider::Package::Yum do it "should raise an exception if candidate version is older than the installed version" do @yum_cache = double( - 'Chef::Provider::Yum::YumCache', + "Chef::Provider::Yum::YumCache", :reload_installed => true, :reset => true, :installed_version => "1.2.4-11.18.el5", @@ -722,8 +722,8 @@ describe Chef::Provider::Package::Yum do # Test our little workaround, some crossover into Chef::Provider::Package territory it "should call action_upgrade in the parent if the current resource version is nil" do allow(@yum_cache).to receive(:installed_version).and_return(nil) - @current_resource = Chef::Resource::Package.new('cups') - allow(@provider).to receive(:candidate_version).and_return('11') + @current_resource = Chef::Resource::Package.new("cups") + allow(@provider).to receive(:candidate_version).and_return("11") expect(@provider).to receive(:upgrade_package).with( "cups", "11", @@ -733,7 +733,7 @@ describe Chef::Provider::Package::Yum do it "should call action_upgrade in the parent if the candidate version is nil" do @provider.load_current_resource - @current_resource = Chef::Resource::Package.new('cups') + @current_resource = Chef::Resource::Package.new("cups") allow(@provider).to receive(:candidate_version).and_return(nil) expect(@provider).not_to receive(:upgrade_package) @provider.run_action(:upgrade) @@ -741,8 +741,8 @@ describe Chef::Provider::Package::Yum do it "should call action_upgrade in the parent if the candidate is newer" do @provider.load_current_resource - @current_resource = Chef::Resource::Package.new('cups') - allow(@provider).to receive(:candidate_version).and_return('11') + @current_resource = Chef::Resource::Package.new("cups") + allow(@provider).to receive(:candidate_version).and_return("11") expect(@provider).to receive(:upgrade_package).with( "cups", "11", @@ -753,8 +753,8 @@ describe Chef::Provider::Package::Yum do it "should not call action_upgrade in the parent if the candidate is older" do allow(@yum_cache).to receive(:installed_version).and_return("12") @provider.load_current_resource - @current_resource = Chef::Resource::Package.new('cups') - allow(@provider).to receive(:candidate_version).and_return('11') + @current_resource = Chef::Resource::Package.new("cups") + allow(@provider).to receive(:candidate_version).and_return("11") expect(@provider).not_to receive(:upgrade_package) @provider.run_action(:upgrade) end @@ -989,37 +989,37 @@ describe Chef::Provider::Package::Yum::RPMUtils do end it "tests isalnum good input" do - [ 'a', 'z', 'A', 'Z', '0', '9' ].each do |t| + [ "a", "z", "A", "Z", "0", "9" ].each do |t| expect(@rpmutils.isalnum(t)).to eq(true) end end it "tests isalnum bad input" do - [ '-', '.', '!', '^', ':', '_' ].each do |t| + [ "-", ".", "!", "^", ":", "_" ].each do |t| expect(@rpmutils.isalnum(t)).to eq(false) end end it "tests isalpha good input" do - [ 'a', 'z', 'A', 'Z' ].each do |t| + [ "a", "z", "A", "Z" ].each do |t| expect(@rpmutils.isalpha(t)).to eq(true) end end it "tests isalpha bad input" do - [ '0', '9', '-', '.', '!', '^', ':', '_' ].each do |t| + [ "0", "9", "-", ".", "!", "^", ":", "_" ].each do |t| expect(@rpmutils.isalpha(t)).to eq(false) end end it "tests isdigit good input" do - [ '0', '9' ].each do |t| + [ "0", "9" ].each do |t| expect(@rpmutils.isdigit(t)).to eq(true) end end it "tests isdigit bad input" do - [ 'A', 'z', '-', '.', '!', '^', ':', '_' ].each do |t| + [ "A", "z", "-", ".", "!", "^", ":", "_" ].each do |t| expect(@rpmutils.isdigit(t)).to eq(false) end end @@ -2115,18 +2115,18 @@ describe "Chef::Provider::Package::Yum - Multi" do @node = Chef::Node.new @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - @new_resource = Chef::Resource::Package.new(['cups', 'vim']) + @new_resource = Chef::Resource::Package.new(["cups", "vim"]) @status = double("Status", :exitstatus => 0) @yum_cache = double( - 'Chef::Provider::Yum::YumCache', + "Chef::Provider::Yum::YumCache", :reload_installed => true, :reset => true, - :installed_version => 'XXXX', - :candidate_version => 'YYYY', + :installed_version => "XXXX", + :candidate_version => "YYYY", :package_available? => true, :version_available? => true, - :allow_multi_install => [ 'kernel' ], - :package_repository => 'base', + :allow_multi_install => [ "kernel" ], + :package_repository => "base", :disable_extra_repo_control => true, ) allow(Chef::Provider::Package::Yum::YumCache).to receive(:instance).and_return(@yum_cache) @@ -2139,12 +2139,12 @@ describe "Chef::Provider::Package::Yum - Multi" do describe "when loading the current system state" do it "should create a current resource with the name of the new_resource" do @provider.load_current_resource - expect(@provider.current_resource.name).to eq('cups, vim') + expect(@provider.current_resource.name).to eq("cups, vim") end it "should set the current resources package name to the new resources package name" do @provider.load_current_resource - expect(@provider.current_resource.package_name).to eq(['cups', 'vim']) + expect(@provider.current_resource.package_name).to eq(["cups", "vim"]) end it "should set the installed version to nil on the current resource if no installed package" do @@ -2154,21 +2154,21 @@ describe "Chef::Provider::Package::Yum - Multi" do end it "should set the installed version if yum has one" do - allow(@yum_cache).to receive(:installed_version).with('cups', nil).and_return('1.2.4-11.18.el5') - allow(@yum_cache).to receive(:installed_version).with('vim', nil).and_return('1.0') - allow(@yum_cache).to receive(:candidate_version).with('cups', nil).and_return('1.2.4-11.18.el5_2.3') - allow(@yum_cache).to receive(:candidate_version).with('vim', nil).and_return('1.5') + allow(@yum_cache).to receive(:installed_version).with("cups", nil).and_return("1.2.4-11.18.el5") + allow(@yum_cache).to receive(:installed_version).with("vim", nil).and_return("1.0") + allow(@yum_cache).to receive(:candidate_version).with("cups", nil).and_return("1.2.4-11.18.el5_2.3") + allow(@yum_cache).to receive(:candidate_version).with("vim", nil).and_return("1.5") @provider.load_current_resource - expect(@provider.current_resource.version).to eq(['1.2.4-11.18.el5', '1.0']) + expect(@provider.current_resource.version).to eq(["1.2.4-11.18.el5", "1.0"]) end it "should set the candidate version if yum info has one" do - allow(@yum_cache).to receive(:installed_version).with('cups', nil).and_return('1.2.4-11.18.el5') - allow(@yum_cache).to receive(:installed_version).with('vim', nil).and_return('1.0') - allow(@yum_cache).to receive(:candidate_version).with('cups', nil).and_return('1.2.4-11.18.el5_2.3') - allow(@yum_cache).to receive(:candidate_version).with('vim', nil).and_return('1.5') + allow(@yum_cache).to receive(:installed_version).with("cups", nil).and_return("1.2.4-11.18.el5") + allow(@yum_cache).to receive(:installed_version).with("vim", nil).and_return("1.0") + allow(@yum_cache).to receive(:candidate_version).with("cups", nil).and_return("1.2.4-11.18.el5_2.3") + allow(@yum_cache).to receive(:candidate_version).with("vim", nil).and_return("1.5") @provider.load_current_resource - expect(@provider.candidate_version).to eql(['1.2.4-11.18.el5_2.3', '1.5']) + expect(@provider.candidate_version).to eql(["1.2.4-11.18.el5_2.3", "1.5"]) end it "should return the current resouce" do @@ -2177,20 +2177,20 @@ describe "Chef::Provider::Package::Yum - Multi" do describe "when version constraint in package_name" do it "should set package_version if no existing package_name is found and new_package_name is available" do - @new_resource = Chef::Resource::Package.new(['cups = 1.2.4-11.18.el5_2.3', 'emacs = 24.4']) + @new_resource = Chef::Resource::Package.new(["cups = 1.2.4-11.18.el5_2.3", "emacs = 24.4"]) @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) allow(@yum_cache).to receive(:package_available?) { |pkg| %w(cups emacs).include?(pkg) ? true : false } allow(@yum_cache).to receive(:candidate_version) do |pkg| - if pkg == 'cups' + if pkg == "cups" "1.2.4-11.18.el5_2.3" - elsif pkg == 'emacs' + elsif pkg == "emacs" "24.4" end end allow(@yum_cache).to receive(:packages_from_require) do |pkg| - if pkg.name == 'cups' + if pkg.name == "cups" [Chef::Provider::Package::Yum::RPMDbPackage.new("cups", "1.2.4-11.18.el5_2.3", "noarch", [], false, true, "base")] - elsif pkg.name == 'emacs' + elsif pkg.name == "emacs" [Chef::Provider::Package::Yum::RPMDbPackage.new("emacs", "24.4", "noarch", [], false, true, "base")] end end @@ -2210,12 +2210,12 @@ describe "Chef::Provider::Package::Yum - Multi" do it "should run yum install with the package name and version" do @provider.load_current_resource allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1) - allow(@yum_cache).to receive(:installed_version).with('cups', nil).and_return('1.2.4-11.18.el5') - allow(@yum_cache).to receive(:installed_version).with('vim', nil).and_return('0.9') + allow(@yum_cache).to receive(:installed_version).with("cups", nil).and_return("1.2.4-11.18.el5") + allow(@yum_cache).to receive(:installed_version).with("vim", nil).and_return("0.9") expect(@provider).to receive(:yum_command).with( "-d0 -e0 -y install cups-1.2.4-11.19.el5 vim-1.0" ) - @provider.install_package(["cups", "vim"], ["1.2.4-11.19.el5", '1.0']) + @provider.install_package(["cups", "vim"], ["1.2.4-11.19.el5", "1.0"]) end it "should run yum install with the package name, version and arch" do @@ -2231,17 +2231,17 @@ describe "Chef::Provider::Package::Yum - Multi" do it "installs the package with the options given in the resource" do @provider.load_current_resource allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1) - allow(@yum_cache).to receive(:installed_version).with('cups', nil).and_return('1.2.4-11.18.el5') - allow(@yum_cache).to receive(:installed_version).with('vim', nil).and_return('0.9') + allow(@yum_cache).to receive(:installed_version).with("cups", nil).and_return("1.2.4-11.18.el5") + allow(@yum_cache).to receive(:installed_version).with("vim", nil).and_return("0.9") expect(@provider).to receive(:yum_command).with( "-d0 -e0 -y --disablerepo epmd install cups-1.2.4-11.19.el5 vim-1.0" ) allow(@new_resource).to receive(:options).and_return("--disablerepo epmd") - @provider.install_package(["cups", "vim"], ["1.2.4-11.19.el5", '1.0']) + @provider.install_package(["cups", "vim"], ["1.2.4-11.19.el5", "1.0"]) end it "should run yum install with the package name and version when name has arch" do - @new_resource = Chef::Resource::Package.new(['cups.x86_64', 'vim']) + @new_resource = Chef::Resource::Package.new(["cups.x86_64", "vim"]) @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1) @@ -2249,20 +2249,20 @@ describe "Chef::Provider::Package::Yum - Multi" do # and we need to craft the right response. The default mock setup above # will just return valid versions all the time which won't work for this # test. - allow(@yum_cache).to receive(:installed_version).with('cups', 'x86_64').and_return('XXXX') - allow(@yum_cache).to receive(:candidate_version).with('cups', 'x86_64').and_return('1.2.4-11.18.el5') - allow(@yum_cache).to receive(:installed_version).with('cups.x86_64').and_return(nil) - allow(@yum_cache).to receive(:candidate_version).with('cups.x86_64').and_return(nil) + allow(@yum_cache).to receive(:installed_version).with("cups", "x86_64").and_return("XXXX") + allow(@yum_cache).to receive(:candidate_version).with("cups", "x86_64").and_return("1.2.4-11.18.el5") + allow(@yum_cache).to receive(:installed_version).with("cups.x86_64").and_return(nil) + allow(@yum_cache).to receive(:candidate_version).with("cups.x86_64").and_return(nil) # Normal mock's for the idempotency check - allow(@yum_cache).to receive(:installed_version).with('cups', nil).and_return('1.2.4-11.18.el5') - allow(@yum_cache).to receive(:installed_version).with('vim', nil).and_return('0.9') + allow(@yum_cache).to receive(:installed_version).with("cups", nil).and_return("1.2.4-11.18.el5") + allow(@yum_cache).to receive(:installed_version).with("vim", nil).and_return("0.9") @provider.load_current_resource expect(@provider).to receive(:yum_command).with( "-d0 -e0 -y install cups-1.2.4-11.19.el5.x86_64 vim-1.0" ) - @provider.install_package(["cups", "vim"], ["1.2.4-11.19.el5", '1.0']) + @provider.install_package(["cups", "vim"], ["1.2.4-11.19.el5", "1.0"]) end end |