diff options
Diffstat (limited to 'spec/unit/resource')
25 files changed, 107 insertions, 116 deletions
diff --git a/spec/unit/resource/conditional_spec.rb b/spec/unit/resource/conditional_spec.rb index ee4a66f8d5..b34b4200e6 100644 --- a/spec/unit/resource/conditional_spec.rb +++ b/spec/unit/resource/conditional_spec.rb @@ -28,7 +28,7 @@ describe Chef::Resource::Conditional do end it "raises an exception when neither a block or command is given" do - expect { Chef::Resource::Conditional.send(:new, :always, @parent_resource, nil, {})}.to raise_error(ArgumentError, /requires either a command or a block/) + expect { Chef::Resource::Conditional.send(:new, :always, @parent_resource, nil, {}) }.to raise_error(ArgumentError, /requires either a command or a block/) end it "does not evaluate a guard interpreter on initialization of the conditional" do @@ -171,7 +171,7 @@ describe Chef::Resource::Conditional do describe "after running a command which timed out" do before do - @conditional = Chef::Resource::Conditional.not_if(@parent_resource, "false") + @conditional = Chef::Resource::Conditional.not_if(@parent_resource, "false") allow_any_instance_of(Chef::GuardInterpreter::DefaultGuardInterpreter).to receive(:shell_out).and_raise(Chef::Exceptions::CommandTimeout) end diff --git a/spec/unit/resource/cookbook_file_spec.rb b/spec/unit/resource/cookbook_file_spec.rb index ca49320503..6886ce1f31 100644 --- a/spec/unit/resource/cookbook_file_spec.rb +++ b/spec/unit/resource/cookbook_file_spec.rb @@ -48,28 +48,27 @@ describe Chef::Resource::CookbookFile do describe "when it has a backup number, group, mode, owner, source, checksum, and cookbook on nix or path, rights, deny_rights, checksum on windows" do before do - if Chef::Platform.windows? - @cookbook_file.path("C:/temp/origin/file.txt") - @cookbook_file.rights(:read, "Everyone") - @cookbook_file.deny_rights(:full_control, "Clumsy_Sam") - else - @cookbook_file.path("/tmp/origin/file.txt") - @cookbook_file.group("wheel") - @cookbook_file.mode("0664") - @cookbook_file.owner("root") - @cookbook_file.source("/tmp/foo.txt") - @cookbook_file.cookbook("/tmp/cookbooks/cooked.rb") - end + if Chef::Platform.windows? + @cookbook_file.path("C:/temp/origin/file.txt") + @cookbook_file.rights(:read, "Everyone") + @cookbook_file.deny_rights(:full_control, "Clumsy_Sam") + else + @cookbook_file.path("/tmp/origin/file.txt") + @cookbook_file.group("wheel") + @cookbook_file.mode("0664") + @cookbook_file.owner("root") + @cookbook_file.source("/tmp/foo.txt") + @cookbook_file.cookbook("/tmp/cookbooks/cooked.rb") + end @cookbook_file.checksum("1" * 64) end - it "describes the state" do state = @cookbook_file.state if Chef::Platform.windows? puts state - expect(state[:rights]).to eq([{:permissions => :read, :principals => "Everyone"}]) - expect(state[:deny_rights]).to eq([{:permissions => :full_control, :principals => "Clumsy_Sam"}]) + expect(state[:rights]).to eq([{ :permissions => :read, :principals => "Everyone" }]) + expect(state[:deny_rights]).to eq([{ :permissions => :full_control, :principals => "Clumsy_Sam" }]) else expect(state[:group]).to eq("wheel") expect(state[:mode]).to eq("0664") diff --git a/spec/unit/resource/cron_spec.rb b/spec/unit/resource/cron_spec.rb index ad2ec08bb2..037bbaf733 100644 --- a/spec/unit/resource/cron_spec.rb +++ b/spec/unit/resource/cron_spec.rb @@ -100,7 +100,7 @@ describe Chef::Resource::Cron do end it "should allow you to specify environment variables hash" do - env = {"TEST" => "LOL"} + env = { "TEST" => "LOL" } @resource.environment env expect(@resource.environment).to eql(env) end diff --git a/spec/unit/resource/deploy_spec.rb b/spec/unit/resource/deploy_spec.rb index bd9d8295a4..0eeb51c8a0 100644 --- a/spec/unit/resource/deploy_spec.rb +++ b/spec/unit/resource/deploy_spec.rb @@ -28,17 +28,16 @@ describe Chef::Resource::Deploy do action: :deploy, ) - class << self def resource_has_a_string_attribute(attr_name) it "has a String attribute for #{attr_name}" do @resource.send(attr_name, "this is a string") expect(@resource.send(attr_name)).to eql("this is a string") - expect {@resource.send(attr_name, 8675309)}.to raise_error(ArgumentError) + expect { @resource.send(attr_name, 8675309) }.to raise_error(ArgumentError) end end - def resource_has_a_boolean_attribute(attr_name, opts={:defaults_to=>false}) + def resource_has_a_boolean_attribute(attr_name, opts = { :defaults_to => false }) it "has a Boolean attribute for #{attr_name}" do expect(@resource.send(attr_name)).to eql(opts[:defaults_to]) @resource.send(attr_name, !opts[:defaults_to]) @@ -49,12 +48,12 @@ describe Chef::Resource::Deploy do def resource_has_a_callback_attribute(attr_name) it "has a Callback attribute #{attr_name}" do callback_block = lambda { :noop } - expect {@resource.send(attr_name, &callback_block)}.not_to raise_error + expect { @resource.send(attr_name, &callback_block) }.not_to raise_error expect(@resource.send(attr_name)).to eq(callback_block) callback_file = "path/to/callback.rb" - expect {@resource.send(attr_name, callback_file)}.not_to raise_error + expect { @resource.send(attr_name, callback_file) }.not_to raise_error expect(@resource.send(attr_name)).to eq(callback_file) - expect {@resource.send(attr_name, :this_is_fail)}.to raise_error(ArgumentError) + expect { @resource.send(attr_name, :this_is_fail) }.to raise_error(ArgumentError) end end end @@ -80,9 +79,9 @@ describe Chef::Resource::Deploy do resource_has_a_string_attribute(:svn_arguments) resource_has_a_string_attribute(:svn_info_args) - resource_has_a_boolean_attribute(:migrate, :defaults_to=>false) - resource_has_a_boolean_attribute(:enable_submodules, :defaults_to=>false) - resource_has_a_boolean_attribute(:shallow_clone, :defaults_to=>false) + resource_has_a_boolean_attribute(:migrate, :defaults_to => false) + resource_has_a_boolean_attribute(:enable_submodules, :defaults_to => false) + resource_has_a_boolean_attribute(:shallow_clone, :defaults_to => false) it "uses the first argument as the deploy directory" do expect(@resource.deploy_to).to eql("/my/deploy/dir") @@ -118,17 +117,17 @@ describe Chef::Resource::Deploy do expect(@resource.svn_force_export).to be_falsey @resource.svn_force_export true expect(@resource.svn_force_export).to be_truthy - expect {@resource.svn_force_export(10053)}.to raise_error(ArgumentError) + expect { @resource.svn_force_export(10053) }.to raise_error(ArgumentError) end it "takes arbitrary environment variables in a hash" do @resource.environment "RAILS_ENV" => "production" - expect(@resource.environment).to eq({"RAILS_ENV" => "production"}) + expect(@resource.environment).to eq({ "RAILS_ENV" => "production" }) end it "takes string arguments to environment for backwards compat, setting RAILS_ENV, RACK_ENV, and MERB_ENV" do @resource.environment "production" - expect(@resource.environment).to eq({"RAILS_ENV"=>"production", "RACK_ENV"=>"production","MERB_ENV"=>"production"}) + expect(@resource.environment).to eq({ "RAILS_ENV" => "production", "RACK_ENV" => "production", "MERB_ENV" => "production" }) end it "sets destination to $deploy_to/shared/$repository_cache" do @@ -183,16 +182,16 @@ describe Chef::Resource::Deploy do end it 'has a Hash attribute symlinks, default: {"system" => "public/system", "pids" => "tmp/pids", "log" => "log"}' do - default = { "system" => "public/system", "pids" => "tmp/pids", "log" => "log"} + default = { "system" => "public/system", "pids" => "tmp/pids", "log" => "log" } expect(@resource.symlinks).to eq(default) @resource.symlinks "foo" => "bar/baz" - expect(@resource.symlinks).to eq({"foo" => "bar/baz"}) + expect(@resource.symlinks).to eq({ "foo" => "bar/baz" }) end it 'has a Hash attribute symlink_before_migrate, default "config/database.yml" => "config/database.yml"' do - expect(@resource.symlink_before_migrate).to eq({"config/database.yml" => "config/database.yml"}) + expect(@resource.symlink_before_migrate).to eq({ "config/database.yml" => "config/database.yml" }) @resource.symlink_before_migrate "wtf?" => "wtf is going on" - expect(@resource.symlink_before_migrate).to eq({"wtf?" => "wtf is going on"}) + expect(@resource.symlink_before_migrate).to eq({ "wtf?" => "wtf is going on" }) end resource_has_a_callback_attribute :before_migrate @@ -206,7 +205,7 @@ describe Chef::Resource::Deploy do end it "takes a block for the restart parameter" do - restart_like_this = lambda {p :noop} + restart_like_this = lambda { p :noop } @resource.restart(&restart_like_this) expect(@resource.restart).to eq(restart_like_this) end @@ -264,8 +263,8 @@ describe Chef::Resource::Deploy do @resource.group("pokemon") @resource.scm_provider(Chef::Provider::Git) @resource.repository_cache("cached-copy") - @resource.environment({"SUDO" => "TRUE"}) - @resource.symlinks({"system" => "public/system"}) + @resource.environment({ "SUDO" => "TRUE" }) + @resource.symlinks({ "system" => "public/system" }) @resource.migrate(false) end diff --git a/spec/unit/resource/dsc_resource_spec.rb b/spec/unit/resource/dsc_resource_spec.rb index ebedd55dec..64f5f50e5e 100644 --- a/spec/unit/resource/dsc_resource_spec.rb +++ b/spec/unit/resource/dsc_resource_spec.rb @@ -40,7 +40,7 @@ describe Chef::Resource::DscResource do end it "has an ed_actions attribute with only the `:run` and `:nothing` attributes" do - expect(dsc_test_resource.allowed_actions.to_set).to eq([:run,:nothing].to_set) + expect(dsc_test_resource.allowed_actions.to_set).to eq([:run, :nothing].to_set) end it "allows the resource attribute to be set" do diff --git a/spec/unit/resource/dsc_script_spec.rb b/spec/unit/resource/dsc_script_spec.rb index 7139405f38..55473e3146 100644 --- a/spec/unit/resource/dsc_script_spec.rb +++ b/spec/unit/resource/dsc_script_spec.rb @@ -31,8 +31,8 @@ describe Chef::Resource::DscScript do let(:dsc_test_resource) { Chef::Resource::DscScript.new(dsc_test_resource_name, dsc_test_run_context) } - let(:configuration_code) {'echo "This is supposed to create a configuration document."'} - let(:configuration_path) {"c:/myconfigs/formatc.ps1"} + let(:configuration_code) { 'echo "This is supposed to create a configuration document."' } + let(:configuration_path) { "c:/myconfigs/formatc.ps1" } let(:configuration_name) { "formatme" } let(:configuration_data) { '@{AllNodes = @( @{ NodeName = "localhost"; PSDscAllowPlainTextPassword = $true })}' } let(:configuration_data_script) { "c:/myconfigs/data/safedata.psd1" } @@ -42,7 +42,7 @@ describe Chef::Resource::DscScript do end it "has an allowed_actions attribute with only the `:run` and `:nothing` attributes" do - expect(dsc_test_resource.allowed_actions.to_set).to eq([:run,:nothing].to_set) + expect(dsc_test_resource.allowed_actions.to_set).to eq([:run, :nothing].to_set) end it "allows the code attribute to be set" do diff --git a/spec/unit/resource/env_spec.rb b/spec/unit/resource/env_spec.rb index f9719689c5..cff862b69e 100644 --- a/spec/unit/resource/env_spec.rb +++ b/spec/unit/resource/env_spec.rb @@ -38,7 +38,7 @@ describe Chef::Resource::Env do expect(@resource.action).to eql([:create]) end - { :create => false, :delete => false, :modify => false, :flibber => true }.each do |action,bad_value| + { :create => false, :delete => false, :modify => false, :flibber => true }.each do |action, bad_value| it "should #{bad_value ? 'not' : ''} accept #{action}" do if bad_value expect { @resource.action action }.to raise_error(ArgumentError) diff --git a/spec/unit/resource/file/verification_spec.rb b/spec/unit/resource/file/verification_spec.rb index b27d8ca754..f55f6416aa 100644 --- a/spec/unit/resource/file/verification_spec.rb +++ b/spec/unit/resource/file/verification_spec.rb @@ -21,7 +21,7 @@ require "spec_helper" describe Chef::Resource::File::Verification do let(:t_block) { Proc.new { true } } let(:f_block) { Proc.new { false } } - let(:path_block) { Proc.new { |path| path }} + let(:path_block) { Proc.new { |path| path } } let(:temp_path) { "/tmp/foobar" } describe "verification registration" do @@ -33,7 +33,7 @@ describe Chef::Resource::File::Verification do end it "raises an error if a verification can't be found" do - expect{Chef::Resource::File::Verification.lookup(:dne)}.to raise_error(Chef::Exceptions::VerificationNotFound) + expect { Chef::Resource::File::Verification.lookup(:dne) }.to raise_error(Chef::Exceptions::VerificationNotFound) end end @@ -42,13 +42,13 @@ describe Chef::Resource::File::Verification do it "expects a string argument" do v = Chef::Resource::File::Verification.new(parent_resource, nil, {}) {} - expect{ v.verify("/foo/bar") }.to_not raise_error - expect{ v.verify }.to raise_error + expect { v.verify("/foo/bar") }.to_not raise_error + expect { v.verify }.to raise_error end it "accepts an options hash" do v = Chef::Resource::File::Verification.new(parent_resource, nil, {}) {} - expect{ v.verify("/foo/bar", {:future => true}) }.to_not raise_error + expect { v.verify("/foo/bar", { :future => true }) }.to_not raise_error end context "with a verification block" do diff --git a/spec/unit/resource/file_spec.rb b/spec/unit/resource/file_spec.rb index f5b576c0f5..c93a213480 100644 --- a/spec/unit/resource/file_spec.rb +++ b/spec/unit/resource/file_spec.rb @@ -67,11 +67,11 @@ describe Chef::Resource::File do end it "should accept a block, symbol, or string for verify" do - expect {@resource.verify {}}.not_to raise_error - expect {@resource.verify ""}.not_to raise_error - expect {@resource.verify :json}.not_to raise_error - expect {@resource.verify true}.to raise_error - expect {@resource.verify false}.to raise_error + expect { @resource.verify {} }.not_to raise_error + expect { @resource.verify "" }.not_to raise_error + expect { @resource.verify :json }.not_to raise_error + expect { @resource.verify true }.to raise_error + expect { @resource.verify false }.to raise_error end it "should accept multiple verify statements" do @@ -122,8 +122,8 @@ describe Chef::Resource::File do end it "describes its state including windows ACL attributes" do state = @resource.state - expect(state[:rights]).to eq([ {:permissions => :read, :principals => "Everyone"}, - {:permissions => :full_control, :principals => "DOMAIN\User"} ]) + expect(state[:rights]).to eq([ { :permissions => :read, :principals => "Everyone" }, + { :permissions => :full_control, :principals => "DOMAIN\User" } ]) end end diff --git a/spec/unit/resource/freebsd_package_spec.rb b/spec/unit/resource/freebsd_package_spec.rb index 97966de2af..0842114c47 100644 --- a/spec/unit/resource/freebsd_package_spec.rb +++ b/spec/unit/resource/freebsd_package_spec.rb @@ -29,7 +29,6 @@ describe Chef::Resource::FreebsdPackage do @resource = Chef::Resource::FreebsdPackage.new("foo", @run_context) end - describe "Initialization" do it "should return a Chef::Resource::FreebsdPackage" do expect(@resource).to be_a_kind_of(Chef::Resource::FreebsdPackage) @@ -44,7 +43,6 @@ describe Chef::Resource::FreebsdPackage do end end - describe "Assigning provider after creation" do describe "if ports specified as source" do it "should be Freebsd::Port" do @@ -87,4 +85,3 @@ describe Chef::Resource::FreebsdPackage do end end end - diff --git a/spec/unit/resource/http_request_spec.rb b/spec/unit/resource/http_request_spec.rb index 8a5745a1af..318a154b88 100644 --- a/spec/unit/resource/http_request_spec.rb +++ b/spec/unit/resource/http_request_spec.rb @@ -48,7 +48,7 @@ describe Chef::Resource::HttpRequest do before do @resource.url("http://www.trololol.net") @resource.message("Get sum post brah.") - @resource.headers({"head" => "tail"}) + @resource.headers({ "head" => "tail" }) end it "returns the url as its identity" do diff --git a/spec/unit/resource/link_spec.rb b/spec/unit/resource/link_spec.rb index dfd98eb16e..bd0976d8ea 100644 --- a/spec/unit/resource/link_spec.rb +++ b/spec/unit/resource/link_spec.rb @@ -39,7 +39,7 @@ describe Chef::Resource::Link do expect(@resource.action).to eql([:create]) end - { :create => false, :delete => false, :blues => true }.each do |action,bad_value| + { :create => false, :delete => false, :blues => true }.each do |action, bad_value| it "should #{bad_value ? 'not' : ''} accept #{action}" do if bad_value expect { @resource.action action }.to raise_error(ArgumentError) diff --git a/spec/unit/resource/mount_spec.rb b/spec/unit/resource/mount_spec.rb index 53efb055e8..ea20511990 100644 --- a/spec/unit/resource/mount_spec.rb +++ b/spec/unit/resource/mount_spec.rb @@ -92,12 +92,12 @@ describe Chef::Resource::Mount do end it "should allow options to be sent as a delayed evaluator" do - @resource.options Chef::DelayedEvaluator.new {["rw", "noexec"]} + @resource.options Chef::DelayedEvaluator.new { ["rw", "noexec"] } expect(@resource.options).to eql(["rw", "noexec"]) end it "should allow options to be sent as a delayed evaluator, and convert to array" do - @resource.options Chef::DelayedEvaluator.new {"rw,noexec"} + @resource.options Chef::DelayedEvaluator.new { "rw,noexec" } expect(@resource.options).to be_a_kind_of(Array) expect(@resource.options).to eql(["rw", "noexec"]) end diff --git a/spec/unit/resource/ohai_spec.rb b/spec/unit/resource/ohai_spec.rb index 0d1d5efd5b..9669ef193d 100644 --- a/spec/unit/resource/ohai_spec.rb +++ b/spec/unit/resource/ohai_spec.rb @@ -58,5 +58,4 @@ describe Chef::Resource::Ohai do end end - end diff --git a/spec/unit/resource/openbsd_package_spec.rb b/spec/unit/resource/openbsd_package_spec.rb index 840cabf1fe..9bdc823576 100644 --- a/spec/unit/resource/openbsd_package_spec.rb +++ b/spec/unit/resource/openbsd_package_spec.rb @@ -46,4 +46,3 @@ describe Chef::Resource::OpenbsdPackage do end end - diff --git a/spec/unit/resource/osx_profile_spec.rb b/spec/unit/resource/osx_profile_spec.rb index a244048878..7bd504d414 100644 --- a/spec/unit/resource/osx_profile_spec.rb +++ b/spec/unit/resource/osx_profile_spec.rb @@ -38,8 +38,8 @@ describe Chef::Resource::OsxProfile do end it "should accept install and remove as actions" do - expect { resource.action :install}.not_to raise_error - expect { resource.action :remove}.not_to raise_error + expect { resource.action :install }.not_to raise_error + expect { resource.action :remove }.not_to raise_error end it "should allow you to set the profile attribute" do diff --git a/spec/unit/resource/package_spec.rb b/spec/unit/resource/package_spec.rb index ef8f6cce53..dbd76d2eba 100644 --- a/spec/unit/resource/package_spec.rb +++ b/spec/unit/resource/package_spec.rb @@ -50,8 +50,8 @@ describe Chef::Resource::Package do end it "should accept a hash for response file template variables" do - @resource.response_file_variables({:variables => true}) - expect(@resource.response_file_variables).to eql({:variables => true}) + @resource.response_file_variables({ :variables => true }) + expect(@resource.response_file_variables).to eql({ :variables => true }) end it "should accept a string for the source" do diff --git a/spec/unit/resource/powershell_script_spec.rb b/spec/unit/resource/powershell_script_spec.rb index 3cb5e1b5a9..f1a9215caa 100644 --- a/spec/unit/resource/powershell_script_spec.rb +++ b/spec/unit/resource/powershell_script_spec.rb @@ -49,7 +49,7 @@ describe Chef::Resource::PowershellScript do it "raises an error when architecture is i386 on Windows Nano Server" do allow(Chef::Platform).to receive(:windows_nano_server?).and_return(true) - expect{@resource.architecture(:i386)}.to raise_error(Chef::Exceptions::Win32ArchitectureIncorrect, "cannot execute script with requested architecture 'i386' on Windows Nano Server") + expect { @resource.architecture(:i386) }.to raise_error(Chef::Exceptions::Win32ArchitectureIncorrect, "cannot execute script with requested architecture 'i386' on Windows Nano Server") end context "when using guards" do @@ -61,7 +61,7 @@ describe Chef::Resource::PowershellScript do it "inherits exactly the :cwd, :environment, :group, :path, :user, :umask, and :architecture attributes from a parent resource class" do inherited_difference = Chef::Resource::PowershellScript.guard_inherited_attributes - - [:cwd, :environment, :group, :path, :user, :umask, :architecture ] + [:cwd, :environment, :group, :path, :user, :umask, :architecture ] expect(inherited_difference).to eq([]) end @@ -87,7 +87,7 @@ describe Chef::Resource::PowershellScript do it "enables convert_boolean_return by default for guards in the context of powershell_script when no guard params are specified" do allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:evaluate_action).and_return(true) allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with( - {:convert_boolean_return => true, :code => "$true"}).and_return(Proc.new {}) + { :convert_boolean_return => true, :code => "$true" }).and_return(Proc.new {}) resource.only_if("$true") end @@ -98,27 +98,27 @@ describe Chef::Resource::PowershellScript do file_resource.guard_interpreter :powershell_script allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with( - {:convert_boolean_return => true, :code => "$true"}).and_return(Proc.new {}) + { :convert_boolean_return => true, :code => "$true" }).and_return(Proc.new {}) resource.only_if("$true") end it "enables convert_boolean_return by default for guards in the context of powershell_script when guard params are specified" do - guard_parameters = {:cwd => "/etc/chef", :architecture => :x86_64} + guard_parameters = { :cwd => "/etc/chef", :architecture => :x86_64 } allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with( - {:convert_boolean_return => true, :code => "$true"}.merge(guard_parameters)).and_return(Proc.new {}) + { :convert_boolean_return => true, :code => "$true" }.merge(guard_parameters)).and_return(Proc.new {}) resource.only_if("$true", guard_parameters) end it "passes convert_boolean_return as true if it was specified as true in a guard parameter" do - guard_parameters = {:cwd => "/etc/chef", :convert_boolean_return => true, :architecture => :x86_64} + guard_parameters = { :cwd => "/etc/chef", :convert_boolean_return => true, :architecture => :x86_64 } allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with( - {:convert_boolean_return => true, :code => "$true"}.merge(guard_parameters)).and_return(Proc.new {}) + { :convert_boolean_return => true, :code => "$true" }.merge(guard_parameters)).and_return(Proc.new {}) resource.only_if("$true", guard_parameters) end it "passes convert_boolean_return as false if it was specified as true in a guard parameter" do - other_guard_parameters = {:cwd => "/etc/chef", :architecture => :x86_64} - parameters_with_boolean_disabled = other_guard_parameters.merge({:convert_boolean_return => false, :code => "$true"}) + other_guard_parameters = { :cwd => "/etc/chef", :architecture => :x86_64 } + parameters_with_boolean_disabled = other_guard_parameters.merge({ :convert_boolean_return => false, :code => "$true" }) allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with( parameters_with_boolean_disabled).and_return(Proc.new {}) resource.only_if("$true", parameters_with_boolean_disabled) diff --git a/spec/unit/resource/registry_key_spec.rb b/spec/unit/resource/registry_key_spec.rb index a2ba6f500d..472c511857 100644 --- a/spec/unit/resource/registry_key_spec.rb +++ b/spec/unit/resource/registry_key_spec.rb @@ -130,7 +130,7 @@ describe Chef::Resource::RegistryKey, "recursive" do end it "should not allow a hash" do - expect { @resource.recursive({:sonic => :screwdriver}) }.to raise_error(ArgumentError) + expect { @resource.recursive({ :sonic => :screwdriver }) }.to raise_error(ArgumentError) end it "should not allow an array" do @@ -159,7 +159,7 @@ describe Chef::Resource::RegistryKey, "architecture" do end it "should not allow a hash" do - expect { @resource.architecture({:sonic => :screwdriver}) }.to raise_error(ArgumentError) + expect { @resource.architecture({ :sonic => :screwdriver }) }.to raise_error(ArgumentError) end it "should not allow an array" do @@ -194,6 +194,6 @@ describe Chef::Resource::RegistryKey, "state" do it "should return scrubbed values" do @resource.values([ { :name => "poosh", :type => :binary, :data => 255.chr * 1 } ]) - expect(@resource.state).to eql( { :values => [{ :name => "poosh", :type => :binary, :data => "a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89"}] } ) + expect(@resource.state).to eql( { :values => [{ :name => "poosh", :type => :binary, :data => "a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89" }] } ) end end diff --git a/spec/unit/resource/remote_file_spec.rb b/spec/unit/resource/remote_file_spec.rb index b511377a51..718129aba3 100644 --- a/spec/unit/resource/remote_file_spec.rb +++ b/spec/unit/resource/remote_file_spec.rb @@ -66,7 +66,7 @@ describe Chef::Resource::RemoteFile do end it "should accept a delayed evalutator (string) for the remote file source" do - @resource.source Chef::DelayedEvaluator.new {"http://opscode.com/"} + @resource.source Chef::DelayedEvaluator.new { "http://opscode.com/" } expect(@resource.source).to eql([ "http://opscode.com/" ]) end @@ -87,13 +87,13 @@ describe Chef::Resource::RemoteFile do it "should only accept a single argument if a delayed evalutor is used" do expect { - @resource.source("http://opscode.com/", Chef::DelayedEvaluator.new {"http://opscode.com/"}) + @resource.source("http://opscode.com/", Chef::DelayedEvaluator.new { "http://opscode.com/" }) }.to raise_error(Chef::Exceptions::InvalidRemoteFileURI) end it "should only accept a single array item if a delayed evalutor is used" do expect { - @resource.source(["http://opscode.com/", Chef::DelayedEvaluator.new {"http://opscode.com/"}]) + @resource.source(["http://opscode.com/", Chef::DelayedEvaluator.new { "http://opscode.com/" }]) }.to raise_error(Chef::Exceptions::InvalidRemoteFileURI) end @@ -103,7 +103,7 @@ describe Chef::Resource::RemoteFile do it "does not accept a non-URI as the source when read from a delayed evaluator" do expect { - @resource.source(Chef::DelayedEvaluator.new {"not-a-uri"}) + @resource.source(Chef::DelayedEvaluator.new { "not-a-uri" }) @resource.source }.to raise_error(Chef::Exceptions::InvalidRemoteFileURI) end @@ -179,20 +179,20 @@ describe Chef::Resource::RemoteFile do @resource.owner("root") end @resource.source("https://www.google.com/images/srpr/logo3w.png") - @resource.checksum("1"*26) + @resource.checksum("1" * 26) end it "describes its state" do state = @resource.state if Chef::Platform.windows? puts state - expect(state[:rights]).to eq([{:permissions => :read, :principals => "Everyone"}]) - expect(state[:deny_rights]).to eq([{:permissions => :full_control, :principals => "Clumsy_Sam"}]) + expect(state[:rights]).to eq([{ :permissions => :read, :principals => "Everyone" }]) + expect(state[:deny_rights]).to eq([{ :permissions => :full_control, :principals => "Clumsy_Sam" }]) else expect(state[:group]).to eq("pokemon") expect(state[:mode]).to eq("0664") expect(state[:owner]).to eq("root") - expect(state[:checksum]).to eq("1"*26) + expect(state[:checksum]).to eq("1" * 26) end end diff --git a/spec/unit/resource/resource_notification_spec.rb b/spec/unit/resource/resource_notification_spec.rb index 5ba6ea35d3..5bb3ba95ea 100644 --- a/spec/unit/resource/resource_notification_spec.rb +++ b/spec/unit/resource/resource_notification_spec.rb @@ -50,7 +50,7 @@ describe Chef::Resource::Notification do end it "raises an ArgumentError if you try to check a non-ducktype object for duplication" do - expect {notification.duplicates?(:not_a_notification)}.to raise_error(ArgumentError) + expect { notification.duplicates?(:not_a_notification) }.to raise_error(ArgumentError) end it "takes no action to resolve a resource reference that doesn't need to be resolved" do @@ -65,7 +65,7 @@ describe Chef::Resource::Notification do end it "resolves a lazy reference to a resource" do - notification.resource = {:cat => "keyboard_cat"} + notification.resource = { :cat => "keyboard_cat" } @keyboard_cat = Chef::Resource::Cat.new("keyboard_cat") @resource_collection = Chef::ResourceCollection.new @resource_collection << @keyboard_cat @@ -78,7 +78,7 @@ describe Chef::Resource::Notification do it "resolves a lazy reference to its notifying resource" do @keyboard_cat = Chef::Resource::Cat.new("keyboard_cat") notification.resource = @keyboard_cat - notification.notifying_resource = {:cat => "long_cat"} + notification.notifying_resource = { :cat => "long_cat" } @long_cat = Chef::Resource::Cat.new("long_cat") @resource_collection = Chef::ResourceCollection.new @resource_collection << @long_cat @@ -87,11 +87,11 @@ describe Chef::Resource::Notification do end it "resolves lazy references to both its resource and its notifying resource" do - notification.resource = {:cat => "keyboard_cat"} + notification.resource = { :cat => "keyboard_cat" } @keyboard_cat = Chef::Resource::Cat.new("keyboard_cat") @resource_collection = Chef::ResourceCollection.new @resource_collection << @keyboard_cat - notification.notifying_resource = {:cat => "long_cat"} + notification.notifying_resource = { :cat => "long_cat" } @long_cat = Chef::Resource::Cat.new("long_cat") @resource_collection << @long_cat notification.resolve_resource_reference(@resource_collection) @@ -100,7 +100,7 @@ describe Chef::Resource::Notification do end it "raises a RuntimeError if you try to reference multiple resources" do - notification.resource = {:cat => ["keyboard_cat", "cheez_cat"]} + notification.resource = { :cat => ["keyboard_cat", "cheez_cat"] } @keyboard_cat = Chef::Resource::Cat.new("keyboard_cat") @cheez_cat = Chef::Resource::Cat.new("cheez_cat") @resource_collection = Chef::ResourceCollection.new @@ -108,11 +108,11 @@ describe Chef::Resource::Notification do @resource_collection << @cheez_cat @long_cat = Chef::Resource::Cat.new("long_cat") notification.notifying_resource = @long_cat - expect {notification.resolve_resource_reference(@resource_collection)}.to raise_error(RuntimeError) + expect { notification.resolve_resource_reference(@resource_collection) }.to raise_error(RuntimeError) end it "raises a RuntimeError if you try to reference multiple notifying resources" do - notification.notifying_resource = {:cat => ["long_cat", "cheez_cat"]} + notification.notifying_resource = { :cat => ["long_cat", "cheez_cat"] } @long_cat = Chef::Resource::Cat.new("long_cat") @cheez_cat = Chef::Resource::Cat.new("cheez_cat") @resource_collection = Chef::ResourceCollection.new @@ -120,27 +120,27 @@ describe Chef::Resource::Notification do @resource_collection << @cheez_cat @keyboard_cat = Chef::Resource::Cat.new("keyboard_cat") notification.resource = @keyboard_cat - expect {notification.resolve_resource_reference(@resource_collection)}.to raise_error(RuntimeError) + expect { notification.resolve_resource_reference(@resource_collection) }.to raise_error(RuntimeError) end it "raises a RuntimeError if it can't find a resource in the resource collection when resolving a lazy reference" do - notification.resource = {:cat => "keyboard_cat"} + notification.resource = { :cat => "keyboard_cat" } @cheez_cat = Chef::Resource::Cat.new("cheez_cat") @resource_collection = Chef::ResourceCollection.new @resource_collection << @cheez_cat @long_cat = Chef::Resource::Cat.new("long_cat") notification.notifying_resource = @long_cat - expect {notification.resolve_resource_reference(@resource_collection)}.to raise_error(RuntimeError) + expect { notification.resolve_resource_reference(@resource_collection) }.to raise_error(RuntimeError) end it "raises a RuntimeError if it can't find a notifying resource in the resource collection when resolving a lazy reference" do - notification.notifying_resource = {:cat => "long_cat"} + notification.notifying_resource = { :cat => "long_cat" } @cheez_cat = Chef::Resource::Cat.new("cheez_cat") @resource_collection = Chef::ResourceCollection.new @resource_collection << @cheez_cat @keyboard_cat = Chef::Resource::Cat.new("keyboard_cat") notification.resource = @keyboard_cat - expect {notification.resolve_resource_reference(@resource_collection)}.to raise_error(RuntimeError) + expect { notification.resolve_resource_reference(@resource_collection) }.to raise_error(RuntimeError) end it "raises an ArgumentError if improper syntax is used in the lazy reference to its resource" do @@ -150,7 +150,7 @@ describe Chef::Resource::Notification do @resource_collection << @keyboard_cat @long_cat = Chef::Resource::Cat.new("long_cat") notification.notifying_resource = @long_cat - expect {notification.resolve_resource_reference(@resource_collection)}.to raise_error(ArgumentError) + expect { notification.resolve_resource_reference(@resource_collection) }.to raise_error(ArgumentError) end it "raises an ArgumentError if improper syntax is used in the lazy reference to its notifying resource" do @@ -160,7 +160,7 @@ describe Chef::Resource::Notification do @resource_collection << @long_cat @keyboard_cat = Chef::Resource::Cat.new("keyboard_cat") notification.resource = @keyboard_cat - expect {notification.resolve_resource_reference(@resource_collection)}.to raise_error(ArgumentError) + expect { notification.resolve_resource_reference(@resource_collection) }.to raise_error(ArgumentError) end # Create test to resolve lazy references to both notifying resource and dest. resource diff --git a/spec/unit/resource/scm_spec.rb b/spec/unit/resource/scm_spec.rb index 8667b244d7..f39334348e 100644 --- a/spec/unit/resource/scm_spec.rb +++ b/spec/unit/resource/scm_spec.rb @@ -101,7 +101,7 @@ describe Chef::Resource::Scm do it "takes the depth as an integer for shallow clones" do @resource.depth 5 expect(@resource.depth).to eq(5) - expect {@resource.depth "five"}.to raise_error(ArgumentError) + expect { @resource.depth "five" }.to raise_error(ArgumentError) end it "defaults to nil depth for a full clone" do @@ -111,7 +111,7 @@ describe Chef::Resource::Scm do it "takes a boolean for #enable_submodules" do @resource.enable_submodules true expect(@resource.enable_submodules).to be_truthy - expect {@resource.enable_submodules "lolz"}.to raise_error(ArgumentError) + expect { @resource.enable_submodules "lolz" }.to raise_error(ArgumentError) end it "defaults to not enabling submodules" do @@ -121,7 +121,7 @@ describe Chef::Resource::Scm do it "takes a boolean for #enable_checkout" do @resource.enable_checkout true expect(@resource.enable_checkout).to be_truthy - expect {@resource.enable_checkout "lolz"}.to raise_error(ArgumentError) + expect { @resource.enable_checkout "lolz" }.to raise_error(ArgumentError) end it "defaults to enabling checkout" do @@ -131,7 +131,7 @@ describe Chef::Resource::Scm do it "takes a string for the remote" do @resource.remote "opscode" expect(@resource.remote).to eql("opscode") - expect {@resource.remote 1337}.to raise_error(ArgumentError) + expect { @resource.remote 1337 }.to raise_error(ArgumentError) end it "defaults to ``origin'' for the remote" do @@ -184,7 +184,7 @@ describe Chef::Resource::Scm do end describe "when it has a environment attribute" do - let(:test_environment) { {"CHEF_ENV" => "/tmp" } } + let(:test_environment) { { "CHEF_ENV" => "/tmp" } } before { @resource.environment(test_environment) } it "stores this environment" do expect(@resource.environment).to eq(test_environment) diff --git a/spec/unit/resource/service_spec.rb b/spec/unit/resource/service_spec.rb index f9953afd53..e06f5bca5e 100644 --- a/spec/unit/resource/service_spec.rb +++ b/spec/unit/resource/service_spec.rb @@ -140,7 +140,7 @@ describe Chef::Resource::Service do end it "should default all the feature support to nil" do - support_hash = { :status => nil, :restart => nil, :reload=> nil } + support_hash = { :status => nil, :restart => nil, :reload => nil } expect(@resource.supports).to eq(support_hash) end @@ -176,5 +176,4 @@ describe Chef::Resource::Service do end end - end diff --git a/spec/unit/resource/template_spec.rb b/spec/unit/resource/template_spec.rb index 19d8b1716f..9060f02d29 100644 --- a/spec/unit/resource/template_spec.rb +++ b/spec/unit/resource/template_spec.rb @@ -127,7 +127,7 @@ describe Chef::Resource::Template do modules = @resource.helper_modules expect(modules.size).to eq(1) o = Object.new - modules.each {|m| o.extend(m)} + modules.each { |m| o.extend(m) } expect(o.example_1).to eq("example_1") expect(o.example_2).to eq("example_2") end @@ -136,7 +136,7 @@ describe Chef::Resource::Template do @resource.helper(:shout) { |quiet| quiet.upcase } modules = @resource.helper_modules o = Object.new - modules.each {|m| o.extend(m)} + modules.each { |m| o.extend(m) } expect(o.shout("shout")).to eq("SHOUT") end @@ -167,7 +167,7 @@ describe Chef::Resource::Template do modules = @resource.helper_modules expect(modules.size).to eq(1) o = Object.new - modules.each {|m| o.extend(m)} + modules.each { |m| o.extend(m) } expect(o.example_1).to eq("example_1") end @@ -199,13 +199,12 @@ describe Chef::Resource::Template do expect(@resource.helper_modules.size).to eq(3) o = Object.new - @resource.helper_modules.each {|m| o.extend(m)} + @resource.helper_modules.each { |m| o.extend(m) } expect(o.static_example).to eq("static_example") expect(o.inline_module).to eq("inline_module") expect(o.inline_method).to eq("inline_method") end - end end diff --git a/spec/unit/resource/user_spec.rb b/spec/unit/resource/user_spec.rb index 4b26288715..9648ee1305 100644 --- a/spec/unit/resource/user_spec.rb +++ b/spec/unit/resource/user_spec.rb @@ -68,7 +68,7 @@ describe Chef::Resource::User, "initialize" do expect { @resource.username "domain\@user" }.not_to raise_error expect(@resource.username).to eq("domain\@user") expect { @resource.username "domain\\user" }.not_to raise_error - expect(@resource.username).to eq("domain\\user") + expect(@resource.username).to eq("domain\\user") end end |