diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-02-09 07:53:56 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-02-09 07:53:56 -0800 |
commit | f073747786abbe6ada55ed24b696a03e39c3c45d (patch) | |
tree | 7971d871e89d522a58291713761a6c83f68e8d19 /spec/unit/provider | |
parent | c6e69783705cfd48bfea0c943dc071964dd21311 (diff) | |
download | chef-f073747786abbe6ada55ed24b696a03e39c3c45d.tar.gz |
auto fixing some rubocops
Style/NegatedWhile
Style/ParenthesesAroundCondition
Style/WhileUntilDo
Style/WordArray
Performance/ReverseEach
Style/ColonMethodCall
Diffstat (limited to 'spec/unit/provider')
20 files changed, 92 insertions, 92 deletions
diff --git a/spec/unit/provider/file/content_spec.rb b/spec/unit/provider/file/content_spec.rb index ebef4faa09..9ebcf10dcc 100644 --- a/spec/unit/provider/file/content_spec.rb +++ b/spec/unit/provider/file/content_spec.rb @@ -66,13 +66,13 @@ describe Chef::Provider::File::Content do it "returns a tempfile in the tempdir when :file_staging_uses_destdir is not set" do Chef::Config[:file_staging_uses_destdir] = false - expect(content.tempfile.path.start_with?(Dir::tmpdir)).to be_truthy + expect(content.tempfile.path.start_with?(Dir.tmpdir)).to be_truthy expect(canonicalize_path(content.tempfile.path).start_with?(enclosing_directory)).to be_falsey end it "returns a tempfile in the destdir when :file_deployment_uses_destdir is set" do Chef::Config[:file_staging_uses_destdir] = true - expect(content.tempfile.path.start_with?(Dir::tmpdir)).to be_falsey + expect(content.tempfile.path.start_with?(Dir.tmpdir)).to be_falsey expect(canonicalize_path(content.tempfile.path).start_with?(enclosing_directory)).to be_truthy end @@ -83,7 +83,7 @@ describe Chef::Provider::File::Content do it "returns a tempfile in the tempdir when :file_deployment_uses_destdir is set to :auto" do Chef::Config[:file_staging_uses_destdir] = :auto - expect(content.tempfile.path.start_with?(Dir::tmpdir)).to be_truthy + expect(content.tempfile.path.start_with?(Dir.tmpdir)).to be_truthy expect(canonicalize_path(content.tempfile.path).start_with?(enclosing_directory)).to be_falsey end @@ -93,7 +93,7 @@ describe Chef::Provider::File::Content do end it "returns a tempfile in the tempdir when :file_desployment_uses_destdir is not set" do - expect(content.tempfile.path.start_with?(Dir::tmpdir)).to be_truthy + expect(content.tempfile.path.start_with?(Dir.tmpdir)).to be_truthy expect(canonicalize_path(content.tempfile.path).start_with?(enclosing_directory)).to be_falsey end end diff --git a/spec/unit/provider/group/dscl_spec.rb b/spec/unit/provider/group/dscl_spec.rb index 52aff87dc5..e060e4af10 100644 --- a/spec/unit/provider/group/dscl_spec.rb +++ b/spec/unit/provider/group/dscl_spec.rb @@ -184,7 +184,7 @@ describe Chef::Provider::Group::Dscl do before do allow(@new_resource).to receive(:members).and_return([]) allow(@new_resource).to receive(:append).and_return(false) - allow(@current_resource).to receive(:members).and_return(["all", "your", "base"]) + allow(@current_resource).to receive(:members).and_return(%w(all your base)) end it "should log an appropriate message" do @@ -201,7 +201,7 @@ describe Chef::Provider::Group::Dscl do describe "with supplied members in the new resource" do before do - @new_resource.members(["all", "your", "base"]) + @new_resource.members(%w(all your base)) @current_resource.members([]) end @@ -326,6 +326,6 @@ EOF end it "should parse members properly" do allow(File).to receive(:exists?).and_return(true) - expect(@current_resource.members).to eq(["waka", "bar"]) + expect(@current_resource.members).to eq(%w(waka bar)) end end diff --git a/spec/unit/provider/group/groupadd_spec.rb b/spec/unit/provider/group/groupadd_spec.rb index b4295c9dff..e8b47621c4 100644 --- a/spec/unit/provider/group/groupadd_spec.rb +++ b/spec/unit/provider/group/groupadd_spec.rb @@ -25,12 +25,12 @@ describe Chef::Provider::Group::Groupadd, "set_options" do @run_context = Chef::RunContext.new(@node, {}, @events) @new_resource = Chef::Resource::Group.new("aj") @new_resource.gid(50) - @new_resource.members(["root", "aj"]) + @new_resource.members(%w(root aj)) @new_resource.system false @new_resource.non_unique false @current_resource = Chef::Resource::Group.new("aj") @current_resource.gid(50) - @current_resource.members(["root", "aj"]) + @current_resource.members(%w(root aj)) @current_resource.system false @current_resource.non_unique false @provider = Chef::Provider::Group::Groupadd.new(@new_resource, @run_context) diff --git a/spec/unit/provider/group/pw_spec.rb b/spec/unit/provider/group/pw_spec.rb index 2c563750f3..250946fd1a 100644 --- a/spec/unit/provider/group/pw_spec.rb +++ b/spec/unit/provider/group/pw_spec.rb @@ -26,11 +26,11 @@ describe Chef::Provider::Group::Pw do @new_resource = Chef::Resource::Group.new("wheel") @new_resource.gid 50 - @new_resource.members [ "root", "aj"] + @new_resource.members %w(root aj) @current_resource = Chef::Resource::Group.new("aj") @current_resource.gid 50 - @current_resource.members [ "root", "aj"] + @current_resource.members %w(root aj) @provider = Chef::Provider::Group::Pw.new(@new_resource, @run_context) @provider.current_resource = @current_resource end @@ -89,7 +89,7 @@ describe Chef::Provider::Group::Pw do describe "with an empty members array in the new resource and existing members in the current resource" do before do allow(@new_resource).to receive(:members).and_return([]) - allow(@current_resource).to receive(:members).and_return(["all", "your", "base"]) + allow(@current_resource).to receive(:members).and_return(%w(all your base)) end it "should log an appropriate message" do @@ -104,7 +104,7 @@ describe Chef::Provider::Group::Pw do describe "with supplied members array in the new resource and an empty members array in the current resource" do before do - allow(@new_resource).to receive(:members).and_return(["all", "your", "base"]) + allow(@new_resource).to receive(:members).and_return(%w(all your base)) allow(@current_resource).to receive(:members).and_return([]) end diff --git a/spec/unit/provider/group/usermod_spec.rb b/spec/unit/provider/group/usermod_spec.rb index 1a718b1d40..5ab5d2bce0 100644 --- a/spec/unit/provider/group/usermod_spec.rb +++ b/spec/unit/provider/group/usermod_spec.rb @@ -24,7 +24,7 @@ describe Chef::Provider::Group::Usermod do @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) @new_resource = Chef::Resource::Group.new("wheel") - @new_resource.members [ "all", "your", "base" ] + @new_resource.members %w(all your base) @new_resource.excluded_members [ ] @provider = Chef::Provider::Group::Usermod.new(@new_resource, @run_context) allow(@provider).to receive(:run_command) @@ -56,7 +56,7 @@ describe Chef::Provider::Group::Usermod do } before do - allow(@new_resource).to receive(:members).and_return(["all", "your", "base"]) + allow(@new_resource).to receive(:members).and_return(%w(all your base)) allow(File).to receive(:exists?).and_return(true) end diff --git a/spec/unit/provider/group/windows_spec.rb b/spec/unit/provider/group/windows_spec.rb index c331e2b021..7ff58848fa 100644 --- a/spec/unit/provider/group/windows_spec.rb +++ b/spec/unit/provider/group/windows_spec.rb @@ -50,7 +50,7 @@ describe Chef::Provider::Group::Windows do before do @new_resource.members([ "us" ]) @current_resource = Chef::Resource::Group.new("staff") - @current_resource.members [ "all", "your", "base" ] + @current_resource.members %w(all your base) allow(Chef::Util::Windows::NetGroup).to receive(:new).and_return(@net_group) allow(@net_group).to receive(:local_add_members) diff --git a/spec/unit/provider/group_spec.rb b/spec/unit/provider/group_spec.rb index d41b0689ee..ed0537adfe 100644 --- a/spec/unit/provider/group_spec.rb +++ b/spec/unit/provider/group_spec.rb @@ -39,7 +39,7 @@ describe Chef::Provider::User do @pw_group = double("Struct::Group", :name => "wheel", :gid => 20, - :mem => [ "root", "aj" ], + :mem => %w(root aj), ) allow(Etc).to receive(:getgrnam).with("wheel").and_return(@pw_group) end diff --git a/spec/unit/provider/mount/mount_spec.rb b/spec/unit/provider/mount/mount_spec.rb index 50ed356049..4e636fba5f 100644 --- a/spec/unit/provider/mount/mount_spec.rb +++ b/spec/unit/provider/mount/mount_spec.rb @@ -107,7 +107,7 @@ describe Chef::Provider::Mount::Mount do expect { @provider.load_current_resource();@provider.mountable? }.to raise_error(Chef::Exceptions::Mount) end - [ "tmpfs", "fuse", "cgroup" ].each do |fstype| + %w(tmpfs fuse cgroup).each do |fstype| it "does not expect the device to exist for #{fstype}" do @new_resource.fstype(fstype) @new_resource.device("whatever") diff --git a/spec/unit/provider/mount/solaris_spec.rb b/spec/unit/provider/mount/solaris_spec.rb index a6d0620df6..3d5ce53619 100644 --- a/spec/unit/provider/mount/solaris_spec.rb +++ b/spec/unit/provider/mount/solaris_spec.rb @@ -316,7 +316,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do end it "should set the options field on the current_resource" do - expect(provider.current_resource.options).to eql(["rw", "soft"]) + expect(provider.current_resource.options).to eql(%w(rw soft)) end it "should set the pass field on the current_resource" do diff --git a/spec/unit/provider/package/chocolatey_spec.rb b/spec/unit/provider/package/chocolatey_spec.rb index aeb420fa7a..34cfec2c05 100644 --- a/spec/unit/provider/package/chocolatey_spec.rb +++ b/spec/unit/provider/package/chocolatey_spec.rb @@ -95,26 +95,26 @@ munin-node|1.6.1.20130823 end it "should set the candidate_version correctly when there are two packages to install" do - allow_remote_list(["ConEmu", "chocolatey"]) - new_resource.package_name(["ConEmu", "chocolatey"]) + allow_remote_list(%w(ConEmu chocolatey)) + new_resource.package_name(%w(ConEmu chocolatey)) expect(provider.candidate_version).to eql(["15.10.25.1", "0.9.9.11"]) end it "should set the candidate_version correctly when only the first is installable" do - allow_remote_list(["ConEmu", "vim"]) - new_resource.package_name(["ConEmu", "vim"]) + allow_remote_list(%w(ConEmu vim)) + new_resource.package_name(%w(ConEmu vim)) expect(provider.candidate_version).to eql(["15.10.25.1", nil]) end it "should set the candidate_version correctly when only the last is installable" do - allow_remote_list(["vim", "chocolatey"]) - new_resource.package_name(["vim", "chocolatey"]) + allow_remote_list(%w(vim chocolatey)) + new_resource.package_name(%w(vim chocolatey)) expect(provider.candidate_version).to eql([nil, "0.9.9.11"]) end it "should set the candidate_version correctly when neither are is installable" do - allow_remote_list(["vim", "ruby"]) - new_resource.package_name(["vim", "ruby"]) + allow_remote_list(%w(vim ruby)) + new_resource.package_name(%w(vim ruby)) expect(provider.candidate_version).to eql([nil, nil]) end end @@ -156,25 +156,25 @@ munin-node|1.6.1.20130823 end it "should set the current_resource.version when there are two packages that are installed" do - new_resource.package_name(["ConEmu", "chocolatey"]) + new_resource.package_name(%w(ConEmu chocolatey)) provider.load_current_resource expect(provider.current_resource.version).to eql(["15.10.25.0", "0.9.9.11"]) end it "should set the current_resource.version correctly when only the first is installed" do - new_resource.package_name(["ConEmu", "git"]) + new_resource.package_name(%w(ConEmu git)) provider.load_current_resource expect(provider.current_resource.version).to eql(["15.10.25.0", nil]) end it "should set the current_resource.version correctly when only the last is installed" do - new_resource.package_name(["git", "chocolatey"]) + new_resource.package_name(%w(git chocolatey)) provider.load_current_resource expect(provider.current_resource.version).to eql([nil, "0.9.9.11"]) end it "should set the current_resource.version correctly when none are installed" do - new_resource.package_name(["git", "vim"]) + new_resource.package_name(%w(git vim)) provider.load_current_resource expect(provider.current_resource.version).to eql([nil, nil]) end @@ -233,8 +233,8 @@ munin-node|1.6.1.20130823 # chocolatey will be pruned by the superclass out of the args to install_package and we # implicitly test that we correctly pick up new_resource.version[1] instead of # new_version.resource[0] - allow_remote_list(["chocolatey", "ConEmu"]) - new_resource.package_name(["chocolatey", "ConEmu"]) + allow_remote_list(%w(chocolatey ConEmu)) + new_resource.package_name(%w(chocolatey ConEmu)) new_resource.version([nil, "15.10.25.1"]) provider.load_current_resource expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -version 15.10.25.1 conemu", { :timeout => timeout }).and_return(double) @@ -253,8 +253,8 @@ munin-node|1.6.1.20130823 end it "should split up commands when given two packages, one with a version pin" do - allow_remote_list(["ConEmu", "git"]) - new_resource.package_name(["ConEmu", "git"]) + allow_remote_list(%w(ConEmu git)) + new_resource.package_name(%w(ConEmu git)) new_resource.version(["15.10.25.1", nil]) provider.load_current_resource expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -version 15.10.25.1 conemu", { :timeout => timeout }).and_return(double) @@ -371,8 +371,8 @@ munin-node|1.6.1.20130823 end it "upgrading multiple packages uses a single command" do - allow_remote_list(["conemu", "git"]) - new_resource.package_name(["conemu", "git"]) + allow_remote_list(%w(conemu git)) + new_resource.package_name(%w(conemu git)) expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y conemu git", { :timeout => timeout }).and_return(double) provider.run_action(:upgrade) expect(new_resource).to be_updated_by_last_action @@ -441,8 +441,8 @@ munin-node|1.6.1.20130823 it "removes a single package when its the only one installed" do pending "this is a bug in the superclass" - allow_remote_list(["git", "conemu"]) - new_resource.package_name(["git", "conemu"]) + allow_remote_list(%w(git conemu)) + new_resource.package_name(%w(git conemu)) provider.load_current_resource expect(provider).to receive(:shell_out!).with("#{choco_exe} uninstall -y conemu", { :timeout => timeout }).and_return(double) provider.run_action(:remove) diff --git a/spec/unit/provider/package/yum_spec.rb b/spec/unit/provider/package/yum_spec.rb index 98fe9551a6..2d4bcc6bef 100644 --- a/spec/unit/provider/package/yum_spec.rb +++ b/spec/unit/provider/package/yum_spec.rb @@ -987,7 +987,7 @@ describe Chef::Provider::Package::Yum::RPMUtils do end it "tests isalnum good input" do - [ "a", "z", "A", "Z", "0", "9" ].each do |t| + %w(a z A Z 0 9).each do |t| expect(@rpmutils.isalnum(t)).to eq(true) end end @@ -999,7 +999,7 @@ describe Chef::Provider::Package::Yum::RPMUtils do end it "tests isalpha good input" do - [ "a", "z", "A", "Z" ].each do |t| + %w(a z A Z).each do |t| expect(@rpmutils.isalpha(t)).to eq(true) end end @@ -1011,7 +1011,7 @@ describe Chef::Provider::Package::Yum::RPMUtils do end it "tests isdigit good input" do - [ "0", "9" ].each do |t| + %w(0 9).each do |t| expect(@rpmutils.isdigit(t)).to eq(true) end end @@ -1119,8 +1119,8 @@ describe Chef::Provider::Package::Yum::RPMVersion do "3.3-15.el5" ], [ "alpha9.8", "beta9.8" ], - [ "14jpp", - "15jpp" ], + %w(14jpp +15jpp), [ "0.9.0-0.6", "0.9.0-0.7" ], [ "0:1.9", @@ -1297,8 +1297,8 @@ describe Chef::Provider::Package::Yum::RPMPackage do "B-test" ], [ "Aa-test", "aA-test" ], - [ "1test", - "2test" ], + %w(1test +2test), ].each do |smaller, larger| sm = Chef::Provider::Package::Yum::RPMPackage.new(smaller, "0:0.0.1-1", "x86_64", []) lg = Chef::Provider::Package::Yum::RPMPackage.new(larger, "0:0.0.1-1", "x86_64", []) @@ -1310,12 +1310,12 @@ describe Chef::Provider::Package::Yum::RPMPackage do it "should sort alphabetically based on package arch" do [ - [ "i386", - "x86_64" ], - [ "i386", - "noarch" ], - [ "noarch", - "x86_64" ], + %w(i386 +x86_64), + %w(i386 +noarch), + %w(noarch +x86_64), ].each do |smaller, larger| sm = Chef::Provider::Package::Yum::RPMPackage.new("test-package", "0:0.0.1-1", smaller, []) lg = Chef::Provider::Package::Yum::RPMPackage.new("test-package", "0:0.0.1-1", larger, []) @@ -2113,7 +2113,7 @@ 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(%w(cups vim)) @status = double("Status", :exitstatus => 0) @yum_cache = double( "Chef::Provider::Yum::YumCache", @@ -2142,7 +2142,7 @@ describe "Chef::Provider::Package::Yum - Multi" do 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(%w(cups vim)) end it "should set the installed version to nil on the current resource if no installed package" do @@ -2196,9 +2196,9 @@ describe "Chef::Provider::Package::Yum - Multi" do expect(Chef::Log).to receive(:debug).exactly(1).times.with(%r{candidate version: \["1.2.4-11.18.el5_2.3", "24.4"\]}) expect(Chef::Log).to receive(:debug).at_least(2).times.with(%r{checking yum info}) @provider.load_current_resource - expect(@provider.new_resource.package_name).to eq(["cups", "emacs"]) + expect(@provider.new_resource.package_name).to eq(%w(cups emacs)) expect(@provider.new_resource.version).to eq(["1.2.4-11.18.el5_2.3", "24.4"]) - expect(@provider.send(:package_name_array)).to eq(["cups", "emacs"]) + expect(@provider.send(:package_name_array)).to eq(%w(cups emacs)) expect(@provider.send(:new_version_array)).to eq(["1.2.4-11.18.el5_2.3", "24.4"]) end end @@ -2213,7 +2213,7 @@ describe "Chef::Provider::Package::Yum - Multi" do 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(%w(cups vim), ["1.2.4-11.19.el5", "1.0"]) end it "should run yum install with the package name, version and arch" do @@ -2223,7 +2223,7 @@ describe "Chef::Provider::Package::Yum - Multi" do expect(@provider).to receive(:yum_command).with( "-d0 -e0 -y install cups-1.2.4-11.19.el5.i386 vim-1.0.i386" ) - @provider.install_package(["cups", "vim"], ["1.2.4-11.19.el5", "1.0"]) + @provider.install_package(%w(cups vim), ["1.2.4-11.19.el5", "1.0"]) end it "installs the package with the options given in the resource" do @@ -2235,7 +2235,7 @@ describe "Chef::Provider::Package::Yum - Multi" do "-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(%w(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 @@ -2260,7 +2260,7 @@ describe "Chef::Provider::Package::Yum - Multi" do 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(%w(cups vim), ["1.2.4-11.19.el5", "1.0"]) end end diff --git a/spec/unit/provider/package/zypper_spec.rb b/spec/unit/provider/package/zypper_spec.rb index c998c93d6e..b64ef5ea93 100644 --- a/spec/unit/provider/package/zypper_spec.rb +++ b/spec/unit/provider/package/zypper_spec.rb @@ -254,7 +254,7 @@ describe Chef::Provider::Package::Zypper do shell_out_expectation!( "zypper --non-interactive --no-gpg-checks install " + "--auto-agree-with-licenses emacs=1.0 vim=2.0" ) - provider.install_package(["emacs", "vim"], ["1.0", "2.0"]) + provider.install_package(%w(emacs vim), ["1.0", "2.0"]) end it "should remove an array of package names and versions" do @@ -262,7 +262,7 @@ describe Chef::Provider::Package::Zypper do shell_out_expectation!( "zypper --non-interactive --no-gpg-checks remove emacs=1.0 vim=2.0" ) - provider.remove_package(["emacs", "vim"], ["1.0", "2.0"]) + provider.remove_package(%w(emacs vim), ["1.0", "2.0"]) end end end diff --git a/spec/unit/provider/package_spec.rb b/spec/unit/provider/package_spec.rb index 50016c623d..b2287ed8ce 100644 --- a/spec/unit/provider/package_spec.rb +++ b/spec/unit/provider/package_spec.rb @@ -44,7 +44,7 @@ describe Chef::Provider::Package do end it "raises a Chef::Exceptions::InvalidResourceSpecification if both multipackage and source are provided" do - new_resource.package_name(["a", "b"]) + new_resource.package_name(%w(a b)) new_resource.source("foo") expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::InvalidResourceSpecification) end @@ -563,8 +563,8 @@ describe "Chef::Provider::Package - Multi" do let(:node) { Chef::Node.new } let(:events) { Chef::EventDispatch::Dispatcher.new } let(:run_context) { Chef::RunContext.new(node, {}, events) } - let(:new_resource) { Chef::Resource::Package.new(["emacs", "vi"]) } - let(:current_resource) { Chef::Resource::Package.new(["emacs", "vi"]) } + let(:new_resource) { Chef::Resource::Package.new(%w(emacs vi)) } + let(:current_resource) { Chef::Resource::Package.new(%w(emacs vi)) } let(:candidate_version) { [ "1.0", "6.2" ] } let(:provider) do provider = Chef::Provider::Package.new(new_resource, run_context) @@ -581,7 +581,7 @@ describe "Chef::Provider::Package - Multi" do it "installs the candidate versions when none are installed" do expect(provider).to receive(:install_package).with( - ["emacs", "vi"], + %w(emacs vi), ["1.0", "6.2"], ).and_return(true) provider.run_action(:install) @@ -731,7 +731,7 @@ describe "Chef::Provider::Package - Multi" do it "should remove the packages if all are installed" do expect(provider).to be_removing_package - expect(provider).to receive(:remove_package).with(["emacs", "vi"], nil) + expect(provider).to receive(:remove_package).with(%w(emacs vi), nil) provider.run_action(:remove) expect(new_resource).to be_updated expect(new_resource).to be_updated_by_last_action @@ -740,7 +740,7 @@ describe "Chef::Provider::Package - Multi" do it "should remove the packages if some are installed" do current_resource.version ["1.0", nil] expect(provider).to be_removing_package - expect(provider).to receive(:remove_package).with(["emacs", "vi"], nil) + expect(provider).to receive(:remove_package).with(%w(emacs vi), nil) provider.run_action(:remove) expect(new_resource).to be_updated expect(new_resource).to be_updated_by_last_action @@ -749,7 +749,7 @@ describe "Chef::Provider::Package - Multi" do it "should remove the packages at a specific version if they are installed at that version" do new_resource.version ["1.0", "6.2"] expect(provider).to be_removing_package - expect(provider).to receive(:remove_package).with(["emacs", "vi"], ["1.0", "6.2"]) + expect(provider).to receive(:remove_package).with(%w(emacs vi), ["1.0", "6.2"]) provider.run_action(:remove) expect(new_resource).to be_updated_by_last_action end @@ -757,7 +757,7 @@ describe "Chef::Provider::Package - Multi" do it "should remove the packages at a specific version any are is installed at that version" do new_resource.version ["0.5", "6.2"] expect(provider).to be_removing_package - expect(provider).to receive(:remove_package).with(["emacs", "vi"], ["0.5", "6.2"]) + expect(provider).to receive(:remove_package).with(%w(emacs vi), ["0.5", "6.2"]) provider.run_action(:remove) expect(new_resource).to be_updated_by_last_action end @@ -787,7 +787,7 @@ describe "Chef::Provider::Package - Multi" do it "should purge the packages if all are installed" do expect(provider).to be_removing_package - expect(provider).to receive(:purge_package).with(["emacs", "vi"], nil) + expect(provider).to receive(:purge_package).with(%w(emacs vi), nil) provider.run_action(:purge) expect(new_resource).to be_updated expect(new_resource).to be_updated_by_last_action @@ -796,7 +796,7 @@ describe "Chef::Provider::Package - Multi" do it "should purge the packages if some are installed" do current_resource.version ["1.0", nil] expect(provider).to be_removing_package - expect(provider).to receive(:purge_package).with(["emacs", "vi"], nil) + expect(provider).to receive(:purge_package).with(%w(emacs vi), nil) provider.run_action(:purge) expect(new_resource).to be_updated expect(new_resource).to be_updated_by_last_action @@ -805,7 +805,7 @@ describe "Chef::Provider::Package - Multi" do it "should purge the packages at a specific version if they are installed at that version" do new_resource.version ["1.0", "6.2"] expect(provider).to be_removing_package - expect(provider).to receive(:purge_package).with(["emacs", "vi"], ["1.0", "6.2"]) + expect(provider).to receive(:purge_package).with(%w(emacs vi), ["1.0", "6.2"]) provider.run_action(:purge) expect(new_resource).to be_updated_by_last_action end @@ -813,7 +813,7 @@ describe "Chef::Provider::Package - Multi" do it "should purge the packages at a specific version any are is installed at that version" do new_resource.version ["0.5", "6.2"] expect(provider).to be_removing_package - expect(provider).to receive(:purge_package).with(["emacs", "vi"], ["0.5", "6.2"]) + expect(provider).to receive(:purge_package).with(%w(emacs vi), ["0.5", "6.2"]) provider.run_action(:purge) expect(new_resource).to be_updated_by_last_action end diff --git a/spec/unit/provider/service/arch_service_spec.rb b/spec/unit/provider/service/arch_service_spec.rb index 47f874cc0e..d95b020357 100644 --- a/spec/unit/provider/service/arch_service_spec.rb +++ b/spec/unit/provider/service/arch_service_spec.rb @@ -180,7 +180,7 @@ RUNNING_PS it "should add chef to DAEMONS array" do allow(::File).to receive(:read).with("/etc/rc.conf").and_return("DAEMONS=(network)") - expect(@provider).to receive(:update_daemons).with(["network", "chef"]) + expect(@provider).to receive(:update_daemons).with(%w(network chef)) @provider.enable_service() end end diff --git a/spec/unit/provider/service/freebsd_service_spec.rb b/spec/unit/provider/service/freebsd_service_spec.rb index e64aa517e2..224ce3b026 100644 --- a/spec/unit/provider/service/freebsd_service_spec.rb +++ b/spec/unit/provider/service/freebsd_service_spec.rb @@ -495,7 +495,7 @@ EOF allow(provider).to receive(:service_enable_variable_name).and_return("#{new_resource.service_name}_enable") end - [ "start", "reload", "restart", "enable" ].each do |action| + %w(start reload restart enable).each do |action| it "should raise an exception when the action is #{action}" do provider.define_resource_requirements provider.action = action @@ -503,7 +503,7 @@ EOF end end - [ "stop", "disable" ].each do |action| + %w(stop disable).each do |action| it "should not raise an error when the action is #{action}" do provider.define_resource_requirements provider.action = action @@ -518,7 +518,7 @@ EOF allow(provider).to receive(:service_enable_variable_name).and_return(nil) end - [ "start", "reload", "restart", "enable" ].each do |action| + %w(start reload restart enable).each do |action| it "should raise an exception when the action is #{action}" do provider.action = action provider.define_resource_requirements @@ -526,7 +526,7 @@ EOF end end - [ "stop", "disable" ].each do |action| + %w(stop disable).each do |action| it "should not raise an error when the action is #{action}" do provider.action = action provider.define_resource_requirements @@ -558,7 +558,7 @@ EOF it "should enable the service if it is not enabled and not already specified in the rc.conf file" do allow(current_resource).to receive(:enabled).and_return(false) - expect(provider).to receive(:read_rc_conf).and_return([ "foo", "bar" ]) + expect(provider).to receive(:read_rc_conf).and_return(%w(foo bar)) expect(provider).to receive(:write_rc_conf).with(["foo", "bar", "#{new_resource.service_name}_enable=\"YES\""]) provider.enable_service() end diff --git a/spec/unit/provider/service/macosx_spec.rb b/spec/unit/provider/service/macosx_spec.rb index 29ebf2da11..0828425523 100644 --- a/spec/unit/provider/service/macosx_spec.rb +++ b/spec/unit/provider/service/macosx_spec.rb @@ -58,7 +58,7 @@ describe Chef::Provider::Service::Macosx do </plist> XML - ["Daemon", "Agent"].each do |service_type| + %w(Daemon Agent).each do |service_type| ["redis-server", "io.redis.redis-server"].each do |service_name| ["10.9", "10.10", "10.11"].each do |platform_version| let(:plist) { "/Library/LaunchDaemons/io.redis.redis-server.plist" } diff --git a/spec/unit/provider/service/openbsd_service_spec.rb b/spec/unit/provider/service/openbsd_service_spec.rb index 7b64214e65..5f5dc80b85 100644 --- a/spec/unit/provider/service/openbsd_service_spec.rb +++ b/spec/unit/provider/service/openbsd_service_spec.rb @@ -338,7 +338,7 @@ describe Chef::Provider::Service::Openbsd do allow(provider).to receive(:builtin_service_enable_variable_name).and_return("#{new_resource.service_name}_enable") end - [ "start", "reload", "restart", "enable" ].each do |action| + %w(start reload restart enable).each do |action| it "should raise an exception when the action is #{action}" do provider.define_resource_requirements provider.action = action @@ -346,7 +346,7 @@ describe Chef::Provider::Service::Openbsd do end end - [ "stop", "disable" ].each do |action| + %w(stop disable).each do |action| it "should not raise an error when the action is #{action}" do provider.define_resource_requirements provider.action = action @@ -360,7 +360,7 @@ describe Chef::Provider::Service::Openbsd do allow(provider).to receive(:builtin_service_enable_variable_name).and_return(nil) end - [ "start", "reload", "restart", "enable" ].each do |action| + %w(start reload restart enable).each do |action| it "should raise an exception when the action is #{action}" do provider.action = action provider.define_resource_requirements @@ -368,7 +368,7 @@ describe Chef::Provider::Service::Openbsd do end end - [ "stop", "disable" ].each do |action| + %w(stop disable).each do |action| it "should not raise an error when the action is #{action}" do provider.action = action provider.define_resource_requirements diff --git a/spec/unit/provider/service/redhat_spec.rb b/spec/unit/provider/service/redhat_spec.rb index 5d03c688fc..7023e6848a 100644 --- a/spec/unit/provider/service/redhat_spec.rb +++ b/spec/unit/provider/service/redhat_spec.rb @@ -150,14 +150,14 @@ describe "Chef::Provider::Service::Redhat" do @provider.define_resource_requirements end - [ "start", "reload", "restart", "enable" ].each do |action| + %w(start reload restart enable).each do |action| it "should raise an error when the action is #{action}" do @provider.action = action expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service) end end - [ "stop", "disable" ].each do |action| + %w(stop disable).each do |action| it "should not raise an error when the action is #{action}" do @provider.action = action expect { @provider.process_resource_requirements }.not_to raise_error diff --git a/spec/unit/provider/template/content_spec.rb b/spec/unit/provider/template/content_spec.rb index 4f7b4c256c..0f936c8f11 100644 --- a/spec/unit/provider/template/content_spec.rb +++ b/spec/unit/provider/template/content_spec.rb @@ -91,7 +91,7 @@ describe Chef::Provider::Template::Content do it "returns a tempfile in the tempdir when :file_staging_uses_destdir is not set" do Chef::Config[:file_staging_uses_destdir] = false - expect(content.tempfile.path.start_with?(Dir::tmpdir)).to be true + expect(content.tempfile.path.start_with?(Dir.tmpdir)).to be true expect(canonicalize_path(content.tempfile.path).start_with?(enclosing_directory)).to be false end @@ -107,7 +107,7 @@ describe Chef::Provider::Template::Content do it "returns a tempfile in the tempdir when :file_deployment_uses_destdir is set to :auto" do Chef::Config[:file_staging_uses_destdir] = :auto - expect(content.tempfile.path.start_with?(Dir::tmpdir)).to be true + expect(content.tempfile.path.start_with?(Dir.tmpdir)).to be true expect(canonicalize_path(content.tempfile.path).start_with?(enclosing_directory)).to be false end @@ -117,7 +117,7 @@ describe Chef::Provider::Template::Content do end it "returns a tempfile in the tempdir when :file_desployment_uses_destdir is not set" do - expect(content.tempfile.path.start_with?(Dir::tmpdir)).to be true + expect(content.tempfile.path.start_with?(Dir.tmpdir)).to be true expect(canonicalize_path(content.tempfile.path).start_with?(enclosing_directory)).to be false end end diff --git a/spec/unit/provider/user_spec.rb b/spec/unit/provider/user_spec.rb index 0794ce0328..6e5a469112 100644 --- a/spec/unit/provider/user_spec.rb +++ b/spec/unit/provider/user_spec.rb @@ -192,13 +192,13 @@ describe Chef::Provider::User do describe "compare_user" do let(:mapping) { { - "username" => ["adam", "Adam"], + "username" => %w(adam Adam), "comment" => ["Adam Jacob", "adam jacob"], "uid" => [1000, 1001], "gid" => [1000, 1001], "home" => ["/home/adam", "/Users/adam"], "shell" => ["/usr/bin/zsh", "/bin/bash"], - "password" => ["abcd", "12345"], + "password" => %w(abcd 12345), } } |