summaryrefslogtreecommitdiff
path: root/spec/functional/resource
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-02-05 15:00:00 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2016-02-05 15:00:00 -0800
commit686113531d23f30e9973d659c456ae33eb9cff1f (patch)
treef225de7251a8b49b8d183dd168bab0a0addbe23f /spec/functional/resource
parentd1cf34b059a16a81e0fc48de52ba29863bb41fe6 (diff)
downloadchef-686113531d23f30e9973d659c456ae33eb9cff1f.tar.gz
autofixing whitespace cops
4174 Style/SpaceInsideHashLiteralBraces 1860 Style/SpaceAroundOperators 1336 Style/SpaceInsideBlockBraces 1292 Style/AlignHash 997 Style/SpaceAfterComma 860 Style/SpaceAroundEqualsInParameterDefault 310 Style/EmptyLines 294 Style/IndentationConsistency 267 Style/TrailingWhitespace 238 Style/ExtraSpacing 212 Style/SpaceBeforeBlockBraces 166 Style/MultilineOperationIndentation 144 Style/TrailingBlankLines 120 Style/EmptyLineBetweenDefs 101 Style/IndentationWidth 82 Style/SpaceAroundBlockParameters 40 Style/EmptyLinesAroundMethodBody 29 Style/EmptyLinesAroundAccessModifier 1 Style/RescueEnsureAlignment
Diffstat (limited to 'spec/functional/resource')
-rwxr-xr-xspec/functional/resource/aix_service_spec.rb1
-rwxr-xr-xspec/functional/resource/aixinit_service_spec.rb22
-rw-r--r--spec/functional/resource/base.rb2
-rw-r--r--spec/functional/resource/bff_spec.rb2
-rw-r--r--spec/functional/resource/chocolatey_package_spec.rb12
-rw-r--r--spec/functional/resource/cron_spec.rb2
-rw-r--r--spec/functional/resource/deploy_revision_spec.rb4
-rw-r--r--spec/functional/resource/dpkg_package_spec.rb6
-rw-r--r--spec/functional/resource/dsc_resource_spec.rb2
-rw-r--r--spec/functional/resource/dsc_script_spec.rb56
-rwxr-xr-xspec/functional/resource/env_spec.rb6
-rw-r--r--spec/functional/resource/file_spec.rb3
-rw-r--r--spec/functional/resource/git_spec.rb4
-rw-r--r--spec/functional/resource/group_spec.rb20
-rw-r--r--spec/functional/resource/link_spec.rb9
-rw-r--r--spec/functional/resource/ohai_spec.rb3
-rw-r--r--spec/functional/resource/package_spec.rb10
-rw-r--r--spec/functional/resource/powershell_script_spec.rb76
-rw-r--r--spec/functional/resource/registry_spec.rb131
-rw-r--r--spec/functional/resource/remote_directory_spec.rb4
-rw-r--r--spec/functional/resource/remote_file_spec.rb2
-rw-r--r--spec/functional/resource/template_spec.rb4
-rw-r--r--spec/functional/resource/user/useradd_spec.rb26
-rw-r--r--spec/functional/resource/windows_package_spec.rb8
-rw-r--r--spec/functional/resource/windows_service_spec.rb6
25 files changed, 205 insertions, 216 deletions
diff --git a/spec/functional/resource/aix_service_spec.rb b/spec/functional/resource/aix_service_spec.rb
index fe71f10cb3..5fff3e00d7 100755
--- a/spec/functional/resource/aix_service_spec.rb
+++ b/spec/functional/resource/aix_service_spec.rb
@@ -94,7 +94,6 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
shell_out!("rmssys -s ctestsys")
end
-
let(:new_resource) do
new_resource = Chef::Resource::Service.new("ctestsys", run_context)
new_resource
diff --git a/spec/functional/resource/aixinit_service_spec.rb b/spec/functional/resource/aixinit_service_spec.rb
index 63c9cf618a..92ddb52c33 100755
--- a/spec/functional/resource/aixinit_service_spec.rb
+++ b/spec/functional/resource/aixinit_service_spec.rb
@@ -39,7 +39,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
def valide_symlinks(expected_output, run_level = nil, status = nil, priority = nil)
directory = []
if priority.is_a? Hash
- priority.each do |level,o|
+ priority.each do |level, o|
directory << "/etc/rc.d/rc#{level}.d/#{(o[0] == :start ? 'S' : 'K')}#{o[1]}#{new_resource.service_name}"
end
directory
@@ -59,7 +59,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
let(:new_resource) do
new_resource = Chef::Resource::Service.new("chefinittest", run_context)
new_resource.provider Chef::Provider::Service::AixInit
- new_resource.supports({:status => true, :restart => true, :reload => true})
+ new_resource.supports({ :status => true, :restart => true, :reload => true })
new_resource
end
@@ -70,7 +70,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
before(:all) do
File.delete("/etc/rc.d/init.d/chefinittest") if File.exists?("/etc/rc.d/init.d/chefinittest")
- FileUtils.cp("#{File.join(File.dirname(__FILE__), "/../assets/chefinittest")}", "/etc/rc.d/init.d/chefinittest")
+ FileUtils.cp("#{File.join(File.dirname(__FILE__), "/../assets/chefinittest")}", "/etc/rc.d/init.d/chefinittest")
end
after(:all) do
@@ -130,7 +130,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
context "when the service doesn't set a priority" do
it "creates symlink with status S" do
new_resource.run_action(:enable)
- valide_symlinks(["/etc/rc.d/rc2.d/Schefinittest"],2,"S")
+ valide_symlinks(["/etc/rc.d/rc2.d/Schefinittest"], 2, "S")
end
end
@@ -141,19 +141,19 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
it "creates a symlink with status S and a priority" do
new_resource.run_action(:enable)
- valide_symlinks(["/etc/rc.d/rc2.d/S75chefinittest"], 2,"S",75)
+ valide_symlinks(["/etc/rc.d/rc2.d/S75chefinittest"], 2, "S", 75)
end
end
context "when the service sets complex priorities (hash)" do
before do
- priority = {2 => [:start, 20], 3 => [:stop, 10]}
+ priority = { 2 => [:start, 20], 3 => [:stop, 10] }
new_resource.priority(priority)
end
it "create symlink with status start (S) or stop (K) and a priority " do
new_resource.run_action(:enable)
- valide_symlinks(["/etc/rc.d/rc2.d/S20chefinittest", "/etc/rc.d/rc3.d/K10chefinittest"], 2,"S",new_resource.priority)
+ valide_symlinks(["/etc/rc.d/rc2.d/S20chefinittest", "/etc/rc.d/rc3.d/K10chefinittest"], 2, "S", new_resource.priority)
end
end
end
@@ -171,7 +171,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
it "creates symlink with status K" do
new_resource.run_action(:disable)
- valide_symlinks(["/etc/rc.d/rc2.d/Kchefinittest"], 2,"K")
+ valide_symlinks(["/etc/rc.d/rc2.d/Kchefinittest"], 2, "K")
end
end
@@ -187,13 +187,13 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
it "creates a symlink with status K and a priority" do
new_resource.run_action(:disable)
- valide_symlinks(["/etc/rc.d/rc2.d/K25chefinittest"], 2,"K",25)
+ valide_symlinks(["/etc/rc.d/rc2.d/K25chefinittest"], 2, "K", 25)
end
end
context "when the service sets complex priorities (hash)" do
before do
- @priority = {2 => [:stop, 20], 3 => [:start, 10]}
+ @priority = { 2 => [:stop, 20], 3 => [:start, 10] }
new_resource.priority(@priority)
File.symlink("/etc/rc.d/init.d/chefinittest", "/etc/rc.d/rc2.d/Schefinittest")
end
@@ -204,7 +204,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
it "create symlink with status stop (K) and a priority " do
new_resource.run_action(:disable)
- valide_symlinks(["/etc/rc.d/rc2.d/K80chefinittest"], 2,"K",80)
+ valide_symlinks(["/etc/rc.d/rc2.d/K80chefinittest"], 2, "K", 80)
end
end
end
diff --git a/spec/functional/resource/base.rb b/spec/functional/resource/base.rb
index 40d178479b..38175e81c0 100644
--- a/spec/functional/resource/base.rb
+++ b/spec/functional/resource/base.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
-
def run_context
@run_context ||= begin
node = Chef::Node.new
@@ -27,4 +26,3 @@ def run_context
Chef::RunContext.new(node, {}, events)
end
end
-
diff --git a/spec/functional/resource/bff_spec.rb b/spec/functional/resource/bff_spec.rb
index 326340606d..3a1d5840e8 100644
--- a/spec/functional/resource/bff_spec.rb
+++ b/spec/functional/resource/bff_spec.rb
@@ -39,7 +39,6 @@ describe Chef::Resource::BffPackage, :requires_root, :external => ohai[:platform
!::File.exists?("/usr/PkgA/bin/acommand")
end
-
before(:all) do
@pkg_name = "PkgA.rte"
@pkg_path = "/tmp/PkgA.1.0.0.0.bff"
@@ -119,4 +118,3 @@ describe Chef::Resource::BffPackage, :requires_root, :external => ohai[:platform
end
end
end
-
diff --git a/spec/functional/resource/chocolatey_package_spec.rb b/spec/functional/resource/chocolatey_package_spec.rb
index 7cbaaf0d6b..e442008060 100644
--- a/spec/functional/resource/chocolatey_package_spec.rb
+++ b/spec/functional/resource/chocolatey_package_spec.rb
@@ -31,7 +31,7 @@ describe Chef::Resource::ChocolateyPackage, :windows_only do
let(:package_name) { "test-A" }
let(:package_list) { proc { powershell_out!("choco list -lo -r #{Array(package_name).join(' ')}").stdout.chomp } }
let(:package_source) { File.join(CHEF_SPEC_ASSETS, "chocolatey_feed") }
-
+
subject do
new_resource = Chef::Resource::ChocolateyPackage.new("test choco package", run_context)
new_resource.package_name package_name
@@ -80,13 +80,13 @@ describe Chef::Resource::ChocolateyPackage, :windows_only do
it "raises if package is not found" do
subject.package_name "blah"
- expect{ subject.run_action(:install) }.to raise_error Chef::Exceptions::Package
+ expect { subject.run_action(:install) }.to raise_error Chef::Exceptions::Package
end
- it "raises if package version is not found" do
+ it "raises if package version is not found" do
subject.version "3.0"
- expect{ subject.run_action(:install) }.to raise_error Chef::Exceptions::Package
- end
+ expect { subject.run_action(:install) }.to raise_error Chef::Exceptions::Package
+ end
end
context "upgrading a package" do
@@ -121,4 +121,4 @@ describe Chef::Resource::ChocolateyPackage, :windows_only do
expect(package_list.call).to eq("")
end
end
-end \ No newline at end of file
+end
diff --git a/spec/functional/resource/cron_spec.rb b/spec/functional/resource/cron_spec.rb
index 8c12b6e867..2906715f7a 100644
--- a/spec/functional/resource/cron_spec.rb
+++ b/spec/functional/resource/cron_spec.rb
@@ -108,7 +108,7 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do
describe "create action with various attributes", :external => exclude_solaris do
def create_and_validate_with_attribute(resource, attribute, value)
if ohai[:platform] == "aix"
- expect {resource.run_action(:create)}.to raise_error(Chef::Exceptions::Cron, /Aix cron entry does not support environment variables. Please set them in script and use script in cron./)
+ expect { resource.run_action(:create) }.to raise_error(Chef::Exceptions::Cron, /Aix cron entry does not support environment variables. Please set them in script and use script in cron./)
else
resource.run_action(:create)
# Verify if the cron is created successfully
diff --git a/spec/functional/resource/deploy_revision_spec.rb b/spec/functional/resource/deploy_revision_spec.rb
index 184c1cd017..4772067949 100644
--- a/spec/functional/resource/deploy_revision_spec.rb
+++ b/spec/functional/resource/deploy_revision_spec.rb
@@ -799,7 +799,7 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
let(:deploy_that_fails) do
resource = deploy_to_latest_rev.dup
- errant_callback = lambda {|x| raise Exception, "I am a failed deploy" }
+ errant_callback = lambda { |x| raise Exception, "I am a failed deploy" }
resource.send(callback, &errant_callback)
resource
end
@@ -862,7 +862,7 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
let(:deploy_that_fails) do
resource = deploy_to_previous_rev.dup
- resource.after_restart {|x| raise Exception, "I am a failed deploy" }
+ resource.after_restart { |x| raise Exception, "I am a failed deploy" }
resource
end
diff --git a/spec/functional/resource/dpkg_package_spec.rb b/spec/functional/resource/dpkg_package_spec.rb
index 3a09faf0d6..d65256231b 100644
--- a/spec/functional/resource/dpkg_package_spec.rb
+++ b/spec/functional/resource/dpkg_package_spec.rb
@@ -33,7 +33,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch:
Chef::RunContext.new(node, {}, events)
}
- let(:dpkg_package) { Chef::Resource::DpkgPackage.new(test1_0, run_context)}
+ let(:dpkg_package) { Chef::Resource::DpkgPackage.new(test1_0, run_context) }
before(:each) do
shell_out("dpkg -P chef-integration-test chef-integration-test2")
@@ -45,7 +45,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch:
dpkg_package.package_name name
end
- def should_be_purged_or_removed(package, action=nil)
+ def should_be_purged_or_removed(package, action = nil)
status = shell_out("dpkg -s #{package}")
output = status.stdout + status.stderr
if action.nil? || action == :purge
@@ -318,7 +318,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch:
set_dpkg_package_name "chef-integration-test2"
dpkg_package.run_action(action)
expect(dpkg_package).not_to be_updated_by_last_action
- shell_out!("dpkg -s chef-integration-test2") # its still 'installed'
+ shell_out!("dpkg -s chef-integration-test2") # its still 'installed'
end
end
diff --git a/spec/functional/resource/dsc_resource_spec.rb b/spec/functional/resource/dsc_resource_spec.rb
index f2c943f21d..129333c190 100644
--- a/spec/functional/resource/dsc_resource_spec.rb
+++ b/spec/functional/resource/dsc_resource_spec.rb
@@ -52,7 +52,7 @@ describe Chef::Resource::DscResource, :windows_powershell_dsc_only do
context "with a valid dsc resource" do
let(:tmp_file_name) { Dir::Tmpname.create("tmpfile") {} }
- let(:test_text) { "'\"!@#$%^&*)(}{][\u2713~n"}
+ let(:test_text) { "'\"!@#$%^&*)(}{][\u2713~n" }
before do
new_resource.resource :File
diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb
index cb8d73f746..5f264fdca1 100644
--- a/spec/functional/resource/dsc_script_spec.rb
+++ b/spec/functional/resource/dsc_script_spec.rb
@@ -38,7 +38,7 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do
data_suffix = data ? "_config_data" : ""
extension = data ? "psd1" : "ps1"
script_path = "#{@temp_dir}/dsc_functional_test#{data_suffix}.#{extension}"
- ::File.open(script_path, "wt") do | script |
+ ::File.open(script_path, "wt") do |script|
script.write(script_code)
end
script_path
@@ -68,7 +68,7 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do
node = Chef::Node.new
node.automatic["platform"] = "windows"
node.automatic["platform_version"] = "6.1"
- node.automatic["kernel"][:machine] = :x86_64 # Only 64-bit architecture is supported
+ node.automatic["kernel"][:machine] = :x86_64 # Only 64-bit architecture is supported
node.automatic[:languages][:powershell][:version] = "4.0"
empty_events = Chef::EventDispatch::Dispatcher.new
Chef::RunContext.new(node, {}, empty_events)
@@ -83,7 +83,7 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do
let(:test_registry_data2) { "LL928" }
let(:reg_key_name_param_name) { "testregkeyname" }
let(:reg_key_value_param_name) { "testregvaluename" }
- let(:registry_embedded_parameters) { "$#{reg_key_name_param_name} = '#{test_registry_key}';$#{reg_key_value_param_name} = '#{test_registry_value}'"}
+ let(:registry_embedded_parameters) { "$#{reg_key_name_param_name} = '#{test_registry_key}';$#{reg_key_value_param_name} = '#{test_registry_value}'" }
let(:dsc_reg_code) { <<-EOH
#{registry_embedded_parameters}
Registry "ChefRegKey"
@@ -105,17 +105,17 @@ EOH
let(:dsc_user_prefix) { "dsc" }
let(:dsc_user_suffix) { "chefx" }
- let(:dsc_user) {"#{dsc_user_prefix}_usr_#{dsc_user_suffix}" }
+ let(:dsc_user) { "#{dsc_user_prefix}_usr_#{dsc_user_suffix}" }
let(:dsc_user_prefix_env_var_name) { "dsc_user_env_prefix" }
let(:dsc_user_suffix_env_var_name) { "dsc_user_env_suffix" }
- let(:dsc_user_prefix_env_code) { "$env:#{dsc_user_prefix_env_var_name}"}
- let(:dsc_user_suffix_env_code) { "$env:#{dsc_user_suffix_env_var_name}"}
+ let(:dsc_user_prefix_env_code) { "$env:#{dsc_user_prefix_env_var_name}" }
+ let(:dsc_user_suffix_env_code) { "$env:#{dsc_user_suffix_env_var_name}" }
let(:dsc_user_prefix_param_name) { "dsc_user_prefix_param" }
let(:dsc_user_suffix_param_name) { "dsc_user_suffix_param" }
- let(:dsc_user_prefix_param_code) { "$#{dsc_user_prefix_param_name}"}
- let(:dsc_user_suffix_param_code) { "$#{dsc_user_suffix_param_name}"}
- let(:dsc_user_env_code) { "\"$(#{dsc_user_prefix_env_code})_usr_$(#{dsc_user_suffix_env_code})\""}
- let(:dsc_user_param_code) { "\"$(#{dsc_user_prefix_param_code})_usr_$(#{dsc_user_suffix_param_code})\""}
+ let(:dsc_user_prefix_param_code) { "$#{dsc_user_prefix_param_name}" }
+ let(:dsc_user_suffix_param_code) { "$#{dsc_user_suffix_param_name}" }
+ let(:dsc_user_env_code) { "\"$(#{dsc_user_prefix_env_code})_usr_$(#{dsc_user_suffix_env_code})\"" }
+ let(:dsc_user_param_code) { "\"$(#{dsc_user_prefix_param_code})_usr_$(#{dsc_user_suffix_param_code})\"" }
let(:config_flags) { nil }
let(:config_params) { <<-EOH
@@ -157,7 +157,7 @@ EOH
}
let(:dsc_user_config_data) {
-<<-EOH
+ <<-EOH
@{
AllNodes = @(
@{
@@ -220,7 +220,7 @@ EOH
expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(false)
dsc_test_resource.run_action(:run)
expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(true)
- expect(dsc_test_resource.registry_value_exists?(test_registry_key, {:name => test_registry_value, :type => :string, :data => test_registry_data})).to eq(true)
+ expect(dsc_test_resource.registry_value_exists?(test_registry_key, { :name => test_registry_value, :type => :string, :data => test_registry_data })).to eq(true)
end
it_should_behave_like "a dsc_script resource with configuration affected by cwd"
@@ -243,12 +243,12 @@ EOH
let(:dsc_code) { dsc_environment_config }
it "should not raise an exception if the cwd is not etc" do
dsc_test_resource.cwd(dsc_environment_no_fail_not_etc_directory)
- expect {dsc_test_resource.run_action(:run)}.not_to raise_error
+ expect { dsc_test_resource.run_action(:run) }.not_to raise_error
end
it "should raise an exception if the cwd is etc" do
dsc_test_resource.cwd(dsc_environment_fail_etc_directory)
- expect {dsc_test_resource.run_action(:run)}.to raise_error(Chef::Exceptions::PowershellCmdletException)
+ expect { dsc_test_resource.run_action(:run) }.to raise_error(Chef::Exceptions::PowershellCmdletException)
begin
dsc_test_resource.run_action(:run)
rescue Chef::Exceptions::PowershellCmdletException => e
@@ -280,7 +280,7 @@ EOH
end
let(:test_registry_data) { test_registry_data1 }
- let(:dsc_parameterized_env_param_value) { "val" + Random::rand.to_s }
+ let(:dsc_parameterized_env_param_value) { "val" + Random::rand.to_s }
it "should have a default value of nil for the configuration_data attribute" do
expect(dsc_test_resource.configuration_data).to eql(nil)
@@ -296,11 +296,11 @@ EOH
it "should set a registry key according to parameters passed to the configuration" do
dsc_test_resource.configuration_name(config_name_value)
- dsc_test_resource.flags({:"#{reg_key_name_param_name}" => test_registry_key, :"#{reg_key_value_param_name}" => test_registry_value})
+ dsc_test_resource.flags({ :"#{reg_key_name_param_name}" => test_registry_key, :"#{reg_key_value_param_name}" => test_registry_value })
expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(false)
dsc_test_resource.run_action(:run)
expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(true)
- expect(dsc_test_resource.registry_value_exists?(test_registry_key, {:name => test_registry_value, :type => :string, :data => test_registry_data})).to eq(true)
+ expect(dsc_test_resource.registry_value_exists?(test_registry_key, { :name => test_registry_value, :type => :string, :data => test_registry_data })).to eq(true)
end
end
end
@@ -320,12 +320,12 @@ EOH
if configuration_data_attribute == "configuration_data_script"
config_data_value = create_config_script_from_code(dsc_user_config_data, "", true)
end
- dsc_test_resource.environment({dsc_user_prefix_env_var_name => dsc_user_prefix,
- dsc_user_suffix_env_var_name => dsc_user_suffix})
+ dsc_test_resource.environment({ dsc_user_prefix_env_var_name => dsc_user_prefix,
+ dsc_user_suffix_env_var_name => dsc_user_suffix })
dsc_test_resource.send(configuration_data_attribute, config_data_value)
dsc_test_resource.flags(config_flags)
expect(user_exists?(dsc_user)).to eq(false)
- expect {dsc_test_resource.run_action(:run)}.not_to raise_error
+ expect { dsc_test_resource.run_action(:run) }.not_to raise_error
expect(user_exists?(dsc_user)).to eq(true)
end
end
@@ -333,9 +333,9 @@ EOH
shared_examples_for "a dsc_script with configuration data that takes parameters" do
let(:dsc_user_code) { dsc_user_param_code }
let(:config_param_section) { config_params }
- let(:config_flags) {{:"#{dsc_user_prefix_param_name}" => "#{dsc_user_prefix}", :"#{dsc_user_suffix_param_name}" => "#{dsc_user_suffix}"}}
+ let(:config_flags) { { :"#{dsc_user_prefix_param_name}" => "#{dsc_user_prefix}", :"#{dsc_user_suffix_param_name}" => "#{dsc_user_suffix}" } }
it "does not directly contain the user name" do
- configuration_script_content = ::File.open(dsc_test_resource.command) do | file |
+ configuration_script_content = ::File.open(dsc_test_resource.command) do |file|
file.read
end
expect(configuration_script_content.include?(dsc_user)).to be(false)
@@ -347,7 +347,7 @@ EOH
let(:dsc_user_code) { dsc_user_env_code }
it "does not directly contain the user name" do
- configuration_script_content = ::File.open(dsc_test_resource.command) do | file |
+ configuration_script_content = ::File.open(dsc_test_resource.command) do |file|
file.read
end
expect(configuration_script_content.include?(dsc_user)).to be(false)
@@ -385,7 +385,7 @@ EOH
before(:each) do
delete_user(dsc_user)
- dsc_test_run_context.node.consume_external_attrs(OHAI_SYSTEM.data,{})
+ dsc_test_run_context.node.consume_external_attrs(OHAI_SYSTEM.data, {})
end
let(:configuration_data_path) { 'C:\\configurationdata.psd1' }
@@ -422,12 +422,12 @@ if($cert -eq $null) {
}
lcm -thumbprint $cert.thumbprint
-set-dsclocalconfigurationmanager -path ./LCM
+set-dsclocalconfigurationmanager -path ./LCM
$ConfigurationData = @"
@{
-AllNodes = @(
- @{
- NodeName = "localhost";
+AllNodes = @(
+ @{
+ NodeName = "localhost";
CertificateID = '$($cert.thumbprint)';
};
);
diff --git a/spec/functional/resource/env_spec.rb b/spec/functional/resource/env_spec.rb
index 91fa860cd7..83328a6738 100755
--- a/spec/functional/resource/env_spec.rb
+++ b/spec/functional/resource/env_spec.rb
@@ -90,7 +90,7 @@ describe Chef::Resource::Env, :windows_only do
expect(ENV[chef_env_test_lower_case]).to eq(nil)
test_resource.key_name(chef_env_test_lower_case)
test_resource.value(env_value1)
- expect {test_resource.run_action(:modify) }.to raise_error(Chef::Exceptions::Env)
+ expect { test_resource.run_action(:modify) }.to raise_error(Chef::Exceptions::Env)
end
it "should modify an existing variable's value to a new value" do
@@ -127,7 +127,7 @@ describe Chef::Resource::Env, :windows_only do
context "when using PATH" do
let(:random_name) { Time.now.to_i }
- let(:env_val) { "#{env_value_expandable}_#{random_name}"}
+ let(:env_val) { "#{env_value_expandable}_#{random_name}" }
let!(:path_before) { test_resource.provider_for_action(test_resource.action).env_value("PATH") || "" }
let!(:env_path_before) { ENV["PATH"] }
@@ -165,7 +165,7 @@ describe Chef::Resource::Env, :windows_only do
expect(ENV[chef_env_test_lower_case]).to eq(nil)
test_resource.key_name(chef_env_test_lower_case)
test_resource.value(env_value1)
- expect{test_resource.run_action(:delete)}.not_to raise_error
+ expect { test_resource.run_action(:delete) }.not_to raise_error
expect(ENV[chef_env_test_lower_case]).to eq(nil)
end
diff --git a/spec/functional/resource/file_spec.rb b/spec/functional/resource/file_spec.rb
index d7ca34ecb8..0fa1317032 100644
--- a/spec/functional/resource/file_spec.rb
+++ b/spec/functional/resource/file_spec.rb
@@ -25,7 +25,7 @@ describe Chef::Resource::File do
let(:file_base) { "file_spec" }
let(:expected_content) { "Don't fear the ruby." }
- def create_resource(opts={})
+ def create_resource(opts = {})
events = Chef::EventDispatch::Dispatcher.new
node = Chef::Node.new
run_context = Chef::RunContext.new(node, {}, events)
@@ -86,7 +86,6 @@ describe Chef::Resource::File do
end
end
-
describe "when using backup" do
before do
Chef::Config[:file_backup_path] = CHEF_SPEC_BACKUP_PATH
diff --git a/spec/functional/resource/git_spec.rb b/spec/functional/resource/git_spec.rb
index 8710b22f31..7174a99451 100644
--- a/spec/functional/resource/git_spec.rb
+++ b/spec/functional/resource/git_spec.rb
@@ -62,7 +62,7 @@ describe Chef::Resource::Git do
let(:v1_tag) { "9b73fb5e316bfaff7b822b0ccb3e1e08f9885085" }
let(:rev_foo) { "ed181b3419b6f489bedab282348162a110d6d3a1" }
let(:rev_testing) { "972d153654503bccec29f630c5dd369854a561e8" }
- let(:rev_head) { "d294fbfd05aa7709ad9a9b8ef6343b17d355bf5f"}
+ let(:rev_head) { "d294fbfd05aa7709ad9a9b8ef6343b17d355bf5f" }
let(:git_user_config) do
<<-E
@@ -76,7 +76,7 @@ E
Chef::Log.level = :warn # silence git command live streams
@old_file_cache_path = Chef::Config[:file_cache_path]
shell_out!("git clone \"#{git_bundle_repo}\" example", :cwd => origin_repo_dir)
- File.open("#{origin_repo}/.git/config", "a+") {|f| f.print(git_user_config) }
+ File.open("#{origin_repo}/.git/config", "a+") { |f| f.print(git_user_config) }
Chef::Config[:file_cache_path] = file_cache_path
end
diff --git a/spec/functional/resource/group_spec.rb b/spec/functional/resource/group_spec.rb
index cb460fe7b4..063b5d9004 100644
--- a/spec/functional/resource/group_spec.rb
+++ b/spec/functional/resource/group_spec.rb
@@ -334,7 +334,7 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" }
invalid_resource = group_resource.dup
invalid_resource.members(["Jack"])
invalid_resource.excluded_members(["Jack"])
- expect { invalid_resource.run_action(:create)}.to raise_error(Chef::Exceptions::ConflictingMembersInGroup)
+ expect { invalid_resource.run_action(:create) }.to raise_error(Chef::Exceptions::ConflictingMembersInGroup)
end
end
end
@@ -361,7 +361,7 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" }
end
describe "group modify action", :not_supported_on_solaris do
- let(:spec_members){ ["mnou5sdz", "htulrvwq", "x4c3g1lu"] }
+ let(:spec_members) { ["mnou5sdz", "htulrvwq", "x4c3g1lu"] }
let(:included_members) { [spec_members[0], spec_members[1]] }
let(:excluded_members) { [spec_members[2]] }
let(:tested_action) { :modify }
@@ -379,7 +379,7 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" }
describe "when running on Windows", :windows_only do
describe "when members are Active Directory domain identities", :windows_domain_joined_only do
let(:computer_domain) { ohai[:kernel]["cs_info"]["domain"].split(".")[0] }
- let(:spec_members){ ["#{computer_domain}\\Domain Admins", "#{computer_domain}\\Domain Users", "#{computer_domain}\\Domain Computers"] }
+ let(:spec_members) { ["#{computer_domain}\\Domain Admins", "#{computer_domain}\\Domain Users", "#{computer_domain}\\Domain Computers"] }
include_examples "correct group management"
end
@@ -389,7 +389,7 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" }
end
describe "group manage action", :not_supported_on_solaris do
- let(:spec_members){ ["mnou5sdz", "htulrvwq", "x4c3g1lu"] }
+ let(:spec_members) { ["mnou5sdz", "htulrvwq", "x4c3g1lu"] }
let(:included_members) { [spec_members[0], spec_members[1]] }
let(:excluded_members) { [spec_members[2]] }
let(:tested_action) { :manage }
@@ -416,7 +416,7 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" }
describe "running on windows", :windows_only do
describe "when members are Windows domain identities", :windows_domain_joined_only do
let(:computer_domain) { ohai[:kernel]["cs_info"]["domain"].split(".")[0] }
- let(:spec_members){ ["#{computer_domain}\\Domain Admins", "#{computer_domain}\\Domain Users", "#{computer_domain}\\Domain Computers"] }
+ let(:spec_members) { ["#{computer_domain}\\Domain Admins", "#{computer_domain}\\Domain Users", "#{computer_domain}\\Domain Computers"] }
include_examples "correct group management"
end
@@ -430,15 +430,15 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" }
let(:excluded_members) { ["x4c3g1lu"] }
it ":manage should raise an error" do
- expect {group_resource.run_action(:manage) }.to raise_error
+ expect { group_resource.run_action(:manage) }.to raise_error
end
it ":modify should raise an error" do
- expect {group_resource.run_action(:modify) }.to raise_error
+ expect { group_resource.run_action(:modify) }.to raise_error
end
it ":create should raise an error" do
- expect {group_resource.run_action(:create) }.to raise_error
+ expect { group_resource.run_action(:create) }.to raise_error
end
end
@@ -450,11 +450,11 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" }
end
it ":manage should raise an error" do
- expect {group_resource.run_action(:manage) }.to raise_error
+ expect { group_resource.run_action(:manage) }.to raise_error
end
it ":modify should raise an error" do
- expect {group_resource.run_action(:modify) }.to raise_error
+ expect { group_resource.run_action(:modify) }.to raise_error
end
end
end
diff --git a/spec/functional/resource/link_spec.rb b/spec/functional/resource/link_spec.rb
index cfb20f0c69..9b9d696979 100644
--- a/spec/functional/resource/link_spec.rb
+++ b/spec/functional/resource/link_spec.rb
@@ -25,7 +25,7 @@ end
describe Chef::Resource::Link do
let(:file_base) { "file_spec" }
- let(:expect_updated?) {true}
+ let(:expect_updated?) { true }
# We create the files in a different directory than tmp to exercise
# different file deployment strategies more completely.
@@ -83,6 +83,7 @@ describe Chef::Resource::Link do
File.symlink(a, b)
end
end
+
def symlink?(file)
if windows?
Chef::ReservedNames::Win32::File.symlink?(file)
@@ -90,6 +91,7 @@ describe Chef::Resource::Link do
File.symlink?(file)
end
end
+
def readlink(file)
if windows?
Chef::ReservedNames::Win32::File.readlink(file)
@@ -97,6 +99,7 @@ describe Chef::Resource::Link do
File.readlink(file)
end
end
+
def link(a, b)
if windows?
Chef::ReservedNames::Win32::File.link(a, b)
@@ -354,9 +357,11 @@ describe Chef::Resource::Link do
def allowed_acl(sid, expected_perms)
[ ACE.access_allowed(sid, expected_perms[:specific]) ]
end
+
def denied_acl(sid, expected_perms)
[ ACE.access_denied(sid, expected_perms[:specific]) ]
end
+
def parent_inheritable_acls
dummy_file_path = File.join(test_file_dir, "dummy_file")
FileUtils.touch(dummy_file_path)
@@ -602,7 +607,7 @@ describe Chef::Resource::Link do
describe "when not supported on platform", :win2k3_only do
it "raises error" do
- expect {resource}.to raise_error(Chef::Exceptions::Win32APIFunctionNotImplemented)
+ expect { resource }.to raise_error(Chef::Exceptions::Win32APIFunctionNotImplemented)
end
end
end
diff --git a/spec/functional/resource/ohai_spec.rb b/spec/functional/resource/ohai_spec.rb
index ff7666392a..9ce989d8df 100644
--- a/spec/functional/resource/ohai_spec.rb
+++ b/spec/functional/resource/ohai_spec.rb
@@ -45,7 +45,7 @@ describe Chef::Resource::Ohai do
end
describe "when reloading all plugins" do
- let(:ohai_resource) { Chef::Resource::Ohai.new("reload all", run_context)}
+ let(:ohai_resource) { Chef::Resource::Ohai.new("reload all", run_context) }
it_behaves_like "reloaded :uptime"
end
@@ -57,7 +57,6 @@ describe Chef::Resource::Ohai do
r
}
-
it_behaves_like "reloaded :uptime"
end
end
diff --git a/spec/functional/resource/package_spec.rb b/spec/functional/resource/package_spec.rb
index 499b2d6b78..36b106bf1c 100644
--- a/spec/functional/resource/package_spec.rb
+++ b/spec/functional/resource/package_spec.rb
@@ -87,9 +87,9 @@ module AptServer
end
metadata = { :unix_only => true,
- :requires_root => true,
- :provider => {:package => Chef::Provider::Package::Apt},
- :arch => "x86_64" # test packages are 64bit
+ :requires_root => true,
+ :provider => { :package => Chef::Provider::Package::Apt },
+ :arch => "x86_64" # test packages are 64bit
}
describe Chef::Resource::Package, metadata do
@@ -112,7 +112,6 @@ describe Chef::Resource::Package, metadata do
shell_out!("apt-get clean")
end
-
after do
shell_out!("dpkg -r chef-integration-test")
shell_out("dpkg --clear-avail")
@@ -325,14 +324,13 @@ describe Chef::Resource::Package, metadata do
# un chef-integration-test <none> (no description available)
def pkg_should_be_removed
# will raise if exit code != 0,1
- pkg_check = shell_out!("dpkg -l chef-integration-test", :returns => [0,1])
+ pkg_check = shell_out!("dpkg -l chef-integration-test", :returns => [0, 1])
if pkg_check.exitstatus == 0
expect(pkg_check.stdout).to match(/un[\s]+chef-integration-test/)
end
end
-
it "removes the package for action :remove" do
package_resource.run_action(:remove)
pkg_should_be_removed
diff --git a/spec/functional/resource/powershell_script_spec.rb b/spec/functional/resource/powershell_script_spec.rb
index 2d9e1458a7..7a7f7a2ded 100644
--- a/spec/functional/resource/powershell_script_spec.rb
+++ b/spec/functional/resource/powershell_script_spec.rb
@@ -164,7 +164,7 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do
it "returns 1 if the last command was a cmdlet that failed and was preceded by an unsuccessfully executed non-cmdlet Windows binary" do
pending "powershell.exe always exits with 0 on nano" if Chef::Platform.windows_nano_server?
- resource.code([arbitrary_nonzero_process_exit_code_content,cmdlet_exit_code_not_found_content].join(";"))
+ resource.code([arbitrary_nonzero_process_exit_code_content, cmdlet_exit_code_not_found_content].join(";"))
resource.returns(arbitrary_nonzero_process_exit_code)
resource.run_action(:run)
end
@@ -325,7 +325,7 @@ configuration LCM
it "raises an error when executing a script with a 32-bit process on Windows Nano Server", :windows_nano_only do
resource.code(processor_architecture_script_content + " | out-file -encoding ASCII #{script_output_path}")
- expect{ resource.architecture(:i386) }.to raise_error(Chef::Exceptions::Win32ArchitectureIncorrect,
+ expect { resource.architecture(:i386) }.to raise_error(Chef::Exceptions::Win32ArchitectureIncorrect,
"cannot execute script with requested architecture 'i386' on Windows Nano Server")
end
end
@@ -342,22 +342,22 @@ configuration LCM
end
it "evaluates a succeeding not_if block using cmd.exe as false by default" do
- resource.not_if "exit /b 0"
+ resource.not_if "exit /b 0"
expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a failing not_if block using cmd.exe as true by default" do
- resource.not_if "exit /b 2"
+ resource.not_if "exit /b 2"
expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates an succeeding only_if block using cmd.exe as true by default" do
- resource.only_if "exit /b 0"
+ resource.only_if "exit /b 0"
expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a failing only_if block using cmd.exe as false by default" do
- resource.only_if "exit /b 2"
+ resource.only_if "exit /b 2"
expect(resource.should_skip?(:run)).to be_truthy
end
end
@@ -383,77 +383,77 @@ configuration LCM
it "evaluates a powershell $false for a not_if block as true" do
pending "powershell.exe always exits with $true on nano" if Chef::Platform.windows_nano_server?
- resource.not_if "$false"
+ resource.not_if "$false"
expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a powershell $true for a not_if block as false" do
- resource.not_if "$true"
+ resource.not_if "$true"
expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a powershell $false for an only_if block as false" do
pending "powershell.exe always exits with $true on nano" if Chef::Platform.windows_nano_server?
- resource.only_if "$false"
+ resource.only_if "$false"
expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a powershell $true for a only_if block as true" do
- resource.only_if "$true"
+ resource.only_if "$true"
expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a not_if block using powershell.exe" do
- resource.not_if "exit([int32](![System.Environment]::CommandLine.Contains('powershell.exe')))"
+ resource.not_if "exit([int32](![System.Environment]::CommandLine.Contains('powershell.exe')))"
expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates an only_if block using powershell.exe" do
- resource.only_if "exit([int32](![System.Environment]::CommandLine.Contains('powershell.exe')))"
+ resource.only_if "exit([int32](![System.Environment]::CommandLine.Contains('powershell.exe')))"
expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a non-zero powershell exit status for not_if as true" do
pending "powershell.exe always exits with 0 on nano" if Chef::Platform.windows_nano_server?
- resource.not_if "exit 37"
+ resource.not_if "exit 37"
expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a zero powershell exit status for not_if as false" do
- resource.not_if "exit 0"
+ resource.not_if "exit 0"
expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a failed executable exit status for not_if as false" do
pending "powershell.exe always exits with success on nano" if Chef::Platform.windows_nano_server?
- resource.not_if windows_process_exit_code_not_found_content
+ resource.not_if windows_process_exit_code_not_found_content
expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a successful executable exit status for not_if as true" do
- resource.not_if windows_process_exit_code_success_content
+ resource.not_if windows_process_exit_code_success_content
expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a failed executable exit status for only_if as false" do
pending "powershell.exe always exits with success on nano" if Chef::Platform.windows_nano_server?
- resource.only_if windows_process_exit_code_not_found_content
+ resource.only_if windows_process_exit_code_not_found_content
expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a successful executable exit status for only_if as true" do
- resource.only_if windows_process_exit_code_success_content
+ resource.only_if windows_process_exit_code_success_content
expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a failed cmdlet exit status for not_if as true" do
pending "powershell.exe always exits with success on nano" if Chef::Platform.windows_nano_server?
- resource.not_if "throw 'up'"
+ resource.not_if "throw 'up'"
expect(resource.should_skip?(:run)).to be_falsey
end
@@ -465,44 +465,44 @@ configuration LCM
it "evaluates a failed cmdlet exit status for only_if as false" do
pending "powershell.exe always exits with success on nano" if Chef::Platform.windows_nano_server?
- resource.only_if "throw 'up'"
+ resource.only_if "throw 'up'"
expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a successful cmdlet exit status for only_if as true" do
- resource.only_if "cd ."
+ resource.only_if "cd ."
expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a not_if block using the cwd guard parameter" do
custom_cwd = "#{ENV['SystemRoot']}\\system32\\drivers\\etc"
- resource.not_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')", :cwd => custom_cwd
+ resource.not_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')", :cwd => custom_cwd
expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates an only_if block using the cwd guard parameter" do
custom_cwd = "#{ENV['SystemRoot']}\\system32\\drivers\\etc"
- resource.only_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')", :cwd => custom_cwd
+ resource.only_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')", :cwd => custom_cwd
expect(resource.should_skip?(:run)).to be_falsey
end
it "inherits cwd from the parent resource for only_if" do
custom_cwd = "#{ENV['SystemRoot']}\\system32\\drivers\\etc"
resource.cwd custom_cwd
- resource.only_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')"
+ resource.only_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')"
expect(resource.should_skip?(:run)).to be_falsey
end
it "inherits cwd from the parent resource for not_if" do
custom_cwd = "#{ENV['SystemRoot']}\\system32\\drivers\\etc"
resource.cwd custom_cwd
- resource.not_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')"
+ resource.not_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')"
expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a 64-bit resource with a 64-bit guard and interprets boolean false as zero status code", :windows64_only do
resource.architecture :x86_64
- resource.only_if "exit [int32]($env:PROCESSOR_ARCHITECTURE -ne 'AMD64')"
+ resource.only_if "exit [int32]($env:PROCESSOR_ARCHITECTURE -ne 'AMD64')"
expect(resource.should_skip?(:run)).to be_falsey
end
@@ -510,19 +510,19 @@ configuration LCM
pending "powershell.exe always exits with 0 on nano" if Chef::Platform.windows_nano_server?
resource.architecture :x86_64
- resource.only_if "exit [int32]($env:PROCESSOR_ARCHITECTURE -eq 'AMD64')"
+ resource.only_if "exit [int32]($env:PROCESSOR_ARCHITECTURE -eq 'AMD64')"
expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a 32-bit resource with a 32-bit guard and interprets boolean false as zero status code", :not_supported_on_nano do
resource.architecture :i386
- resource.only_if "exit [int32]($env:PROCESSOR_ARCHITECTURE -ne 'X86')"
+ resource.only_if "exit [int32]($env:PROCESSOR_ARCHITECTURE -ne 'X86')"
expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a 32-bit resource with a 32-bit guard and interprets boolean true as nonzero status code", :not_supported_on_nano do
resource.architecture :i386
- resource.only_if "exit [int32]($env:PROCESSOR_ARCHITECTURE -eq 'X86')"
+ resource.only_if "exit [int32]($env:PROCESSOR_ARCHITECTURE -eq 'X86')"
expect(resource.should_skip?(:run)).to be_truthy
end
@@ -530,7 +530,7 @@ configuration LCM
pending "powershell.exe always exits with 0 on nano" if Chef::Platform.windows_nano_server?
resource.convert_boolean_return true
- resource.only_if "$false"
+ resource.only_if "$false"
expect(resource.should_skip?(:run)).to be_truthy
end
@@ -538,53 +538,53 @@ configuration LCM
pending "powershell.exe always exits with 0 on nano" if Chef::Platform.windows_nano_server?
resource.convert_boolean_return true
- resource.not_if "$false"
+ resource.not_if "$false"
expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a simple boolean true as 0 status code when convert_boolean_return is true for only_if" do
resource.convert_boolean_return true
- resource.only_if "$true"
+ resource.only_if "$true"
expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a simple boolean true as 0 status code when convert_boolean_return is true for not_if" do
resource.convert_boolean_return true
- resource.not_if "$true"
+ resource.not_if "$true"
expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a 32-bit resource with a 32-bit guard and interprets boolean false as zero status code using convert_boolean_return for only_if", :not_supported_on_nano do
resource.convert_boolean_return true
resource.architecture :i386
- resource.only_if "$env:PROCESSOR_ARCHITECTURE -eq 'X86'"
+ resource.only_if "$env:PROCESSOR_ARCHITECTURE -eq 'X86'"
expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a 32-bit resource with a 32-bit guard and interprets boolean false as zero status code using convert_boolean_return for not_if", :not_supported_on_nano do
resource.convert_boolean_return true
resource.architecture :i386
- resource.not_if "$env:PROCESSOR_ARCHITECTURE -ne 'X86'"
+ resource.not_if "$env:PROCESSOR_ARCHITECTURE -ne 'X86'"
expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a 32-bit resource with a 32-bit guard and interprets boolean true as nonzero status code using convert_boolean_return for only_if", :not_supported_on_nano do
resource.convert_boolean_return true
resource.architecture :i386
- resource.only_if "$env:PROCESSOR_ARCHITECTURE -ne 'X86'"
+ resource.only_if "$env:PROCESSOR_ARCHITECTURE -ne 'X86'"
expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a 32-bit resource with a 32-bit guard and interprets boolean true as nonzero status code using convert_boolean_return for not_if", :not_supported_on_nano do
resource.convert_boolean_return true
resource.architecture :i386
- resource.not_if "$env:PROCESSOR_ARCHITECTURE -eq 'X86'"
+ resource.not_if "$env:PROCESSOR_ARCHITECTURE -eq 'X86'"
expect(resource.should_skip?(:run)).to be_truthy
end
it "raises an error when a 32-bit guard is used on Windows Nano Server", :windows_nano_only do
resource.only_if "$true", :architecture => :i386
- expect{resource.run_action(:run)}.to raise_error(
+ expect { resource.run_action(:run) }.to raise_error(
Chef::Exceptions::Win32ArchitectureIncorrect,
/cannot execute script with requested architecture 'i386' on Windows Nano Server/)
end
diff --git a/spec/functional/resource/registry_spec.rb b/spec/functional/resource/registry_spec.rb
index 9d7de1f183..6cf8524883 100644
--- a/spec/functional/resource/registry_spec.rb
+++ b/spec/functional/resource/registry_spec.rb
@@ -27,15 +27,15 @@ describe Chef::Resource::RegistryKey, :unix_only do
node = Chef::Node.new
ohai = Ohai::System.new
ohai.all_plugins
- node.consume_external_attrs(ohai.data,{})
+ node.consume_external_attrs(ohai.data, {})
run_context = Chef::RunContext.new(node, {}, events)
@resource = Chef::Resource::RegistryKey.new("HKCU\\Software", run_context)
end
context "when load_current_resource is run on a non-windows node" do
it "throws an exception because you don't have a windows registry (derp)" do
@resource.key("HKCU\\Software\\Opscode")
- @resource.values([{:name=>"Color", :type=>:string, :data=>"Orange"}])
- expect{@resource.run_action(:create)}.to raise_error(Chef::Exceptions::Win32NotWindows)
+ @resource.values([{ :name => "Color", :type => :string, :data => "Orange" }])
+ expect { @resource.run_action(:create) }.to raise_error(Chef::Exceptions::Win32NotWindows)
end
end
end
@@ -98,7 +98,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
@node = Chef::Node.new
ohai = Ohai::System.new
ohai.all_plugins
- @node.consume_external_attrs(ohai.data,{})
+ @node.consume_external_attrs(ohai.data, {})
@run_context = Chef::RunContext.new(@node, {}, @events)
@new_resource = Chef::Resource::RegistryKey.new(resource_name, @run_context)
@@ -113,8 +113,8 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
@rest_client = double("Chef::ServerAPI (mock)")
allow(@rest_client).to receive(:create_url).and_return("reports/nodes/windowsbox/runs/#{@run_id}");
- allow(@rest_client).to receive(:raw_http_request).and_return({"result"=>"ok"});
- allow(@rest_client).to receive(:post_rest).and_return({"uri"=>"https://example.com/reports/nodes/windowsbox/runs/#{@run_id}"});
+ allow(@rest_client).to receive(:raw_http_request).and_return({ "result" => "ok" });
+ allow(@rest_client).to receive(:post_rest).and_return({ "uri" => "https://example.com/reports/nodes/windowsbox/runs/#{@run_id}" });
@resource_reporter = Chef::ResourceReporter.new(@rest_client)
@events.register(@resource_reporter)
@@ -122,7 +122,6 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
@resource_reporter.run_started(@run_status)
@run_id = @resource_reporter.run_id
-
@new_resource.cookbook_name = "monkey"
@cookbook_version = double("Cookbook::Version", :version => "1.2.3")
allow(@new_resource).to receive(:cookbook_version).and_return(@cookbook_version)
@@ -138,76 +137,76 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
end
it "creates registry key, value if the key is missing" do
@new_resource.key(reg_child)
- @new_resource.values([{:name=>"Color", :type=>:string, :data=>"Orange"}])
+ @new_resource.values([{ :name => "Color", :type => :string, :data => "Orange" }])
@new_resource.run_action(:create)
expect(@registry.key_exists?(reg_child)).to eq(true)
- expect(@registry.data_exists?(reg_child, {:name=>"Color", :type=>:string, :data=>"Orange"})).to eq(true)
+ expect(@registry.data_exists?(reg_child, { :name => "Color", :type => :string, :data => "Orange" })).to eq(true)
end
it "does not create the key if it already exists with same value, type and data" do
@new_resource.key(reg_child)
- @new_resource.values([{:name=>"Color", :type=>:string, :data=>"Orange"}])
+ @new_resource.values([{ :name => "Color", :type => :string, :data => "Orange" }])
@new_resource.run_action(:create)
expect(@registry.key_exists?(reg_child)).to eq(true)
- expect(@registry.data_exists?(reg_child, {:name=>"Color", :type=>:string, :data=>"Orange"})).to eq(true)
+ expect(@registry.data_exists?(reg_child, { :name => "Color", :type => :string, :data => "Orange" })).to eq(true)
end
it "creates a value if it does not exist" do
@new_resource.key(reg_child)
- @new_resource.values([{:name=>"Mango", :type=>:string, :data=>"Yellow"}])
+ @new_resource.values([{ :name => "Mango", :type => :string, :data => "Yellow" }])
@new_resource.run_action(:create)
- expect(@registry.data_exists?(reg_child, {:name=>"Mango", :type=>:string, :data=>"Yellow"})).to eq(true)
+ expect(@registry.data_exists?(reg_child, { :name => "Mango", :type => :string, :data => "Yellow" })).to eq(true)
end
it "modifies the data if the key and value exist and type matches" do
@new_resource.key(reg_child)
- @new_resource.values([{:name=>"Color", :type=>:string, :data=>"Not just Orange - OpscodeOrange!"}])
+ @new_resource.values([{ :name => "Color", :type => :string, :data => "Not just Orange - OpscodeOrange!" }])
@new_resource.run_action(:create)
- expect(@registry.data_exists?(reg_child, {:name=>"Color", :type=>:string, :data=>"Not just Orange - OpscodeOrange!"})).to eq(true)
+ expect(@registry.data_exists?(reg_child, { :name => "Color", :type => :string, :data => "Not just Orange - OpscodeOrange!" })).to eq(true)
end
it "modifys the type if the key and value exist and the type does not match" do
@new_resource.key(reg_child)
- @new_resource.values([{:name=>"Color", :type=>:multi_string, :data=>["Not just Orange - OpscodeOrange!"]}])
+ @new_resource.values([{ :name => "Color", :type => :multi_string, :data => ["Not just Orange - OpscodeOrange!"] }])
@new_resource.run_action(:create)
- expect(@registry.data_exists?(reg_child, {:name=>"Color", :type=>:multi_string, :data=>["Not just Orange - OpscodeOrange!"]})).to eq(true)
+ expect(@registry.data_exists?(reg_child, { :name => "Color", :type => :multi_string, :data => ["Not just Orange - OpscodeOrange!"] })).to eq(true)
end
it "creates subkey if parent exists" do
@new_resource.key(reg_child + '\OpscodeTest')
- @new_resource.values([{:name=>"Chef", :type=>:multi_string, :data=>["OpscodeOrange", "Rules"]}])
+ @new_resource.values([{ :name => "Chef", :type => :multi_string, :data => ["OpscodeOrange", "Rules"] }])
@new_resource.recursive(false)
@new_resource.run_action(:create)
expect(@registry.key_exists?(reg_child + '\OpscodeTest')).to eq(true)
- expect(@registry.value_exists?(reg_child + '\OpscodeTest', {:name=>"Chef", :type=>:multi_string, :data=>["OpscodeOrange", "Rules"]})).to eq(true)
+ expect(@registry.value_exists?(reg_child + '\OpscodeTest', { :name => "Chef", :type => :multi_string, :data => ["OpscodeOrange", "Rules"] })).to eq(true)
end
it "gives error if action create and parent does not exist and recursive is set to false" do
@new_resource.key(reg_child + '\Missing1\Missing2')
- @new_resource.values([{:name=>"OC", :type=>:string, :data=>"MissingData"}])
+ @new_resource.values([{ :name => "OC", :type => :string, :data => "MissingData" }])
@new_resource.recursive(false)
- expect{@new_resource.run_action(:create)}.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
+ expect { @new_resource.run_action(:create) }.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
end
it "creates missing keys if action create and parent does not exist and recursive is set to true" do
@new_resource.key(reg_child + '\Missing1\Missing2')
- @new_resource.values([{:name=>"OC", :type=>:string, :data=>"MissingData"}])
+ @new_resource.values([{ :name => "OC", :type => :string, :data => "MissingData" }])
@new_resource.recursive(true)
@new_resource.run_action(:create)
expect(@registry.key_exists?(reg_child + '\Missing1\Missing2')).to eq(true)
- expect(@registry.value_exists?(reg_child + '\Missing1\Missing2', {:name=>"OC", :type=>:string, :data=>"MissingData"})).to eq(true)
+ expect(@registry.value_exists?(reg_child + '\Missing1\Missing2', { :name => "OC", :type => :string, :data => "MissingData" })).to eq(true)
end
it "creates key with multiple value as specified" do
@new_resource.key(reg_child)
- @new_resource.values([{:name=>"one", :type=>:string, :data=>"1"},{:name=>"two", :type=>:string, :data=>"2"},{:name=>"three", :type=>:string, :data=>"3"}])
+ @new_resource.values([{ :name => "one", :type => :string, :data => "1" }, { :name => "two", :type => :string, :data => "2" }, { :name => "three", :type => :string, :data => "3" }])
@new_resource.recursive(true)
@new_resource.run_action(:create)
@@ -226,12 +225,12 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
end
it "creates a key in a 32-bit registry that is not viewable in 64-bit" do
@new_resource.key(reg_child + '\Atraxi' )
- @new_resource.values([{:name=>"OC", :type=>:string, :data=>"Data"}])
+ @new_resource.values([{ :name => "OC", :type => :string, :data => "Data" }])
@new_resource.recursive(true)
@new_resource.architecture(:i386)
@new_resource.run_action(:create)
@registry.architecture = :i386
- expect(@registry.data_exists?(reg_child + '\Atraxi', {:name=>"OC", :type=>:string, :data=>"Data"})).to eq(true)
+ expect(@registry.data_exists?(reg_child + '\Atraxi', { :name => "OC", :type => :string, :data => "Data" })).to eq(true)
@registry.architecture = :x86_64
expect(@registry.key_exists?(reg_child + '\Atraxi')).to eq(false)
end
@@ -239,7 +238,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
it "prepares the reporting data for action :create" do
@new_resource.key(reg_child + '\Ood')
- @new_resource.values([{:name=>"ReportingVal1", :type=>:string, :data=>"report1"},{:name=>"ReportingVal2", :type=>:string, :data=>"report2"}])
+ @new_resource.values([{ :name => "ReportingVal1", :type => :string, :data => "report1" }, { :name => "ReportingVal2", :type => :string, :data => "report2" }])
@new_resource.recursive(true)
@new_resource.run_action(:create)
@report = @resource_reporter.prepare_run_data
@@ -248,8 +247,8 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
expect(@report["resources"][0]["type"]).to eq("registry_key")
expect(@report["resources"][0]["name"]).to eq(resource_name)
expect(@report["resources"][0]["id"]).to eq(reg_child + '\Ood')
- expect(@report["resources"][0]["after"][:values]).to eq([{:name=>"ReportingVal1", :type=>:string, :data=>"report1"},
- {:name=>"ReportingVal2", :type=>:string, :data=>"report2"}])
+ expect(@report["resources"][0]["after"][:values]).to eq([{ :name => "ReportingVal1", :type => :string, :data => "report1" },
+ { :name => "ReportingVal2", :type => :string, :data => "report2" }])
expect(@report["resources"][0]["before"][:values]).to eq([])
expect(@report["resources"][0]["result"]).to eq("create")
expect(@report["status"]).to eq("success")
@@ -263,7 +262,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
it "does not throw an exception if the keys do not exist but recursive is set to false" do
@new_resource.key(reg_child + '\Slitheen\Raxicoricofallapatorius')
- @new_resource.values([{:name=>"BriskWalk",:type=>:string,:data=>"is good for health"}])
+ @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }])
@new_resource.recursive(false)
@new_resource.run_action(:create) # should not raise_error
expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false)
@@ -271,7 +270,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
end
it "does not create key if the action is create" do
@new_resource.key(reg_child + '\Slitheen')
- @new_resource.values([{:name=>"BriskWalk",:type=>:string,:data=>"is good for health"}])
+ @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }])
@new_resource.recursive(false)
@new_resource.run_action(:create)
expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false)
@@ -286,61 +285,61 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
it "creates registry key, value if the key is missing" do
@new_resource.key(reg_child)
- @new_resource.values([{:name=>"Color", :type=>:string, :data=>"Orange"}])
+ @new_resource.values([{ :name => "Color", :type => :string, :data => "Orange" }])
@new_resource.run_action(:create_if_missing)
expect(@registry.key_exists?(reg_parent)).to eq(true)
expect(@registry.key_exists?(reg_child)).to eq(true)
- expect(@registry.data_exists?(reg_child, {:name=>"Color", :type=>:string, :data=>"Orange"})).to eq(true)
+ expect(@registry.data_exists?(reg_child, { :name => "Color", :type => :string, :data => "Orange" })).to eq(true)
end
it "does not create the key if it already exists with same value, type and data" do
@new_resource.key(reg_child)
- @new_resource.values([{:name=>"Color", :type=>:string, :data=>"Orange"}])
+ @new_resource.values([{ :name => "Color", :type => :string, :data => "Orange" }])
@new_resource.run_action(:create_if_missing)
expect(@registry.key_exists?(reg_child)).to eq(true)
- expect(@registry.data_exists?(reg_child, {:name=>"Color", :type=>:string, :data=>"Orange"})).to eq(true)
+ expect(@registry.data_exists?(reg_child, { :name => "Color", :type => :string, :data => "Orange" })).to eq(true)
end
it "creates a value if it does not exist" do
@new_resource.key(reg_child)
- @new_resource.values([{:name=>"Mango", :type=>:string, :data=>"Yellow"}])
+ @new_resource.values([{ :name => "Mango", :type => :string, :data => "Yellow" }])
@new_resource.run_action(:create_if_missing)
- expect(@registry.data_exists?(reg_child, {:name=>"Mango", :type=>:string, :data=>"Yellow"})).to eq(true)
+ expect(@registry.data_exists?(reg_child, { :name => "Mango", :type => :string, :data => "Yellow" })).to eq(true)
end
it "creates subkey if parent exists" do
@new_resource.key(reg_child + '\Pyrovile')
- @new_resource.values([{:name=>"Chef", :type=>:multi_string, :data=>["OpscodeOrange", "Rules"]}])
+ @new_resource.values([{ :name => "Chef", :type => :multi_string, :data => ["OpscodeOrange", "Rules"] }])
@new_resource.recursive(false)
@new_resource.run_action(:create_if_missing)
expect(@registry.key_exists?(reg_child + '\Pyrovile')).to eq(true)
- expect(@registry.value_exists?(reg_child + '\Pyrovile', {:name=>"Chef", :type=>:multi_string, :data=>["OpscodeOrange", "Rules"]})).to eq(true)
+ expect(@registry.value_exists?(reg_child + '\Pyrovile', { :name => "Chef", :type => :multi_string, :data => ["OpscodeOrange", "Rules"] })).to eq(true)
end
it "gives error if action create and parent does not exist and recursive is set to false" do
@new_resource.key(reg_child + '\Sontaran\Sontar')
- @new_resource.values([{:name=>"OC", :type=>:string, :data=>"MissingData"}])
+ @new_resource.values([{ :name => "OC", :type => :string, :data => "MissingData" }])
@new_resource.recursive(false)
- expect{@new_resource.run_action(:create_if_missing)}.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
+ expect { @new_resource.run_action(:create_if_missing) }.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
end
it "creates missing keys if action create and parent does not exist and recursive is set to true" do
@new_resource.key(reg_child + '\Sontaran\Sontar')
- @new_resource.values([{:name=>"OC", :type=>:string, :data=>"MissingData"}])
+ @new_resource.values([{ :name => "OC", :type => :string, :data => "MissingData" }])
@new_resource.recursive(true)
@new_resource.run_action(:create_if_missing)
expect(@registry.key_exists?(reg_child + '\Sontaran\Sontar')).to eq(true)
- expect(@registry.value_exists?(reg_child + '\Sontaran\Sontar', {:name=>"OC", :type=>:string, :data=>"MissingData"})).to eq(true)
+ expect(@registry.value_exists?(reg_child + '\Sontaran\Sontar', { :name => "OC", :type => :string, :data => "MissingData" })).to eq(true)
end
it "creates key with multiple value as specified" do
@new_resource.key(reg_child + '\Adipose')
- @new_resource.values([{:name=>"one", :type=>:string, :data=>"1"},{:name=>"two", :type=>:string, :data=>"2"},{:name=>"three", :type=>:string, :data=>"3"}])
+ @new_resource.values([{ :name => "one", :type => :string, :data => "1" }, { :name => "two", :type => :string, :data => "2" }, { :name => "three", :type => :string, :data => "3" }])
@new_resource.recursive(true)
@new_resource.run_action(:create_if_missing)
@@ -351,7 +350,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
it "prepares the reporting data for :create_if_missing" do
@new_resource.key(reg_child + '\Judoon')
- @new_resource.values([{:name=>"ReportingVal3", :type=>:string, :data=>"report3"}])
+ @new_resource.values([{ :name => "ReportingVal3", :type => :string, :data => "report3" }])
@new_resource.recursive(true)
@new_resource.run_action(:create_if_missing)
@report = @resource_reporter.prepare_run_data
@@ -360,7 +359,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
expect(@report["resources"][0]["type"]).to eq("registry_key")
expect(@report["resources"][0]["name"]).to eq(resource_name)
expect(@report["resources"][0]["id"]).to eq(reg_child + '\Judoon')
- expect(@report["resources"][0]["after"][:values]).to eq([{:name=>"ReportingVal3", :type=>:string, :data=>"report3"}])
+ expect(@report["resources"][0]["after"][:values]).to eq([{ :name => "ReportingVal3", :type => :string, :data => "report3" }])
expect(@report["resources"][0]["before"][:values]).to eq([])
expect(@report["resources"][0]["result"]).to eq("create_if_missing")
expect(@report["status"]).to eq("success")
@@ -374,7 +373,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
it "does not throw an exception if the keys do not exist but recursive is set to false" do
@new_resource.key(reg_child + '\Zygons\Zygor')
- @new_resource.values([{:name=>"BriskWalk",:type=>:string,:data=>"is good for health"}])
+ @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }])
@new_resource.recursive(false)
@new_resource.run_action(:create_if_missing) # should not raise_error
expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false)
@@ -382,7 +381,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
end
it "does nothing if the action is create_if_missing" do
@new_resource.key(reg_child + '\Zygons')
- @new_resource.values([{:name=>"BriskWalk",:type=>:string,:data=>"is good for health"}])
+ @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }])
@new_resource.recursive(false)
@new_resource.run_action(:create_if_missing)
expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false)
@@ -399,7 +398,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
it "takes no action if the specified key path does not exist in the system" do
expect(@registry.key_exists?(reg_parent + '\Osirian')).to eq(false)
- @new_resource.key(reg_parent+ '\Osirian')
+ @new_resource.key(reg_parent + '\Osirian')
@new_resource.recursive(false)
@new_resource.run_action(:delete)
@@ -407,53 +406,53 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
end
it "takes no action if the key exists but the value does not" do
- expect(@registry.data_exists?(reg_parent + '\Opscode', {:name=>"Color", :type=>:string, :data=>"Orange"})).to eq(true)
+ expect(@registry.data_exists?(reg_parent + '\Opscode', { :name => "Color", :type => :string, :data => "Orange" })).to eq(true)
@new_resource.key(reg_parent + '\Opscode')
- @new_resource.values([{:name=>"LooksLike", :type=>:multi_string, :data=>["SeattleGrey", "OCOrange"]}])
+ @new_resource.values([{ :name => "LooksLike", :type => :multi_string, :data => ["SeattleGrey", "OCOrange"] }])
@new_resource.recursive(false)
@new_resource.run_action(:delete)
- expect(@registry.data_exists?(reg_parent + '\Opscode', {:name=>"Color", :type=>:string, :data=>"Orange"})).to eq(true)
+ expect(@registry.data_exists?(reg_parent + '\Opscode', { :name => "Color", :type => :string, :data => "Orange" })).to eq(true)
end
it "deletes only specified values under a key path" do
@new_resource.key(reg_parent + '\Opscode')
- @new_resource.values([{:name=>"Opscode", :type=>:multi_string, :data=>["Seattle", "Washington"]}, {:name=>"AKA", :type=>:string, :data=>"OC"}])
+ @new_resource.values([{ :name => "Opscode", :type => :multi_string, :data => ["Seattle", "Washington"] }, { :name => "AKA", :type => :string, :data => "OC" }])
@new_resource.recursive(false)
@new_resource.run_action(:delete)
- expect(@registry.data_exists?(reg_parent + '\Opscode', {:name=>"Color", :type=>:string, :data=>"Orange"})).to eq(true)
- expect(@registry.value_exists?(reg_parent + '\Opscode', {:name=>"AKA", :type=>:string, :data=>"OC"})).to eq(false)
- expect(@registry.value_exists?(reg_parent + '\Opscode', {:name=>"Opscode", :type=>:multi_string, :data=>["Seattle", "Washington"]})).to eq(false)
+ expect(@registry.data_exists?(reg_parent + '\Opscode', { :name => "Color", :type => :string, :data => "Orange" })).to eq(true)
+ expect(@registry.value_exists?(reg_parent + '\Opscode', { :name => "AKA", :type => :string, :data => "OC" })).to eq(false)
+ expect(@registry.value_exists?(reg_parent + '\Opscode', { :name => "Opscode", :type => :multi_string, :data => ["Seattle", "Washington"] })).to eq(false)
end
it "it deletes the values with the same name irrespective of it type and data" do
@new_resource.key(reg_parent + '\Opscode')
- @new_resource.values([{:name=>"Color", :type=>:multi_string, :data=>["Black", "Orange"]}])
+ @new_resource.values([{ :name => "Color", :type => :multi_string, :data => ["Black", "Orange"] }])
@new_resource.recursive(false)
@new_resource.run_action(:delete)
- expect(@registry.value_exists?(reg_parent + '\Opscode', {:name=>"Color", :type=>:string, :data=>"Orange"})).to eq(false)
+ expect(@registry.value_exists?(reg_parent + '\Opscode', { :name => "Color", :type => :string, :data => "Orange" })).to eq(false)
end
it "prepares the reporting data for action :delete" do
@new_resource.key(reg_parent + '\ReportKey')
- @new_resource.values([{:name=>"ReportVal4", :type=>:string, :data=>"report4"},{:name=>"ReportVal5", :type=>:string, :data=>"report5"}])
+ @new_resource.values([{ :name => "ReportVal4", :type => :string, :data => "report4" }, { :name => "ReportVal5", :type => :string, :data => "report5" }])
@new_resource.recursive(true)
@new_resource.run_action(:delete)
@report = @resource_reporter.prepare_run_data
- expect(@registry.value_exists?(reg_parent + '\ReportKey', [{:name=>"ReportVal4", :type=>:string, :data=>"report4"},{:name=>"ReportVal5", :type=>:string, :data=>"report5"}])).to eq(false)
+ expect(@registry.value_exists?(reg_parent + '\ReportKey', [{ :name => "ReportVal4", :type => :string, :data => "report4" }, { :name => "ReportVal5", :type => :string, :data => "report5" }])).to eq(false)
expect(@report["action"]).to eq("end")
expect(@report["resources"].count).to eq(1)
expect(@report["resources"][0]["type"]).to eq("registry_key")
expect(@report["resources"][0]["name"]).to eq(resource_name)
expect(@report["resources"][0]["id"]).to eq(reg_parent + '\ReportKey')
- expect(@report["resources"][0]["before"][:values]).to eq([{:name=>"ReportVal4", :type=>:string, :data=>"report4"},
- {:name=>"ReportVal5", :type=>:string, :data=>"report5"}])
+ expect(@report["resources"][0]["before"][:values]).to eq([{ :name => "ReportVal4", :type => :string, :data => "report4" },
+ { :name => "ReportVal5", :type => :string, :data => "report5" }])
#Not testing for after values to match since after -> new_resource values.
expect(@report["resources"][0]["result"]).to eq("delete")
expect(@report["status"]).to eq("success")
@@ -466,7 +465,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
end
it "does nothing if the action is delete" do
@new_resource.key(reg_parent + '\OpscodeWhyRun')
- @new_resource.values([{:name=>"BriskWalk",:type=>:string,:data=>"is good for health"}])
+ @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }])
@new_resource.recursive(false)
@new_resource.run_action(:delete)
@@ -502,7 +501,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
it "raises an exception if the key has subkeys and recursive == false" do
@new_resource.key(reg_parent)
@new_resource.recursive(false)
- expect{@new_resource.run_action(:delete_key)}.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
+ expect { @new_resource.run_action(:delete_key) }.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
end
it "ignores the values under a key" do
@@ -544,13 +543,13 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
it "does not throw an exception if the key has subkeys but recursive is set to false" do
@new_resource.key(reg_parent + '\OpscodeWhyRun')
- @new_resource.values([{:name=>"BriskWalk",:type=>:string,:data=>"is good for health"}])
+ @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }])
@new_resource.recursive(false)
@new_resource.run_action(:delete_key)
end
it "does nothing if the action is delete_key" do
@new_resource.key(reg_parent + '\OpscodeWhyRun')
- @new_resource.values([{:name=>"BriskWalk",:type=>:string,:data=>"is good for health"}])
+ @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }])
@new_resource.recursive(false)
@new_resource.run_action(:delete_key)
diff --git a/spec/functional/resource/remote_directory_spec.rb b/spec/functional/resource/remote_directory_spec.rb
index 8e01464e86..c25e51cf2a 100644
--- a/spec/functional/resource/remote_directory_spec.rb
+++ b/spec/functional/resource/remote_directory_spec.rb
@@ -136,8 +136,8 @@ describe Chef::Resource::RemoteDirectory do
FileUtils.mkdir_p(File.join(path, "remotesubdir"))
modified_file = File.join(path, "remote_dir_file1.txt")
modified_subdir_file = File.join(path, "remotesubdir", "remote_subdir_file1.txt")
- File.open(modified_file, "a") {|f| f.puts "santa is real"}
- File.open(modified_subdir_file, "a") {|f| f.puts "so is rudolph"}
+ File.open(modified_file, "a") { |f| f.puts "santa is real" }
+ File.open(modified_subdir_file, "a") { |f| f.puts "so is rudolph" }
modified_file_checksum = sha256_checksum(modified_file)
modified_subdir_file_checksum = sha256_checksum(modified_subdir_file)
diff --git a/spec/functional/resource/remote_file_spec.rb b/spec/functional/resource/remote_file_spec.rb
index 876467d490..b394bd0240 100644
--- a/spec/functional/resource/remote_file_spec.rb
+++ b/spec/functional/resource/remote_file_spec.rb
@@ -232,7 +232,7 @@ describe Chef::Resource::RemoteFile do
end
it "should not create the file" do
- expect{ resource.run_action(:create) }.to raise_error
+ expect { resource.run_action(:create) }.to raise_error
expect(File).not_to exist(path)
end
end
diff --git a/spec/functional/resource/template_spec.rb b/spec/functional/resource/template_spec.rb
index 6ce4a3cc3d..da8cbfc68a 100644
--- a/spec/functional/resource/template_spec.rb
+++ b/spec/functional/resource/template_spec.rb
@@ -21,7 +21,7 @@ require "spec_helper"
describe Chef::Resource::Template do
def binread(file)
- File.open(file,"rb") {|f| f.read }
+ File.open(file, "rb") { |f| f.read }
end
include_context Chef::Resource::File
@@ -73,7 +73,7 @@ describe Chef::Resource::Template do
end
it "creates the template with the rendered content using a local erb file when the :create action is run" do
- resource.source(File.expand_path(File.join(CHEF_SPEC_DATA,"cookbooks","openldap","templates","default","openldap_stuff.conf.erb")))
+ resource.source(File.expand_path(File.join(CHEF_SPEC_DATA, "cookbooks", "openldap", "templates", "default", "openldap_stuff.conf.erb")))
resource.cookbook(nil)
resource.local(true)
resource.run_action(:create)
diff --git a/spec/functional/resource/user/useradd_spec.rb b/spec/functional/resource/user/useradd_spec.rb
index ab16a1672f..84757cc197 100644
--- a/spec/functional/resource/user/useradd_spec.rb
+++ b/spec/functional/resource/user/useradd_spec.rb
@@ -31,23 +31,22 @@ def user_provider_for_platform
end
metadata = { :unix_only => true,
- :requires_root => true,
- :not_supported_on_mac_osx => true,
- :provider => {:user => user_provider_for_platform},
+ :requires_root => true,
+ :not_supported_on_mac_osx => true,
+ :provider => { :user => user_provider_for_platform },
}
describe Chef::Provider::User::Useradd, metadata do
include Chef::Mixin::ShellOut
-
# Utility code for /etc/passwd interaction, avoid any caching of user records:
PwEntry = Struct.new(:name, :passwd, :uid, :gid, :gecos, :home, :shell)
class UserNotFound < StandardError; end
def pw_entry
- passwd_file = File.open("/etc/passwd", "rb") {|f| f.read}
+ passwd_file = File.open("/etc/passwd", "rb") { |f| f.read }
matcher = /^#{Regexp.escape(username)}.+$/
if passwd_entry = passwd_file.scan(matcher).first
PwEntry.new(*passwd_entry.split(":"))
@@ -59,9 +58,9 @@ describe Chef::Provider::User::Useradd, metadata do
def etc_shadow
case ohai[:platform]
when "aix"
- File.open("/etc/security/passwd") {|f| f.read }
+ File.open("/etc/security/passwd") { |f| f.read }
else
- File.open("/etc/shadow") {|f| f.read }
+ File.open("/etc/shadow") { |f| f.read }
end
end
@@ -104,7 +103,7 @@ describe Chef::Provider::User::Useradd, metadata do
while max_retries > 0
begin
pw_entry # will raise if the user doesn't exist
- status = shell_out!("userdel", "-r", username, :returns => [0,8,12])
+ status = shell_out!("userdel", "-r", username, :returns => [0, 8, 12])
# Error code 8 during userdel indicates that the user is logged in.
# This occurs randomly because the accounts daemon holds a lock due to which userdel fails.
@@ -160,7 +159,7 @@ describe Chef::Provider::User::Useradd, metadata do
let(:expected_shadow) do
if ohai[:platform] == "aix"
- expected_shadow = "cf-test" # For aix just check user entry in shadow file
+ expected_shadow = "cf-test" # For aix just check user entry in shadow file
else
expected_shadow = "cf-test:$1$RRa/wMM/$XltKfoX5ffnexVF4dHZZf/"
end
@@ -174,7 +173,6 @@ describe Chef::Provider::User::Useradd, metadata do
expect(user_resource).to be_updated_by_last_action
end
-
it "ensures the user exists" do
expect(pw_entry.name).to eq(username)
end
@@ -194,7 +192,6 @@ describe Chef::Provider::User::Useradd, metadata do
end
end
-
context "when uid is set" do
# Should verify uid not in use...
let(:uid) { 1999 }
@@ -296,7 +293,7 @@ describe Chef::Provider::User::Useradd, metadata do
# Ubuntu 13.04 system, these are commented out, so we'll look at
# UID_MIN to find the lower limit of the non-system-user range, and
# use that value in our assertions.
- login_defs = File.open("/etc/login.defs", "rb") {|f| f.read }
+ login_defs = File.open("/etc/login.defs", "rb") { |f| f.read }
uid_min_scan = /^UID_MIN\s+(\d+)/
login_defs.match(uid_min_scan)[1]
end
@@ -455,7 +452,6 @@ describe Chef::Provider::User::Useradd, metadata do
end
end
-
it "ensures the password is set" do
password_should_be_set
expect(etc_shadow).to include(expected_shadow)
@@ -484,7 +480,6 @@ describe Chef::Provider::User::Useradd, metadata do
end
end
-
it "ensures the password is set to the desired value" do
password_should_be_set
expect(etc_shadow).to include(expected_shadow)
@@ -518,7 +513,7 @@ describe Chef::Provider::User::Useradd, metadata do
let(:user_locked_context?) { false }
def shadow_entry
- etc_shadow.lines.select {|l| l.include?(username) }.first
+ etc_shadow.lines.select { |l| l.include?(username) }.first
end
def shadow_password
@@ -596,7 +591,6 @@ describe Chef::Provider::User::Useradd, metadata do
end
end
-
it "locks the user's password" do
user_account_should_be_locked
end
diff --git a/spec/functional/resource/windows_package_spec.rb b/spec/functional/resource/windows_package_spec.rb
index 02559bcd97..bc508dc526 100644
--- a/spec/functional/resource/windows_package_spec.rb
+++ b/spec/functional/resource/windows_package_spec.rb
@@ -70,7 +70,7 @@ describe Chef::Resource::WindowsPackage, :windows_only, :volatile do
subject { Chef::Resource::WindowsPackage.new(pkg_name, run_context) }
context "multiple versions and a version given to remove" do
- before { subject.version("8.0.56336")}
+ before { subject.version("8.0.56336") }
it "removes specified version" do
subject.run_action(:remove)
@@ -127,7 +127,7 @@ describe Chef::Resource::WindowsPackage, :windows_only, :volatile do
let(:pkg_name) { "Ultra Defragmenter" }
let(:pkg_path) { "http://iweb.dl.sourceforge.net/project/ultradefrag/stable-release/6.1.1/ultradefrag-6.1.1.bin.amd64.exe" }
let(:pkg_checksum) { "11d53ed4c426c8c867ad43f142b7904226ffd9938c02e37086913620d79e3c09" }
-
+
it "finds the correct installer type" do
subject.run_action(:install)
expect(subject.provider_for_action(:install).installer_type).to eq(:nsis)
@@ -164,5 +164,5 @@ describe Chef::Resource::WindowsPackage, :windows_only, :volatile do
subject.run_action(:remove)
expect(subject).to be_updated_by_last_action
end
- end
-end \ No newline at end of file
+ end
+end
diff --git a/spec/functional/resource/windows_service_spec.rb b/spec/functional/resource/windows_service_spec.rb
index 6e19998995..80faaece34 100644
--- a/spec/functional/resource/windows_service_spec.rb
+++ b/spec/functional/resource/windows_service_spec.rb
@@ -23,9 +23,9 @@ describe Chef::Resource::WindowsService, :windows_only, :system_windows_service_
include_context "using Win32::Service"
- let(:username) { "service_spec_user"}
- let(:qualified_username) { "#{ENV['COMPUTERNAME']}\\#{username}"}
- let(:password) { "1a2b3c4X!&narf"}
+ let(:username) { "service_spec_user" }
+ let(:qualified_username) { "#{ENV['COMPUTERNAME']}\\#{username}" }
+ let(:password) { "1a2b3c4X!&narf" }
let(:user_resource) {
r = Chef::Resource::User.new(username, run_context)