From c8c5b3b41e42c43117256798094f95d3412029bb Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Fri, 22 Oct 2021 12:15:33 -0700 Subject: Fix all the string errors Signed-off-by: Tim Smith --- chef-config/lib/chef-config/fips.rb | 2 +- chef-config/lib/chef-config/path_helper.rb | 2 +- chef-config/spec/unit/fips_spec.rb | 2 +- chef-config/spec/unit/path_helper_spec.rb | 32 +++++++++++++++--------------- 4 files changed, 19 insertions(+), 19 deletions(-) (limited to 'chef-config') diff --git a/chef-config/lib/chef-config/fips.rb b/chef-config/lib/chef-config/fips.rb index eb9e55afe6..18bd3f512e 100644 --- a/chef-config/lib/chef-config/fips.rb +++ b/chef-config/lib/chef-config/fips.rb @@ -39,7 +39,7 @@ module ChefConfig Win32::Registry::KEY_READ end begin - Win32::Registry::HKEY_LOCAL_MACHINE.open('System\CurrentControlSet\Control\Lsa\FIPSAlgorithmPolicy', reg_type) do |policy| + Win32::Registry::HKEY_LOCAL_MACHINE.open("System\\CurrentControlSet\\Control\\Lsa\\FIPSAlgorithmPolicy", reg_type) do |policy| policy["Enabled"] != 0 end rescue Win32::Registry::Error diff --git a/chef-config/lib/chef-config/path_helper.rb b/chef-config/lib/chef-config/path_helper.rb index adacade391..734dc35635 100644 --- a/chef-config/lib/chef-config/path_helper.rb +++ b/chef-config/lib/chef-config/path_helper.rb @@ -335,7 +335,7 @@ module ChefConfig line.scan(/\s*(?>([^\s\\"]+|"([^"]*)"|'([^']*)')|(\S))(\s|\z)?/m) do |word, within_dq, within_sq, esc, sep| # Append the string with Word & Escape Character - field << (word || esc.gsub(/\\(.)/, '\\1')) + field << (word || esc.gsub(/\\(.)/, "\\1")) # Re-build the field when any whitespace character or # End of string is encountered diff --git a/chef-config/spec/unit/fips_spec.rb b/chef-config/spec/unit/fips_spec.rb index 4be6f64a2d..dd8b3e17d1 100644 --- a/chef-config/spec/unit/fips_spec.rb +++ b/chef-config/spec/unit/fips_spec.rb @@ -65,7 +65,7 @@ RSpec.describe "ChefConfig.fips?" do end context "on windows", :windows_only do - let(:fips_key) { 'System\CurrentControlSet\Control\Lsa\FIPSAlgorithmPolicy' } + let(:fips_key) { "System\\CurrentControlSet\\Control\\Lsa\\FIPSAlgorithmPolicy" } let(:win_reg_entry) { { "Enabled" => enabled } } before(:each) do diff --git a/chef-config/spec/unit/path_helper_spec.rb b/chef-config/spec/unit/path_helper_spec.rb index de45de2a62..70998423d8 100644 --- a/chef-config/spec/unit/path_helper_spec.rb +++ b/chef-config/spec/unit/path_helper_spec.rb @@ -62,31 +62,31 @@ RSpec.describe ChefConfig::PathHelper do context "platform-specific #join behavior" do it "joins components on Windows when some end with unix separators" do expected = "C:\\foo\\bar\\baz" - expect(path_helper.join('C:\\foo/', "bar", "baz", windows: true)).to eq(expected) + expect(path_helper.join("C:\\foo/", "bar", "baz", windows: true)).to eq(expected) end it "joins components when some end with separators" do expected = "C:\\foo\\bar\\baz" - expect(path_helper.join('C:\\foo\\', "bar", "baz", windows: true)).to eq(expected) + expect(path_helper.join("C:\\foo\\", "bar", "baz", windows: true)).to eq(expected) end it "joins components when some end and start with separators" do expected = "C:\\foo\\bar\\baz" - expect(path_helper.join('C:\\foo\\', "bar/", "/baz", windows: true)).to eq(expected) + expect(path_helper.join("C:\\foo\\", "bar/", "/baz", windows: true)).to eq(expected) end it "joins components that don't end in separators" do expected = "C:\\foo\\bar\\baz" - expect(path_helper.join('C:\\foo', "bar", "baz", windows: true)).to eq(expected) + expect(path_helper.join("C:\\foo", "bar", "baz", windows: true)).to eq(expected) end end it "cleanpath changes slashes into backslashes and leaves backslashes alone" do - expect(path_helper.cleanpath('/a/b\\c/d/', windows: true)).to eq('\\a\\b\\c\\d') + expect(path_helper.cleanpath("/a/b\\c/d/", windows: true)).to eq("\\a\\b\\c\\d") end it "cleanpath does not remove leading double backslash" do - expect(path_helper.cleanpath('\\\\a/b\\c/d/', windows: true)).to eq('\\\\a\\b\\c\\d') + expect(path_helper.cleanpath("\\\\a/b\\c/d/", windows: true)).to eq("\\\\a\\b\\c\\d") end end @@ -117,11 +117,11 @@ RSpec.describe ChefConfig::PathHelper do end it "cleanpath changes backslashes into slashes and leaves slashes alone" do - expect(path_helper.cleanpath('/a/b\\c/d/', windows: false)).to eq("/a/b/c/d") + expect(path_helper.cleanpath("/a/b\\c/d/", windows: false)).to eq("/a/b/c/d") end it "cleanpath does not remove leading double backslash" do - expect(path_helper.cleanpath('\\\\a/b\\c/d/', windows: false)).to eq("//a/b/c/d") + expect(path_helper.cleanpath("\\\\a/b\\c/d/", windows: false)).to eq("//a/b/c/d") end end end @@ -139,31 +139,31 @@ RSpec.describe ChefConfig::PathHelper do context "platform-specific #join behavior" do it "joins components on Windows when some end with unix separators" do expected = "C:\\foo\\bar\\baz" - expect(path_helper.join('C:\\foo/', "bar", "baz")).to eq(expected) + expect(path_helper.join("C:\\foo/", "bar", "baz")).to eq(expected) end it "joins components when some end with separators" do expected = "C:\\foo\\bar\\baz" - expect(path_helper.join('C:\\foo\\', "bar", "baz")).to eq(expected) + expect(path_helper.join("C:\\foo\\", "bar", "baz")).to eq(expected) end it "joins components when some end and start with separators" do expected = "C:\\foo\\bar\\baz" - expect(path_helper.join('C:\\foo\\', "bar/", "/baz")).to eq(expected) + expect(path_helper.join("C:\\foo\\", "bar/", "/baz")).to eq(expected) end it "joins components that don't end in separators" do expected = "C:\\foo\\bar\\baz" - expect(path_helper.join('C:\\foo', "bar", "baz")).to eq(expected) + expect(path_helper.join("C:\\foo", "bar", "baz")).to eq(expected) end end it "cleanpath changes slashes into backslashes and leaves backslashes alone" do - expect(path_helper.cleanpath('/a/b\\c/d/')).to eq('\\a\\b\\c\\d') + expect(path_helper.cleanpath("/a/b\\c/d/")).to eq("\\a\\b\\c\\d") end it "cleanpath does not remove leading double backslash" do - expect(path_helper.cleanpath('\\\\a/b\\c/d/')).to eq('\\\\a\\b\\c\\d') + expect(path_helper.cleanpath("\\\\a/b\\c/d/")).to eq("\\\\a\\b\\c\\d") end end @@ -198,12 +198,12 @@ RSpec.describe ChefConfig::PathHelper do end it "cleanpath changes backslashes into slashes and leaves slashes alone" do - expect(path_helper.cleanpath('/a/b\\c/d/', windows: false)).to eq("/a/b/c/d") + expect(path_helper.cleanpath("/a/b\\c/d/", windows: false)).to eq("/a/b/c/d") end # NOTE: this seems a bit weird to me, but this is just the way Pathname#cleanpath works it "cleanpath does not remove leading double backslash" do - expect(path_helper.cleanpath('\\\\a/b\\c/d/')).to eq("//a/b/c/d") + expect(path_helper.cleanpath("\\\\a/b\\c/d/")).to eq("//a/b/c/d") end end -- cgit v1.2.1