diff options
author | Tim Smith <tsmith84@gmail.com> | 2021-12-26 20:32:49 -0800 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2021-12-26 20:32:49 -0800 |
commit | 0cefcaa319b0d2f07241b78bf7d6f06de03d07ef (patch) | |
tree | 5c1061b328d1769e8ad1c995db78a5521736c33e | |
parent | 50a0001bae754c66feb69c84b64cb305a03a34d2 (diff) | |
download | chef-0cefcaa319b0d2f07241b78bf7d6f06de03d07ef.tar.gz |
Resolve Performance/StringIdentifierArgument warningsPerformance_StringIdentifierArgument
Inernally it's all a symbol so skip the conversion
Signed-off-by: Tim Smith <tsmith@chef.io>
22 files changed, 63 insertions, 63 deletions
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb index 3eb8c8475c..9b5f5a849a 100644 --- a/chef-config/lib/chef-config/config.rb +++ b/chef-config/lib/chef-config/config.rb @@ -1287,10 +1287,10 @@ module ChefConfig require "digest/md5" unless defined?(Digest::MD5) # Remove pre-existing constants if they do exist to reduce the # amount of log spam and warnings. - Digest.send(:remove_const, "SHA1") if Digest.const_defined?("SHA1") - Digest.const_set("SHA1", OpenSSL::Digest::SHA1) - OpenSSL::Digest.send(:remove_const, "MD5") if OpenSSL::Digest.const_defined?("MD5") - OpenSSL::Digest.const_set("MD5", Digest::MD5) + Digest.send(:remove_const, "SHA1") if Digest.const_defined?(:SHA1) + Digest.const_set(:SHA1, OpenSSL::Digest::SHA1) + OpenSSL::Digest.send(:remove_const, "MD5") if OpenSSL::Digest.const_defined?(:MD5) + OpenSSL::Digest.const_set(:MD5, Digest::MD5) ChefConfig.logger.debug "FIPS mode is enabled." end end diff --git a/knife/spec/support/platform_helpers.rb b/knife/spec/support/platform_helpers.rb index a3fb95e069..4d3acbcb33 100644 --- a/knife/spec/support/platform_helpers.rb +++ b/knife/spec/support/platform_helpers.rb @@ -168,7 +168,7 @@ def wpar? end def supports_cloexec? - Fcntl.const_defined?("F_SETFD") && Fcntl.const_defined?("FD_CLOEXEC") + Fcntl.const_defined?(:F_SETFD) && Fcntl.const_defined?(:FD_CLOEXEC) end def selinux_enabled? diff --git a/lib/chef/provider/package.rb b/lib/chef/provider/package.rb index daf46c502e..a49a97ea7e 100644 --- a/lib/chef/provider/package.rb +++ b/lib/chef/provider/package.rb @@ -658,7 +658,7 @@ class Chef end def allow_downgrade - if new_resource.respond_to?("allow_downgrade") + if new_resource.respond_to?(:allow_downgrade) new_resource.allow_downgrade else true diff --git a/lib/chef/resource_reporter.rb b/lib/chef/resource_reporter.rb index 242a6e9f0f..16d90baf4f 100644 --- a/lib/chef/resource_reporter.rb +++ b/lib/chef/resource_reporter.rb @@ -34,7 +34,7 @@ class Chef as_hash["after"] = new_resource.state_for_resource_reporter as_hash["before"] = current_resource ? current_resource.state_for_resource_reporter : {} as_hash["duration"] = ( action_record.elapsed_time * 1000 ).to_i.to_s - as_hash["delta"] = new_resource.diff if new_resource.respond_to?("diff") + as_hash["delta"] = new_resource.diff if new_resource.respond_to?(:diff) as_hash["delta"] = "" if as_hash["delta"].nil? # TODO: rename as "action" diff --git a/lib/chef/run_lock.rb b/lib/chef/run_lock.rb index 8382983ca0..b70a936aab 100644 --- a/lib/chef/run_lock.rb +++ b/lib/chef/run_lock.rb @@ -144,7 +144,7 @@ class Chef # If we support FD_CLOEXEC, then use it. # NB: ruby-2.0.0-p195 sets FD_CLOEXEC by default, but not # ruby-1.8.7/1.9.3 - if Fcntl.const_defined?("F_SETFD") && Fcntl.const_defined?("FD_CLOEXEC") + if Fcntl.const_defined?(:F_SETFD) && Fcntl.const_defined?(:FD_CLOEXEC) runlock.fcntl(Fcntl::F_SETFD, runlock.fcntl(Fcntl::F_GETFD, 0) | Fcntl::FD_CLOEXEC) end # Flock will return 0 if it can acquire the lock otherwise it diff --git a/spec/support/platform_helpers.rb b/spec/support/platform_helpers.rb index 1538a4eb34..430d9b055f 100644 --- a/spec/support/platform_helpers.rb +++ b/spec/support/platform_helpers.rb @@ -172,7 +172,7 @@ def wpar? end def supports_cloexec? - Fcntl.const_defined?("F_SETFD") && Fcntl.const_defined?("FD_CLOEXEC") + Fcntl.const_defined?(:F_SETFD) && Fcntl.const_defined?(:FD_CLOEXEC) end def selinux_enabled? diff --git a/spec/support/shared/functional/file_resource.rb b/spec/support/shared/functional/file_resource.rb index 1385d3dc30..70379263b6 100644 --- a/spec/support/shared/functional/file_resource.rb +++ b/spec/support/shared/functional/file_resource.rb @@ -157,7 +157,7 @@ shared_examples_for "a file with the wrong content" do context "when running :create action" do let(:provider) { resource.provider_for_action(:create) } - let(:reporter_messages) { provider.instance_variable_get("@converge_actions").actions[0][0] } + let(:reporter_messages) { provider.instance_variable_get(:@converge_actions).actions[0][0] } before do provider.run_action diff --git a/spec/support/shared/unit/provider/useradd_based_user_provider.rb b/spec/support/shared/unit/provider/useradd_based_user_provider.rb index 1f9f87866c..7e7a8ae857 100644 --- a/spec/support/shared/unit/provider/useradd_based_user_provider.rb +++ b/spec/support/shared/unit/provider/useradd_based_user_provider.rb @@ -169,7 +169,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option before do provider.new_resource.system true # there is no public API to set attribute's value to nil - provider.new_resource.instance_variable_set("@home", nil) + provider.new_resource.instance_variable_set(:@home, nil) end it "should not include -m or -d in the command options" do diff --git a/spec/unit/dsl/registry_helper_spec.rb b/spec/unit/dsl/registry_helper_spec.rb index 5ef8caa053..09dfe24226 100644 --- a/spec/unit/dsl/registry_helper_spec.rb +++ b/spec/unit/dsl/registry_helper_spec.rb @@ -31,22 +31,22 @@ describe Chef::Resource::RegistryKey do context "tests registry dsl" do it "resource can access registry_helper method registry_key_exists" do - expect(@resource.respond_to?("registry_key_exists?")).to eq(true) + expect(@resource.respond_to?(:registry_key_exists?)).to eq(true) end it "resource can access registry_helper method registry_get_values" do - expect(@resource.respond_to?("registry_get_values")).to eq(true) + expect(@resource.respond_to?(:registry_get_values)).to eq(true) end it "resource can access registry_helper method registry_has_subkey" do - expect(@resource.respond_to?("registry_has_subkeys?")).to eq(true) + expect(@resource.respond_to?(:registry_has_subkeys?)).to eq(true) end it "resource can access registry_helper method registry_get_subkeys" do - expect(@resource.respond_to?("registry_get_subkeys")).to eq(true) + expect(@resource.respond_to?(:registry_get_subkeys)).to eq(true) end it "resource can access registry_helper method registry_value_exists" do - expect(@resource.respond_to?("registry_value_exists?")).to eq(true) + expect(@resource.respond_to?(:registry_value_exists?)).to eq(true) end it "resource can access registry_helper method data_value_exists" do - expect(@resource.respond_to?("registry_data_exists?")).to eq(true) + expect(@resource.respond_to?(:registry_data_exists?)).to eq(true) end end end diff --git a/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb b/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb index 0760bcee1d..a5ec146fc1 100644 --- a/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +++ b/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb @@ -94,7 +94,7 @@ describe Chef::GuardInterpreter::ResourceGuardInterpreter do describe "script command opts switch" do let(:guard_interpreter) { Chef::GuardInterpreter::ResourceGuardInterpreter.new(parent_resource, "exit 0", {}) } - let(:resource) { guard_interpreter.instance_variable_get("@resource") } + let(:resource) { guard_interpreter.instance_variable_get(:@resource) } context "resource is a Script" do context "and guard_interpreter is a :script" do diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb index 5767e3987b..e93640ab86 100644 --- a/spec/unit/lwrp_spec.rb +++ b/spec/unit/lwrp_spec.rb @@ -54,7 +54,7 @@ describe "LWRP" do end it "should not skip loading a resource when there's a top level symbol of the same name" do - Object.const_set("LwrpFoo", Class.new) + Object.const_set(:LwrpFoo, Class.new) file = File.expand_path( "lwrp/resources/foo.rb", CHEF_SPEC_DATA) expect(Chef::Log).not_to receive(:info).with(/Skipping/) expect(Chef::Log).not_to receive(:trace).with(/anymore/) @@ -63,7 +63,7 @@ describe "LWRP" do end it "should not skip loading a provider when there's a top level symbol of the same name" do - Object.const_set("LwrpBuckPasser", Class.new) + Object.const_set(:LwrpBuckPasser, Class.new) file = File.expand_path( "lwrp/providers/buck_passer.rb", CHEF_SPEC_DATA) expect(Chef::Log).not_to receive(:info).with(/Skipping/) expect(Chef::Log).not_to receive(:trace).with(/anymore/) diff --git a/spec/unit/provider/dsc_script_spec.rb b/spec/unit/provider/dsc_script_spec.rb index d59b6f2480..41544a32a2 100644 --- a/spec/unit/provider/dsc_script_spec.rb +++ b/spec/unit/provider/dsc_script_spec.rb @@ -39,21 +39,21 @@ describe Chef::Provider::DscScript do it "describes the resource as converged if there were 0 DSC resources" do allow(provider).to receive(:run_configuration).with(:test).and_return([]) provider.load_current_resource - expect(provider.instance_variable_get("@resource_converged")).to be_truthy + expect(provider.instance_variable_get(:@resource_converged)).to be_truthy end it "describes the resource as not converged if there is 1 DSC resources that is converged" do dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resource", false, ["nothing will change something"]) allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info]) provider.load_current_resource - expect(provider.instance_variable_get("@resource_converged")).to be_truthy + expect(provider.instance_variable_get(:@resource_converged)).to be_truthy end it "describes the resource as not converged if there is 1 DSC resources that is not converged" do dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resource", true, ["will change something"]) allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info]) provider.load_current_resource - expect(provider.instance_variable_get("@resource_converged")).to be_falsey + expect(provider.instance_variable_get(:@resource_converged)).to be_falsey end it "describes the resource as not converged if there are any DSC resources that are not converged" do @@ -62,7 +62,7 @@ describe Chef::Provider::DscScript do allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info1, dsc_resource_info2]) provider.load_current_resource - expect(provider.instance_variable_get("@resource_converged")).to be_falsey + expect(provider.instance_variable_get(:@resource_converged)).to be_falsey end it "describes the resource as converged if all DSC resources that are converged" do @@ -71,7 +71,7 @@ describe Chef::Provider::DscScript do allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info1, dsc_resource_info2]) provider.load_current_resource - expect(provider.instance_variable_get("@resource_converged")).to be_truthy + expect(provider.instance_variable_get(:@resource_converged)).to be_truthy end end @@ -126,19 +126,19 @@ describe Chef::Provider::DscScript do describe "#generate_description" do it "removes the resource name from the beginning of any log line from the LCM" do dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resourcename", true, ["resourcename doing something", "lastline"]) - provider.instance_variable_set("@dsc_resources_info", [dsc_resource_info]) + provider.instance_variable_set(:@dsc_resources_info, [dsc_resource_info]) expect(provider.send(:generate_description)[1]).to match(/converge DSC resource resourcename by doing something/) end it "ignores the last line" do dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resourcename", true, ["resourcename doing something", "lastline"]) - provider.instance_variable_set("@dsc_resources_info", [dsc_resource_info]) + provider.instance_variable_set(:@dsc_resources_info, [dsc_resource_info]) expect(provider.send(:generate_description)[1]).not_to match(/lastline/) end it "reports a dsc resource has not been changed if the LCM reported no change was required" do dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resourcename", false, ["resourcename does nothing", "lastline"]) - provider.instance_variable_set("@dsc_resources_info", [dsc_resource_info]) + provider.instance_variable_set(:@dsc_resources_info, [dsc_resource_info]) expect(provider.send(:generate_description)[1]).to match(/converge DSC resource resourcename by doing nothing/) end end diff --git a/spec/unit/provider/group/usermod_spec.rb b/spec/unit/provider/group/usermod_spec.rb index caac1857cf..4071797720 100644 --- a/spec/unit/provider/group/usermod_spec.rb +++ b/spec/unit/provider/group/usermod_spec.rb @@ -61,7 +61,7 @@ describe Chef::Provider::Group::Usermod do @provider.action = :modify @provider.define_resource_requirements @provider.load_current_resource - @provider.instance_variable_set("@group_exists", true) + @provider.instance_variable_set(:@group_exists, true) expect { @provider.run_action(@provider.process_resource_requirements) }.to raise_error(Chef::Exceptions::Group, "setting group members directly is not supported by #{@provider}, must set append true in group") end @@ -69,7 +69,7 @@ describe Chef::Provider::Group::Usermod do @provider.action = :modify @provider.define_resource_requirements @provider.load_current_resource - @provider.instance_variable_set("@group_exists", true) + @provider.instance_variable_set(:@group_exists, true) @new_resource.append(true) @new_resource.excluded_members(["someone"]) expect { @provider.run_action(@provider.process_resource_requirements) }.to raise_error(Chef::Exceptions::Group, "excluded_members is not supported by #{@provider}") diff --git a/spec/unit/provider/ifconfig/aix_spec.rb b/spec/unit/provider/ifconfig/aix_spec.rb index 613291aabb..39edf25fcd 100644 --- a/spec/unit/provider/ifconfig/aix_spec.rb +++ b/spec/unit/provider/ifconfig/aix_spec.rb @@ -68,8 +68,8 @@ describe Chef::Provider::Ifconfig::Aix do it "should add an interface if it does not exist" do @new_resource.device "en10" allow(@provider).to receive(:load_current_resource) do - @provider.instance_variable_set("@status", double("Status", exitstatus: 0)) - @provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)) + @provider.instance_variable_set(:@status, double("Status", exitstatus: 0)) + @provider.instance_variable_set(:@current_resource, Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)) end command = "chdev -l #{@new_resource.device} -a netaddr=#{@new_resource.name}" expect(@provider).to receive(:shell_out_compacted!).with(*command.split(" ")) @@ -82,8 +82,8 @@ describe Chef::Provider::Ifconfig::Aix do @new_resource.device "en0" @new_resource.metric "1" allow(@provider).to receive(:load_current_resource) do - @provider.instance_variable_set("@status", double("Status", exitstatus: 0)) - @provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)) + @provider.instance_variable_set(:@status, double("Status", exitstatus: 0)) + @provider.instance_variable_set(:@current_resource, Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)) end expect { @provider.run_action(:add) }.to raise_error(Chef::Exceptions::Ifconfig, "interface metric property cannot be set for :add action") @@ -94,8 +94,8 @@ describe Chef::Provider::Ifconfig::Aix do it "should enable an interface if it does not exist" do @new_resource.device "en10" allow(@provider).to receive(:load_current_resource) do - @provider.instance_variable_set("@status", double("Status", exitstatus: 0)) - @provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)) + @provider.instance_variable_set(:@status, double("Status", exitstatus: 0)) + @provider.instance_variable_set(:@current_resource, Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)) end command = "ifconfig #{@new_resource.device} #{@new_resource.name}" expect(@provider).to receive(:shell_out_compacted!).with(*command.split(" ")) @@ -110,8 +110,8 @@ describe Chef::Provider::Ifconfig::Aix do it "should not disable an interface if it does not exist" do @new_resource.device "en10" allow(@provider).to receive(:load_current_resource) do - @provider.instance_variable_set("@status", double("Status", exitstatus: 0)) - @provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)) + @provider.instance_variable_set(:@status, double("Status", exitstatus: 0)) + @provider.instance_variable_set(:@current_resource, Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)) end expect(@provider).not_to receive(:shell_out_compacted!) @@ -124,10 +124,10 @@ describe Chef::Provider::Ifconfig::Aix do before do @new_resource.device "en10" allow(@provider).to receive(:load_current_resource) do - @provider.instance_variable_set("@status", double("Status", exitstatus: 0)) + @provider.instance_variable_set(:@status, double("Status", exitstatus: 0)) current_resource = Chef::Resource::Ifconfig.new("10.0.0.1", @run_context) current_resource.device @new_resource.device - @provider.instance_variable_set("@current_resource", current_resource) + @provider.instance_variable_set(:@current_resource, current_resource) end end @@ -147,8 +147,8 @@ describe Chef::Provider::Ifconfig::Aix do it "should not delete an interface if it does not exist" do @new_resource.device "en10" allow(@provider).to receive(:load_current_resource) do - @provider.instance_variable_set("@status", double("Status", exitstatus: 0)) - @provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)) + @provider.instance_variable_set(:@status, double("Status", exitstatus: 0)) + @provider.instance_variable_set(:@current_resource, Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)) end expect(@provider).not_to receive(:shell_out_compacted!) @@ -161,10 +161,10 @@ describe Chef::Provider::Ifconfig::Aix do before do @new_resource.device "en10" allow(@provider).to receive(:load_current_resource) do - @provider.instance_variable_set("@status", double("Status", exitstatus: 0)) + @provider.instance_variable_set(:@status, double("Status", exitstatus: 0)) current_resource = Chef::Resource::Ifconfig.new("10.0.0.1", @run_context) current_resource.device @new_resource.device - @provider.instance_variable_set("@current_resource", current_resource) + @provider.instance_variable_set(:@current_resource, current_resource) end end diff --git a/spec/unit/provider/ifconfig/debian_spec.rb b/spec/unit/provider/ifconfig/debian_spec.rb index 308435dea2..7cf951498d 100644 --- a/spec/unit/provider/ifconfig/debian_spec.rb +++ b/spec/unit/provider/ifconfig/debian_spec.rb @@ -42,7 +42,7 @@ describe Chef::Provider::Ifconfig::Debian do let(:provider) do status = double("Status", exitstatus: 0) provider = Chef::Provider::Ifconfig::Debian.new(new_resource, run_context) - provider.instance_variable_set("@status", status) + provider.instance_variable_set(:@status, status) provider.current_resource = current_resource allow(provider).to receive(:load_current_resource) allow(provider).to receive(:shell_out!) diff --git a/spec/unit/provider/ifconfig/redhat_spec.rb b/spec/unit/provider/ifconfig/redhat_spec.rb index 75291d3bf9..361363451a 100644 --- a/spec/unit/provider/ifconfig/redhat_spec.rb +++ b/spec/unit/provider/ifconfig/redhat_spec.rb @@ -40,7 +40,7 @@ describe Chef::Provider::Ifconfig::Redhat do @current_resource = Chef::Resource::Ifconfig.new("10.0.0.1", @run_context) status = double("Status", exitstatus: 0) - @provider.instance_variable_set("@status", status) + @provider.instance_variable_set(:@status, status) @provider.current_resource = @current_resource config_filename = "/etc/sysconfig/network-scripts/ifcfg-#{@new_resource.device}" diff --git a/spec/unit/provider/ifconfig_spec.rb b/spec/unit/provider/ifconfig_spec.rb index 166fe24304..120e63c809 100644 --- a/spec/unit/provider/ifconfig_spec.rb +++ b/spec/unit/provider/ifconfig_spec.rb @@ -35,7 +35,7 @@ describe Chef::Provider::Ifconfig do @current_resource = Chef::Resource::Ifconfig.new("10.0.0.1", @run_context) status = double("Status", exitstatus: 0) - @provider.instance_variable_set("@status", status) + @provider.instance_variable_set(:@status, status) @provider.current_resource = @current_resource end @@ -58,7 +58,7 @@ describe Chef::Provider::Ifconfig do @provider.load_current_resource end it "should track state of ifconfig failure" do - expect(@provider.instance_variable_get("@status").exitstatus).not_to eq(0) + expect(@provider.instance_variable_get(:@status).exitstatus).not_to eq(0) end it "should thrown an exception when ifconfig fails" do @provider.action = :add @@ -79,7 +79,7 @@ describe Chef::Provider::Ifconfig do @provider.load_current_resource end it "should track state of ifconfig failure" do - expect(@provider.instance_variable_get("@status").exitstatus).not_to eq(0) + expect(@provider.instance_variable_get(:@status).exitstatus).not_to eq(0) end it "should thrown an exception when ifconfig fails" do @provider.action = :add diff --git a/spec/unit/provider/remote_file/cache_control_data_spec.rb b/spec/unit/provider/remote_file/cache_control_data_spec.rb index 19848e4456..3252a08e6c 100644 --- a/spec/unit/provider/remote_file/cache_control_data_spec.rb +++ b/spec/unit/provider/remote_file/cache_control_data_spec.rb @@ -219,11 +219,11 @@ describe Chef::Provider::RemoteFile::CacheControlData do let(:truncated_remote_uri) { URI.parse(long_remote_path[0...CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH]) } let(:truncated_file_cache_path) do cache_control_data_truncated = Chef::Provider::RemoteFile::CacheControlData.load_and_validate(truncated_remote_uri, current_file_checksum) - cache_control_data_truncated.send("sanitized_cache_file_basename")[0...CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH] + cache_control_data_truncated.send(:sanitized_cache_file_basename)[0...CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH] end it "truncates the file cache path to 102 characters" do - normalized_cache_path = cache_control_data.send("sanitized_cache_file_basename") + normalized_cache_path = cache_control_data.send(:sanitized_cache_file_basename) expect(Chef::FileCache).to receive(:store).with("remote_file/" + normalized_cache_path, cache_control_data.json_data) @@ -233,7 +233,7 @@ describe Chef::Provider::RemoteFile::CacheControlData do end it "uses a file cache path that starts with the first #{CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH} characters of the URI" do - normalized_cache_path = cache_control_data.send("sanitized_cache_file_basename") + normalized_cache_path = cache_control_data.send(:sanitized_cache_file_basename) expect(truncated_file_cache_path.length).to eq(CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH) expect(normalized_cache_path.start_with?(truncated_file_cache_path)).to eq(true) diff --git a/spec/unit/provider/service/gentoo_service_spec.rb b/spec/unit/provider/service/gentoo_service_spec.rb index efab722ac8..25726684ae 100644 --- a/spec/unit/provider/service/gentoo_service_spec.rb +++ b/spec/unit/provider/service/gentoo_service_spec.rb @@ -49,13 +49,13 @@ describe Chef::Provider::Service::Gentoo do it "should track when service file is not found in /etc/runlevels" do @provider.load_current_resource - expect(@provider.instance_variable_get("@found_script")).to be_falsey + expect(@provider.instance_variable_get(:@found_script)).to be_falsey end it "should track when service file is found in /etc/runlevels/**/" do allow(Dir).to receive(:glob).with("/etc/runlevels/**/chef").and_return(["/etc/runlevels/default/chef"]) @provider.load_current_resource - expect(@provider.instance_variable_get("@found_script")).to be_truthy + expect(@provider.instance_variable_get(:@found_script)).to be_truthy end describe "when detecting the service enable state" do diff --git a/spec/unit/provider/service/upstart_service_spec.rb b/spec/unit/provider/service/upstart_service_spec.rb index 924ac58551..5f41319c89 100644 --- a/spec/unit/provider/service/upstart_service_spec.rb +++ b/spec/unit/provider/service/upstart_service_spec.rb @@ -160,7 +160,7 @@ describe Chef::Provider::Service::Upstart do it "should track state when the upstart configuration file fails to load" do expect(File).to receive(:exist?).and_return false @provider.load_current_resource - expect(@provider.instance_variable_get("@config_file_found")).to eq(false) + expect(@provider.instance_variable_get(:@config_file_found)).to eq(false) end describe "when a status command has been specified" do @@ -177,7 +177,7 @@ describe Chef::Provider::Service::Upstart do it "should track state when the user-provided status command fails" do allow(@provider).to receive(:shell_out!).and_raise(Errno::ENOENT) @provider.load_current_resource - expect(@provider.instance_variable_get("@command_success")).to eq(false) + expect(@provider.instance_variable_get(:@command_success)).to eq(false) end it "should set running to false if it catches a Chef::Exceptions::Exec when using a status command" do @@ -190,7 +190,7 @@ describe Chef::Provider::Service::Upstart do it "should track state when we fail to obtain service status via upstart_goal_state" do expect(@provider).to receive(:upstart_goal_state).and_raise Chef::Exceptions::Exec @provider.load_current_resource - expect(@provider.instance_variable_get("@command_success")).to eq(false) + expect(@provider.instance_variable_get(:@command_success)).to eq(false) end it "should return the current resource" do diff --git a/spec/unit/resource/conditional_spec.rb b/spec/unit/resource/conditional_spec.rb index 5f99238919..5374157336 100644 --- a/spec/unit/resource/conditional_spec.rb +++ b/spec/unit/resource/conditional_spec.rb @@ -59,7 +59,7 @@ describe Chef::Resource::Conditional do describe "after running a negative/false command given as a string" do before do - @status.send("success?=", false) + @status.send(:"success?=", false) @conditional = Chef::Resource::Conditional.only_if(@parent_resource, "false") end @@ -80,7 +80,7 @@ describe Chef::Resource::Conditional do describe "after running a negative/false command given as an array" do before do - @status.send("success?=", false) + @status.send(:"success?=", false) @conditional = Chef::Resource::Conditional.only_if(@parent_resource, ["false"]) end @@ -162,7 +162,7 @@ describe Chef::Resource::Conditional do describe "after running a failed/false command given as a string" do before do - @status.send("success?=", false) + @status.send(:"success?=", false) @conditional = Chef::Resource::Conditional.not_if(@parent_resource, "false") end @@ -183,7 +183,7 @@ describe Chef::Resource::Conditional do describe "after running a failed/false command given as an array" do before do - @status.send("success?=", false) + @status.send(:"success?=", false) @conditional = Chef::Resource::Conditional.not_if(@parent_resource, ["false"]) end diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb index faf87076fd..f20a6d3bc6 100644 --- a/spec/unit/resource_spec.rb +++ b/spec/unit/resource_spec.rb @@ -955,7 +955,7 @@ describe Chef::Resource do node.name("bumblebee") node.automatic[:platform] = "autobots" node.automatic[:platform_version] = "6.1" - Object.const_set("Soundwave", klz1) + Object.const_set(:Soundwave, klz1) klz1.provides :soundwave end @@ -978,7 +978,7 @@ describe Chef::Resource do node.automatic[:platform] = "autobots" node.automatic[:platform_version] = "6.1" klz2.provides :dinobot, platform: ["autobots"] - Object.const_set("Grimlock", klz2) + Object.const_set(:Grimlock, klz2) klz2.provides :grimlock end |