diff options
author | Lamont Granquist <454857+lamont-granquist@users.noreply.github.com> | 2021-10-25 15:07:05 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-25 15:07:05 -0700 |
commit | ef8aed886b6ad963cdd62d2873e7dfaca2bc8bbb (patch) | |
tree | 66e1d9ebced90cb0c8252bcd1b4d661c0ae40c13 /spec/unit | |
parent | 44b787ce503c55d2ea91d2d115f75eda6653f541 (diff) | |
parent | c8c5b3b41e42c43117256798094f95d3412029bb (diff) | |
download | chef-ef8aed886b6ad963cdd62d2873e7dfaca2bc8bbb.tar.gz |
Merge pull request #12204 from chef/expeditor/chef/chefstyle_b5c712d298e240493020b8d5977f03172cc65e17
Diffstat (limited to 'spec/unit')
20 files changed, 48 insertions, 48 deletions
diff --git a/spec/unit/dsl/reboot_pending_spec.rb b/spec/unit/dsl/reboot_pending_spec.rb index 90945c3b80..3156d31e7e 100644 --- a/spec/unit/dsl/reboot_pending_spec.rb +++ b/spec/unit/dsl/reboot_pending_spec.rb @@ -36,7 +36,7 @@ describe Chef::DSL::RebootPending do end it 'should return true if "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations" exists' do - allow(recipe).to receive(:registry_value_exists?).with('HKLM\SYSTEM\CurrentControlSet\Control\Session Manager', { name: "PendingFileRenameOperations" }).and_return(true) + allow(recipe).to receive(:registry_value_exists?).with("HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager", { name: "PendingFileRenameOperations" }).and_return(true) expect(recipe.reboot_pending?).to be_truthy end diff --git a/spec/unit/mixin/default_paths_spec.rb b/spec/unit/mixin/default_paths_spec.rb index 0224b8f4ce..6d16cc6f6c 100644 --- a/spec/unit/mixin/default_paths_spec.rb +++ b/spec/unit/mixin/default_paths_spec.rb @@ -84,7 +84,7 @@ describe Chef::Mixin::DefaultPaths do allow(Gem).to receive(:bindir).and_return(gem_bindir) allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return(ruby_bindir) allow(ChefUtils).to receive(:windows?).and_return(true) - env = { "PATH" => 'C:\Windows\system32;C:\mr\softie' } + env = { "PATH" => "C:\\Windows\\system32;C:\\mr\\softie" } @default_paths.enforce_default_paths(env) expect(env["PATH"]).to eq("#{gem_bindir};#{ruby_bindir};C:\\Windows\\system32;C:\\mr\\softie") end diff --git a/spec/unit/mixin/securable_spec.rb b/spec/unit/mixin/securable_spec.rb index bbbd6bab84..b672dc19f5 100644 --- a/spec/unit/mixin/securable_spec.rb +++ b/spec/unit/mixin/securable_spec.rb @@ -53,8 +53,8 @@ describe Chef::Mixin::Securable do end it "should accept group/owner names with spaces and backslashes" do - expect { @securable.group 'test\ group' }.not_to raise_error - expect { @securable.owner 'test\ group' }.not_to raise_error + expect { @securable.group "test\\ group" }.not_to raise_error + expect { @securable.owner "test\\ group" }.not_to raise_error end it "should accept group/owner names that are a single character or digit" do @@ -186,7 +186,7 @@ describe Chef::Mixin::Securable do end it "should not accept a group name or id for group with spaces and multiple backslashes" do - expect { @securable.group 'test\ \group' }.to raise_error(ArgumentError) + expect { @securable.group "test\\ \\group" }.to raise_error(ArgumentError) end it "should accept a unix file mode in string form as an octal number" do diff --git a/spec/unit/provider/package/rubygems_spec.rb b/spec/unit/provider/package/rubygems_spec.rb index 5013b6505c..6ef63d3961 100644 --- a/spec/unit/provider/package/rubygems_spec.rb +++ b/spec/unit/provider/package/rubygems_spec.rb @@ -503,11 +503,11 @@ describe Chef::Provider::Package::Rubygems do platform_mock :windows do allow(ENV).to receive(:[]).with("PATH").and_return('C:\windows\system32;C:\windows;C:\Ruby186\bin') allow(ENV).to receive(:[]).with("PATHEXT").and_return(nil) - allow(File).to receive(:executable?).with('C:\\windows\\system32/gem').and_return(false) - allow(File).to receive(:executable?).with('C:\\windows/gem').and_return(false) - allow(File).to receive(:executable?).with('C:\\Ruby186\\bin/gem').and_return(true) - allow(File).to receive(:executable?).with('d:\\opscode\\chef\\bin/gem').and_return(false) # should not get here - allow(File).to receive(:executable?).with('d:\\opscode\\chef\\bin/gem').and_return(false) # should not get here + allow(File).to receive(:executable?).with("C:\\windows\\system32/gem").and_return(false) + allow(File).to receive(:executable?).with("C:\\windows/gem").and_return(false) + allow(File).to receive(:executable?).with("C:\\Ruby186\\bin/gem").and_return(true) + allow(File).to receive(:executable?).with("d:\\opscode\\chef\\bin/gem").and_return(false) # should not get here + allow(File).to receive(:executable?).with("d:\\opscode\\chef\\bin/gem").and_return(false) # should not get here allow(File).to receive(:executable?).with("d:/opscode/chef/embedded/bin/gem").and_return(false) # should not get here expect(provider.gem_env.gem_binary_location).to eq('C:\Ruby186\bin/gem') end diff --git a/spec/unit/provider/package/windows_spec.rb b/spec/unit/provider/package/windows_spec.rb index 6531d9c5ec..29ca8ce521 100644 --- a/spec/unit/provider/package/windows_spec.rb +++ b/spec/unit/provider/package/windows_spec.rb @@ -39,7 +39,7 @@ describe Chef::Provider::Package::Windows, :windows_only do new_resource end let(:provider) { Chef::Provider::Package::Windows.new(new_resource, run_context) } - let(:cache_path) { 'c:\\cache\\' } + let(:cache_path) { "c:\\cache\\" } before(:each) do allow(::File).to receive(:exist?).with(new_resource.source).and_return(true) diff --git a/spec/unit/provider/registry_key_spec.rb b/spec/unit/provider/registry_key_spec.rb index fe643a0ec3..76f039a9b9 100644 --- a/spec/unit/provider/registry_key_spec.rb +++ b/spec/unit/provider/registry_key_spec.rb @@ -274,7 +274,7 @@ describe Chef::Provider::RegistryKey do end context "when the key data is safe" do - let(:keyname) { 'HKLM\Software\Opscode\Testing\Safe' } + let(:keyname) { "HKLM\\Software\\Opscode\\Testing\\Safe" } let(:testval1) { { name: "one", type: :string, data: "1" } } let(:testval1_wrong_type) { { name: "one", type: :multi_string, data: "1" } } let(:testval1_wrong_data) { { name: "one", type: :string, data: "2" } } @@ -295,7 +295,7 @@ describe Chef::Provider::RegistryKey do describe "action_create" do context "when key exists and type matches" do - let(:keyname) { 'hklm\\software\\opscode\\testing\\dword' } + let(:keyname) { "hklm\\software\\opscode\\testing\\dword" } let(:dword_passed_as_integer) { { name: "one", type: :dword, data: 12345 } } let(:testval1) { { name: "one", type: :dword, data: "12345" } } before do @@ -349,7 +349,7 @@ describe Chef::Provider::RegistryKey do end context "and key does not exist" do - let(:keyname) { 'hklm\\software\\opscode\\testing\\sensitive\missing' } + let(:keyname) { "hklm\\software\\opscode\\testing\\sensitive\\missing" } let(:testval1) { { name: "one", type: :string, data: "first_value" } } before(:each) do @@ -368,7 +368,7 @@ describe Chef::Provider::RegistryKey do describe "action_create_if_missing" do context "when sensitive is true" do - let(:keyname) { 'hklm\\software\\opscode\\testing\\create_if_missing\\sensitive' } + let(:keyname) { "hklm\\software\\opscode\\testing\\create_if_missing\\sensitive" } let(:testval1) { { name: "one", type: :string, data: "first_value" } } before(:each) do diff --git a/spec/unit/provider/service/windows_spec.rb b/spec/unit/provider/service/windows_spec.rb index 08d4b2a620..2186298143 100644 --- a/spec/unit/provider/service/windows_spec.rb +++ b/spec/unit/provider/service/windows_spec.rb @@ -33,7 +33,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do # Actual response from Win32::Service.config_info('chef-client') let(:chef_service_binary_path_name) do - 'C:\\opscode\\chef\\embedded\\bin\\ruby.exe C:\\opscode\\chef\\bin\\chef-windows-service' + "C:\\opscode\\chef\\embedded\\bin\\ruby.exe C:\\opscode\\chef\\bin\\chef-windows-service" end let(:chef_service_config_info) do double("Struct::ServiceConfigInfo", @@ -153,11 +153,11 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do service_type: "share process", start_type: "demand start", error_control: "normal", - binary_path_name: 'C:\\Windows\\system32\\svchost.exe -k LocalServiceNetworkRestricted', + binary_path_name: "C:\\Windows\\system32\\svchost.exe -k LocalServiceNetworkRestricted", load_order_group: "TDI", tag_id: 0, dependencies: %w{NSI Tdx Afd}, - service_start_name: 'NT Authority\\LocalService', + service_start_name: "NT Authority\\LocalService", display_name: "DHCP Client") ) end @@ -169,11 +169,11 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do service_type: "share process", start_type: "demand start", error_control: "normal", - binary_path_name: 'C:\\Windows\\system32\\svchost.exe -k LocalServiceNetworkRestricted', + binary_path_name: "C:\\Windows\\system32\\svchost.exe -k LocalServiceNetworkRestricted", load_order_group: "TDI", tag_id: 0, dependencies: %w{NSI Tdx Afd}, - service_start_name: 'NT Authority\\LocalService', + service_start_name: "NT Authority\\LocalService", display_name: "DHCP Client") ) end diff --git a/spec/unit/provider/windows_env_spec.rb b/spec/unit/provider/windows_env_spec.rb index 7f64622d20..eb3f65713f 100644 --- a/spec/unit/provider/windows_env_spec.rb +++ b/spec/unit/provider/windows_env_spec.rb @@ -358,7 +358,7 @@ describe "windows_env provider", :windows_only do context "when environment is PATH" do describe "for PATH" do let(:system_root) { "%SystemRoot%" } - let(:system_root_value) { 'D:\Windows' } + let(:system_root_value) { "D:\\Windows" } let(:new_resource) do new_resource = Chef::Resource::WindowsEnv.new("PATH", run_context) new_resource.value(system_root) diff --git a/spec/unit/provider/zypper_repository_spec.rb b/spec/unit/provider/zypper_repository_spec.rb index 2cf4ed99c8..6b09c7bc9f 100644 --- a/spec/unit/provider/zypper_repository_spec.rb +++ b/spec/unit/provider/zypper_repository_spec.rb @@ -103,7 +103,7 @@ describe Chef::Provider::ZypperRepository do describe "#escaped_repo_name" do it "returns an escaped repo name" do - expect(provider.escaped_repo_name).to eq('Nginx\\ Repository') + expect(provider.escaped_repo_name).to eq("Nginx\\ Repository") end end diff --git a/spec/unit/resource/chocolatey_config_spec.rb b/spec/unit/resource/chocolatey_config_spec.rb index 8c4ebfaecf..0a37654b4e 100644 --- a/spec/unit/resource/chocolatey_config_spec.rb +++ b/spec/unit/resource/chocolatey_config_spec.rb @@ -41,7 +41,7 @@ describe Chef::Resource::ChocolateyConfig do # we save off the ENV and set ALLUSERSPROFILE so these specs will work on *nix and non-C drive Windows installs before(:each) do @original_env = ENV.to_hash - ENV["ALLUSERSPROFILE"] = 'C:\ProgramData' + ENV["ALLUSERSPROFILE"] = "C:\\ProgramData" end after(:each) do diff --git a/spec/unit/resource/chocolatey_feature_spec.rb b/spec/unit/resource/chocolatey_feature_spec.rb index 0a3ec8e314..0ad2bc4039 100644 --- a/spec/unit/resource/chocolatey_feature_spec.rb +++ b/spec/unit/resource/chocolatey_feature_spec.rb @@ -41,7 +41,7 @@ describe Chef::Resource::ChocolateyFeature do # we save off the ENV and set ALLUSERSPROFILE so these specs will work on *nix and non-C drive Windows installs before(:each) do @original_env = ENV.to_hash - ENV["ALLUSERSPROFILE"] = 'C:\ProgramData' + ENV["ALLUSERSPROFILE"] = "C:\\ProgramData" end after(:each) do diff --git a/spec/unit/resource/chocolatey_source_spec.rb b/spec/unit/resource/chocolatey_source_spec.rb index d0066d3ccb..1e9a1001a5 100644 --- a/spec/unit/resource/chocolatey_source_spec.rb +++ b/spec/unit/resource/chocolatey_source_spec.rb @@ -54,7 +54,7 @@ describe Chef::Resource::ChocolateySource do allow(resource).to receive(:provider_for_action).and_return(enable_provider) allow(resource.class).to receive(:new).and_return(current_resource) @original_env = ENV.to_hash - ENV["ALLUSERSPROFILE"] = 'C:\ProgramData' + ENV["ALLUSERSPROFILE"] = "C:\\ProgramData" end after(:each) do diff --git a/spec/unit/resource/registry_key_spec.rb b/spec/unit/resource/registry_key_spec.rb index 86bd41ef92..e52c7843c7 100644 --- a/spec/unit/resource/registry_key_spec.rb +++ b/spec/unit/resource/registry_key_spec.rb @@ -19,14 +19,14 @@ require "spec_helper" describe Chef::Resource::RegistryKey, "initialize" do - let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') } + let(:resource) { Chef::Resource::RegistryKey.new("HKCU\\Software\\Raxicoricofallapatorius") } it "sets the resource_name to :registry_key" do expect(resource.resource_name).to eql(:registry_key) end it "the key property is the name_property" do - expect(resource.key).to eql('HKCU\Software\Raxicoricofallapatorius') + expect(resource.key).to eql("HKCU\\Software\\Raxicoricofallapatorius") end it "sets the default action as :create" do @@ -60,11 +60,11 @@ describe Chef::Resource::RegistryKey, "initialize" do end describe Chef::Resource::RegistryKey, "key" do - let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') } + let(:resource) { Chef::Resource::RegistryKey.new("HKCU\\Software\\Raxicoricofallapatorius") } it "allows a string" do - resource.key 'HKCU\Software\Poosh' - expect(resource.key).to eql('HKCU\Software\Poosh') + resource.key "HKCU\\Software\\Poosh" + expect(resource.key).to eql("HKCU\\Software\\Poosh") end it "does not allow an integer" do @@ -77,7 +77,7 @@ describe Chef::Resource::RegistryKey, "key" do end describe Chef::Resource::RegistryKey, "values" do - let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') } + let(:resource) { Chef::Resource::RegistryKey.new("HKCU\\Software\\Raxicoricofallapatorius") } it "allows a single proper hash of registry values" do resource.values( { name: "poosh", type: :string, data: "carmen" } ) @@ -140,7 +140,7 @@ describe Chef::Resource::RegistryKey, "values" do end describe Chef::Resource::RegistryKey, "recursive" do - let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') } + let(:resource) { Chef::Resource::RegistryKey.new("HKCU\\Software\\Raxicoricofallapatorius") } it "allows a boolean" do resource.recursive(true) @@ -165,7 +165,7 @@ describe Chef::Resource::RegistryKey, "recursive" do end describe Chef::Resource::RegistryKey, "architecture" do - let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') } + let(:resource) { Chef::Resource::RegistryKey.new("HKCU\\Software\\Raxicoricofallapatorius") } %i{i386 x86_64 machine}.each do |arch| it "allows #{arch} as a symbol" do @@ -196,7 +196,7 @@ describe Chef::Resource::RegistryKey, "architecture" do end describe Chef::Resource::RegistryKey, ":unscrubbed_values" do - let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') } + let(:resource) { Chef::Resource::RegistryKey.new("HKCU\\Software\\Raxicoricofallapatorius") } it "returns unsafe data as-is" do key_values = [ { name: "poosh", type: :binary, data: 255.chr * 1 } ] @@ -206,7 +206,7 @@ describe Chef::Resource::RegistryKey, ":unscrubbed_values" do end describe Chef::Resource::RegistryKey, "state" do - let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') } + let(:resource) { Chef::Resource::RegistryKey.new("HKCU\\Software\\Raxicoricofallapatorius") } it "returns scrubbed values" do resource.values([ { name: "poosh", type: :binary, data: 255.chr * 1 } ]) diff --git a/spec/unit/resource/windows_auto_run_spec.rb b/spec/unit/resource/windows_auto_run_spec.rb index 2e9f4a4f33..8d9a8aac96 100644 --- a/spec/unit/resource/windows_auto_run_spec.rb +++ b/spec/unit/resource/windows_auto_run_spec.rb @@ -45,6 +45,6 @@ describe Chef::Resource::WindowsAutorun do it "coerces forward slashes to backslashes for the path" do resource.path "C:/something.exe" - expect(resource.path).to eql('C:\\something.exe') + expect(resource.path).to eql("C:\\something.exe") end end diff --git a/spec/unit/resource/windows_feature_powershell_spec.rb b/spec/unit/resource/windows_feature_powershell_spec.rb index 5b4062f34c..09e9018cf9 100644 --- a/spec/unit/resource/windows_feature_powershell_spec.rb +++ b/spec/unit/resource/windows_feature_powershell_spec.rb @@ -76,7 +76,7 @@ describe Chef::Resource::WindowsFeaturePowershell do node.default["powershell_features_cache"]["disabled"] = ["dhcp"] node.default["powershell_features_cache"]["removed"] = ["snmp"] resource.feature_name "dhcp, snmp" - resource.source 'D:\\sources\\sxs' + resource.source "D:\\sources\\sxs" expect(provider.features_to_install).to eq(%w{dhcp snmp}) end diff --git a/spec/unit/resource/windows_firewall_rule_spec.rb b/spec/unit/resource/windows_firewall_rule_spec.rb index d73e7d222a..d3feea7c0a 100644 --- a/spec/unit/resource/windows_firewall_rule_spec.rb +++ b/spec/unit/resource/windows_firewall_rule_spec.rb @@ -377,7 +377,7 @@ describe Chef::Resource::WindowsFirewallRule do resource.icmp_type("Any") resource.firewall_action(:notconfigured) resource.profile(:domain) - resource.program('%WINDIR%\System32\lsass.exe') + resource.program("%WINDIR%\\System32\\lsass.exe") resource.service("SomeService") resource.interface_type(:remoteaccess) resource.enabled(false) @@ -499,7 +499,7 @@ describe Chef::Resource::WindowsFirewallRule do resource.icmp_type("Any") resource.firewall_action(:notconfigured) resource.profile(:domain) - resource.program('%WINDIR%\System32\lsass.exe') + resource.program("%WINDIR%\\System32\\lsass.exe") resource.service("SomeService") resource.interface_type(:remoteaccess) resource.enabled(false) diff --git a/spec/unit/resource/windows_task_spec.rb b/spec/unit/resource/windows_task_spec.rb index b991cb89de..8b29e773b6 100644 --- a/spec/unit/resource/windows_task_spec.rb +++ b/spec/unit/resource/windows_task_spec.rb @@ -75,7 +75,7 @@ describe Chef::Resource::WindowsTask, :windows_only do context "a System User" do before do resource.frequency :hourly - resource.user 'NT AUTHORITY\SYSTEM' + resource.user "NT AUTHORITY\\SYSTEM" end context "for an interactive task" do @@ -88,7 +88,7 @@ describe Chef::Resource::WindowsTask, :windows_only do expect { resource.after_created }.to raise_error(ArgumentError, "Password is not required for system users.") end it "does not raises an error even when user is in lowercase" do - resource.user 'nt authority\system' + resource.user "nt authority\\system" expect { resource.after_created }.to_not raise_error end end @@ -103,7 +103,7 @@ describe Chef::Resource::WindowsTask, :windows_only do expect { resource.after_created }.to raise_error(ArgumentError, "Password is not required for system users.") end it "does not raises an error even when user is in lowercase" do - resource.user 'nt authority\system' + resource.user "nt authority\\system" expect { resource.after_created }.to_not raise_error end end diff --git a/spec/unit/resource_reporter_spec.rb b/spec/unit/resource_reporter_spec.rb index 69d5b28e7e..cea866cb17 100644 --- a/spec/unit/resource_reporter_spec.rb +++ b/spec/unit/resource_reporter_spec.rb @@ -494,7 +494,7 @@ describe Chef::ResourceReporter do context "when the resource is a RegistryKey with binary data" do let(:new_resource) do - resource = Chef::Resource::RegistryKey.new('Wubba\Lubba\Dub\Dubs') + resource = Chef::Resource::RegistryKey.new("Wubba\\Lubba\\Dub\\Dubs") resource.values([ { name: "rick", type: :binary, data: 255.chr * 1 } ]) allow(resource).to receive(:cookbook_name).and_return(cookbook_name) allow(resource).to receive(:cookbook_version).and_return(cookbook_version) @@ -502,7 +502,7 @@ describe Chef::ResourceReporter do end let(:current_resource) do - resource = Chef::Resource::RegistryKey.new('Wubba\Lubba\Dub\Dubs') + resource = Chef::Resource::RegistryKey.new("Wubba\\Lubba\\Dub\\Dubs") resource.values([ { name: "rick", type: :binary, data: 255.chr * 1 } ]) resource end diff --git a/spec/unit/util/backup_spec.rb b/spec/unit/util/backup_spec.rb index 1db64d3029..d7a57dce1a 100644 --- a/spec/unit/util/backup_spec.rb +++ b/spec/unit/util/backup_spec.rb @@ -132,7 +132,7 @@ describe Chef::Util::Backup do end it "uses the configured Chef::Config[:file_backup_path] and strips the drive on windows" do - expect(@backup).to receive(:path).and_return('c:\\a\\b\\c.txt') + expect(@backup).to receive(:path).and_return("c:\\a\\b\\c.txt") Chef::Config[:file_backup_path] = 'c:\backupdir' expect(@backup.send(:backup_path)).to match(%r|^c:\\backupdir[\\/]+a\\b\\c.txt.chef-\d{14}.\d{6}$|) end diff --git a/spec/unit/win32/registry_spec.rb b/spec/unit/win32/registry_spec.rb index 124765129b..992c5d99e2 100644 --- a/spec/unit/win32/registry_spec.rb +++ b/spec/unit/win32/registry_spec.rb @@ -23,12 +23,12 @@ describe Chef::Win32::Registry do let(:value1) { { name: "one", type: :string, data: "1" } } let(:value1_upcase_name) { { name: "ONE", type: :string, data: "1" } } - let(:key_path) { 'HKCU\Software\OpscodeNumbers' } - let(:key) { 'Software\OpscodeNumbers' } + let(:key_path) { "HKCU\\Software\\OpscodeNumbers" } + let(:key) { "Software\\OpscodeNumbers" } let(:key_parent) { "Software" } let(:key_to_delete) { "OpscodeNumbers" } let(:sub_key) { "OpscodePrimes" } - let(:missing_key_path) { 'HKCU\Software' } + let(:missing_key_path) { "HKCU\\Software" } let(:registry) { Chef::Win32::Registry.new } let(:hive_mock) { double("::Win32::Registry::HKEY_CURRENT_USER") } let(:reg_mock) { double("reg") } |