diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2019-07-02 15:11:54 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2019-07-02 15:11:54 -0700 |
commit | e71560df5cebbfb209089c6255e37e65f0e34d95 (patch) | |
tree | 5cd0a1d01eb9609d7f5681b2e04faa902de67e84 /spec | |
parent | 7a1a6c8ef26c787e4b6dd1602f3d158b37e81720 (diff) | |
download | chef-e71560df5cebbfb209089c6255e37e65f0e34d95.tar.gz |
Style/SymbolArray
start enforcing using %i{} instead of arrays of symbols
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec')
46 files changed, 205 insertions, 205 deletions
diff --git a/spec/functional/file_content_management/deploy_strategies_spec.rb b/spec/functional/file_content_management/deploy_strategies_spec.rb index 9e2131388f..07991aa8bd 100644 --- a/spec/functional/file_content_management/deploy_strategies_spec.rb +++ b/spec/functional/file_content_management/deploy_strategies_spec.rb @@ -175,20 +175,20 @@ end describe Chef::FileContentManagement::Deploy::Cp do let(:unix_invariants) do - [ - :uid, - :gid, - :mode, - :ino, - ] + %i{ + uid + gid + mode + ino + } end let(:security_descriptor_invariants) do - [ - :owner, - :group, - :dacl, - ] + %i{ + owner + group + dacl + } end it_should_behave_like "a content deploy strategy" @@ -198,11 +198,11 @@ end describe Chef::FileContentManagement::Deploy::MvUnix, :unix_only do let(:unix_invariants) do - [ - :uid, - :gid, - :mode, - ] + %i{ + uid + gid + mode + } end it_should_behave_like "a content deploy strategy" @@ -216,11 +216,11 @@ describe Chef::FileContentManagement::Deploy::MvWindows, :windows_only do context "when a file has no sacl" do let(:security_descriptor_invariants) do - [ - :owner, - :group, - :dacl, - ] + %i{ + owner + group + dacl + } end it_should_behave_like "a content deploy strategy" diff --git a/spec/functional/mixin/user_context_spec.rb b/spec/functional/mixin/user_context_spec.rb index 5beed18166..b6b8b057d5 100644 --- a/spec/functional/mixin/user_context_spec.rb +++ b/spec/functional/mixin/user_context_spec.rb @@ -26,7 +26,7 @@ describe Chef::Mixin::UserContext, windows_only: true do let(:get_user_name_a) do FFI.ffi_lib "advapi32.dll" - FFI.attach_function :GetUserNameA, [ :pointer, :pointer ], :bool + FFI.attach_function :GetUserNameA, %i{pointer pointer}, :bool end let(:process_username) do diff --git a/spec/functional/resource/reboot_spec.rb b/spec/functional/resource/reboot_spec.rb index 3b8e3efe8a..5489dc1c72 100644 --- a/spec/functional/resource/reboot_spec.rb +++ b/spec/functional/resource/reboot_spec.rb @@ -45,7 +45,7 @@ describe Chef::Resource::Reboot do shared_context "testing run context modification" do def test_reboot_action(resource) reboot_info = resource.run_context.reboot_info - expect(reboot_info.keys.sort).to eq([:delay_mins, :reason, :requested_by, :timestamp]) + expect(reboot_info.keys.sort).to eq(%i{delay_mins reason requested_by timestamp}) expect(reboot_info[:delay_mins]).to eq(expected[:delay_mins]) expect(reboot_info[:reason]).to eq(expected[:reason]) expect(reboot_info[:requested_by]).to eq(expected[:requested_by]) diff --git a/spec/functional/resource/windows_service_spec.rb b/spec/functional/resource/windows_service_spec.rb index f422ac21d6..3e46e8c2d0 100644 --- a/spec/functional/resource/windows_service_spec.rb +++ b/spec/functional/resource/windows_service_spec.rb @@ -59,7 +59,7 @@ describe Chef::Resource::WindowsService, :windows_only, :system_windows_service_ let(:service_resource) do r = Chef::Resource::WindowsService.new(service_params[:service_name], run_context) - [:run_as_user, :run_as_password].each { |prop| r.send(prop, service_params[prop]) } + %i{run_as_user run_as_password}.each { |prop| r.send(prop, service_params[prop]) } r end diff --git a/spec/functional/win32/security_spec.rb b/spec/functional/win32/security_spec.rb index 92ce480d25..c72da9ce6c 100644 --- a/spec/functional/win32/security_spec.rb +++ b/spec/functional/win32/security_spec.rb @@ -131,7 +131,7 @@ describe "Chef::Win32::Security", :windows_only do end context "when the token is valid" do - let(:token_elevation_type) { [:TokenElevationTypeDefault, :TokenElevationTypeFull, :TokenElevationTypeLimited] } + let(:token_elevation_type) { %i{TokenElevationTypeDefault TokenElevationTypeFull TokenElevationTypeLimited} } it "returns the token elevation type" do elevation_type = Chef::ReservedNames::Win32::Security.get_token_information_elevation_type(token) diff --git a/spec/functional/win32/service_manager_spec.rb b/spec/functional/win32/service_manager_spec.rb index 8fff73396e..abc8118835 100644 --- a/spec/functional/win32/service_manager_spec.rb +++ b/spec/functional/win32/service_manager_spec.rb @@ -43,7 +43,7 @@ describe "Chef::Application::WindowsServiceManager", :windows_only, :system_wind end it "throws an error with required missing options" do - [:service_name, :service_display_name, :service_description, :service_file_path].each do |key| + %i{service_name service_display_name service_description service_file_path}.each do |key| service_def = test_service.dup service_def.delete(key) diff --git a/spec/integration/recipes/lwrp_inline_resources_spec.rb b/spec/integration/recipes/lwrp_inline_resources_spec.rb index 6bc857df48..d978a18e3e 100644 --- a/spec/integration/recipes/lwrp_inline_resources_spec.rb +++ b/spec/integration/recipes/lwrp_inline_resources_spec.rb @@ -53,7 +53,7 @@ describe "LWRPs with inline resources" do action :fiddle do file PATH do content new_resource.content - action [:create, :delete] + action %i{create delete} end end end diff --git a/spec/integration/recipes/recipe_dsl_spec.rb b/spec/integration/recipes/recipe_dsl_spec.rb index 0250786f0e..6c0cc305f9 100644 --- a/spec/integration/recipes/recipe_dsl_spec.rb +++ b/spec/integration/recipes/recipe_dsl_spec.rb @@ -1340,10 +1340,10 @@ describe "Recipe DSL methods" do resource_class.new("blah", run_context) end it "The actions are part of actions along with :nothing" do - expect(resource_class.actions).to eq [ :nothing, :create ] + expect(resource_class.actions).to eq %i{nothing create} end it "The actions are part of allowed_actions along with :nothing" do - expect(resource.allowed_actions).to eq [ :nothing, :create ] + expect(resource.allowed_actions).to eq %i{nothing create} end context "and a subclass that declares more actions" do @@ -1358,14 +1358,14 @@ describe "Recipe DSL methods" do end it "The parent class actions are not part of actions" do - expect(subresource_class.actions).to eq [ :nothing, :delete ] + expect(subresource_class.actions).to eq %i{nothing delete} end it "The parent class actions are not part of allowed_actions" do - expect(subresource.allowed_actions).to eq [ :nothing, :delete ] + expect(subresource.allowed_actions).to eq %i{nothing delete} end it "The parent class actions do not change" do - expect(resource_class.actions).to eq [ :nothing, :create ] - expect(resource.allowed_actions).to eq [ :nothing, :create ] + expect(resource_class.actions).to eq %i{nothing create} + expect(resource.allowed_actions).to eq %i{nothing create} end end end diff --git a/spec/support/shared/unit/file_system_support.rb b/spec/support/shared/unit/file_system_support.rb index d27c90a7c3..80cc7cdc23 100644 --- a/spec/support/shared/unit/file_system_support.rb +++ b/spec/support/shared/unit/file_system_support.rb @@ -56,7 +56,7 @@ module FileSystemSupport def no_blocking_calls_allowed [ Chef::ChefFS::FileSystem::Memory::MemoryFile, Chef::ChefFS::FileSystem::Memory::MemoryDir ].each do |c| - [ :children, :exists?, :read ].each do |m| + %i{children exists? read}.each do |m| allow_any_instance_of(c).to receive(m).and_raise("#{m} should not be called") end end diff --git a/spec/support/shared/unit/platform_introspector.rb b/spec/support/shared/unit/platform_introspector.rb index 7b9cc0f94e..0354c3a33c 100644 --- a/spec/support/shared/unit/platform_introspector.rb +++ b/spec/support/shared/unit/platform_introspector.rb @@ -36,7 +36,7 @@ shared_examples_for "a platform introspector" do @platform_family_hash = { "debian" => "debian value", - [:rhel, :fedora] => "redhatty value", + %i{rhel fedora} => "redhatty value", "suse" => "suse value", :default => "default value", } @@ -125,7 +125,7 @@ shared_examples_for "a platform introspector" do it "returns true if the node is a provided platform and platforms are provided as symbols" do node.automatic_attrs[:platform] = "ubuntu" - expect(platform_introspector.platform?([:redhat, :ubuntu])).to eq(true) + expect(platform_introspector.platform?(%i{redhat ubuntu})).to eq(true) end it "returns true if the node is a provided platform and platforms are provided as strings" do @@ -143,7 +143,7 @@ shared_examples_for "a platform introspector" do it "returns true if the node is in a provided platform family and families are provided as symbols" do node.automatic_attrs[:platform_family] = "debian" - expect(platform_introspector.platform_family?([:rhel, :debian])).to eq(true) + expect(platform_introspector.platform_family?(%i{rhel debian})).to eq(true) end it "returns true if the node is a provided platform and platforms are provided as strings" do @@ -165,24 +165,24 @@ shared_examples_for "a platform introspector" do describe "when the value is an array" do before do @platform_hash = { - "debian" => { "4.0" => [ :restart, :reload ], "default" => [ :restart, :reload, :status ] }, - "ubuntu" => { "default" => [ :restart, :reload, :status ] }, - "centos" => { "default" => [ :restart, :reload, :status ] }, - "redhat" => { "default" => [ :restart, :reload, :status ] }, - "fedora" => { "default" => [ :restart, :reload, :status ] }, - "default" => { "default" => [:restart, :reload ] } } + "debian" => { "4.0" => %i{restart reload}, "default" => %i{restart reload status} }, + "ubuntu" => { "default" => %i{restart reload status} }, + "centos" => { "default" => %i{restart reload status} }, + "redhat" => { "default" => %i{restart reload status} }, + "fedora" => { "default" => %i{restart reload status} }, + "default" => { "default" => %i{restart reload} } } end it "returns the correct default for a given platform" do node.automatic_attrs[:platform] = "debian" node.automatic_attrs[:platform_version] = "9000" - expect(platform_introspector.value_for_platform(@platform_hash)).to eq([ :restart, :reload, :status ]) + expect(platform_introspector.value_for_platform(@platform_hash)).to eq(%i{restart reload status}) end it "returns the correct platform+version specific value " do node.automatic_attrs[:platform] = "debian" node.automatic_attrs[:platform_version] = "4.0" - expect(platform_introspector.value_for_platform(@platform_hash)).to eq([:restart, :reload]) + expect(platform_introspector.value_for_platform(@platform_hash)).to eq(%i{restart reload}) end end diff --git a/spec/support/shared/unit/provider/file.rb b/spec/support/shared/unit/provider/file.rb index b3039f9be4..2771a371d4 100644 --- a/spec/support/shared/unit/provider/file.rb +++ b/spec/support/shared/unit/provider/file.rb @@ -417,7 +417,7 @@ shared_examples_for Chef::Provider::File do context "when the enclosing directory does not exist" do before { setup_missing_enclosing_directory } - [:create, :create_if_missing, :touch].each do |action| + %i{create create_if_missing touch}.each do |action| context "action #{action}" do it "raises EnclosingDirectoryDoesNotExist" do expect { provider.run_action(action) }.to raise_error(Chef::Exceptions::EnclosingDirectoryDoesNotExist) diff --git a/spec/support/shared/unit/script_resource.rb b/spec/support/shared/unit/script_resource.rb index 5c4f6eecbb..83d7d9dfe6 100644 --- a/spec/support/shared/unit/script_resource.rb +++ b/spec/support/shared/unit/script_resource.rb @@ -66,7 +66,7 @@ shared_examples_for "a script resource" do it "inherits exactly the :cwd, :environment, :group, :path, :user, and :umask attributes from a parent resource class" do inherited_difference = Chef::Resource::Script.guard_inherited_attributes - - [:cwd, :environment, :group, :path, :user, :umask ] + %i{cwd environment group path user umask} expect(inherited_difference).to eq([]) end diff --git a/spec/unit/cookbook/metadata_spec.rb b/spec/unit/cookbook/metadata_spec.rb index 8d65efbd6a..7f66fe0c32 100644 --- a/spec/unit/cookbook/metadata_spec.rb +++ b/spec/unit/cookbook/metadata_spec.rb @@ -26,10 +26,10 @@ describe Chef::Cookbook::Metadata do describe "when comparing for equality" do before do - @fields = [ :name, :description, :long_description, :maintainer, - :maintainer_email, :license, :platforms, :dependencies, - :providing, :recipes, :version, :source_url, :issues_url, - :privacy, :ohai_versions, :chef_versions, :gems ] + @fields = %i{name description long_description maintainer + maintainer_email license platforms dependencies + providing recipes version source_url issues_url + privacy ohai_versions chef_versions gems} end it "does not depend on object identity for equality" do diff --git a/spec/unit/data_bag_item_spec.rb b/spec/unit/data_bag_item_spec.rb index 70fcd7041e..7a197b6bc5 100644 --- a/spec/unit/data_bag_item_spec.rb +++ b/spec/unit/data_bag_item_spec.rb @@ -148,12 +148,12 @@ describe Chef::DataBagItem do end it "implements all the methods of Hash" do - methods = [:rehash, :to_hash, :[], :fetch, :[]=, :store, :default, - :default=, :default_proc, :index, :size, :length, - :empty?, :each_value, :each_key, :each_pair, :each, :keys, :values, - :values_at, :delete, :delete_if, :reject!, :clear, - :invert, :update, :replace, :merge!, :merge, :has_key?, :has_value?, - :key?, :value?] + methods = %i{rehash to_hash \[\] fetch \[\]= store default + default= default_proc index size length + empty? each_value each_key each_pair each keys values + values_at delete delete_if reject! clear + invert update replace merge! merge has_key? has_value? + key? value?} methods.each do |m| expect(data_bag_item).to respond_to(m) end diff --git a/spec/unit/dsl/declare_resource_spec.rb b/spec/unit/dsl/declare_resource_spec.rb index 255e85e22e..ead0be2967 100644 --- a/spec/unit/dsl/declare_resource_spec.rb +++ b/spec/unit/dsl/declare_resource_spec.rb @@ -34,7 +34,7 @@ describe Chef::ResourceCollection do describe "mixed in correctly" do it "the resources() method winds up in the right classes" do - methods = [ :resources, :find_resource, :find_resource!, :edit_resource, :edit_resource!, :delete_resource, :delete_resource!, :declare_resource, :build_resource ] + methods = %i{resources find_resource find_resource! edit_resource edit_resource! delete_resource delete_resource! declare_resource build_resource} expect(Chef::Resource.instance_methods).to include(*methods) expect(Chef::Recipe.instance_methods).to include(*methods) expect(Chef::Provider.instance_methods).to include(*methods) diff --git a/spec/unit/dsl/platform_introspection_spec.rb b/spec/unit/dsl/platform_introspection_spec.rb index 51123ba930..7af233a769 100644 --- a/spec/unit/dsl/platform_introspection_spec.rb +++ b/spec/unit/dsl/platform_introspection_spec.rb @@ -40,7 +40,7 @@ describe Chef::DSL::PlatformIntrospection::PlatformDependentValue do before do platform_hash = { :openbsd => { default: "free, functional, secure" }, - [:redhat, :centos, :fedora, :scientific] => { default: '"stable"' }, + %i{redhat centos fedora scientific} => { default: '"stable"' }, :ubuntu => { "10.04" => "using upstart more", :default => "using init more" }, :default => "bork da bork", } @@ -84,7 +84,7 @@ describe Chef::DSL::PlatformIntrospection::PlatformDependentValue do end describe Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue do before do - @array_values = [:stop, :start, :reload] + @array_values = %i{stop start reload} @platform_family_hash = { "debian" => "debian value", diff --git a/spec/unit/event_dispatch/dsl_spec.rb b/spec/unit/event_dispatch/dsl_spec.rb index 979b067fb6..009242f4fb 100644 --- a/spec/unit/event_dispatch/dsl_spec.rb +++ b/spec/unit/event_dispatch/dsl_spec.rb @@ -63,7 +63,7 @@ describe Chef::EventDispatch::DSL do resource = Chef::Resource::RubyBlock.new("foo", run_context) resource.block {} resource.run_action(:run) - expect(calls).to eq([:started, :updated]) + expect(calls).to eq(%i{started updated}) end it "preserve instance variables across handler callbacks" do diff --git a/spec/unit/knife_spec.rb b/spec/unit/knife_spec.rb index 2c14e417b4..d7943f0f8c 100644 --- a/spec/unit/knife_spec.rb +++ b/spec/unit/knife_spec.rb @@ -55,7 +55,7 @@ describe Chef::Knife do allow(knife.ui).to receive(:print) allow(Chef::Log).to receive(:init) allow(Chef::Log).to receive(:level) - [:debug, :info, :warn, :error, :crit].each do |level_sym| + %i{debug info warn error crit}.each do |level_sym| allow(Chef::Log).to receive(level_sym) end allow(Chef::Knife).to receive(:puts) diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb index a7f95f8bfd..68db44e537 100644 --- a/spec/unit/lwrp_spec.rb +++ b/spec/unit/lwrp_spec.rb @@ -264,12 +264,12 @@ describe "LWRP" do let(:lwrp) do Class.new(Chef::Resource::LWRPBase) do actions :eat, :sleep - default_action [:eat, :sleep] + default_action %i{eat sleep} end end it "returns the array of default actions" do - expect(lwrp.default_action).to eq([:eat, :sleep]) + expect(lwrp.default_action).to eq(%i{eat sleep}) end end @@ -287,7 +287,7 @@ describe "LWRP" do end it "delegates #actions to the parent" do - expect(child.actions).to eq([:nothing, :eat, :sleep]) + expect(child.actions).to eq(%i{nothing eat sleep}) end it "delegates #default_action to the parent" do @@ -304,7 +304,7 @@ describe "LWRP" do end it "does not delegate #actions to the parent" do - expect(child.actions).to eq([:nothing, :dont_eat, :dont_sleep]) + expect(child.actions).to eq(%i{nothing dont_eat dont_sleep}) end it "does not delegate #default_action to the parent" do @@ -322,7 +322,7 @@ describe "LWRP" do end it "amends actions when they are already defined" do - expect(child.actions).to eq([:nothing, :eat, :sleep, :drink]) + expect(child.actions).to eq(%i{nothing eat sleep drink}) end end end @@ -330,40 +330,40 @@ describe "LWRP" do describe "when actions is set to an array" do let(:resource_class) do Class.new(Chef::Resource::LWRPBase) do - actions [ :eat, :sleep ] + actions %i{eat sleep} end end let(:resource) do resource_class.new("blah") end it "actions includes those actions" do - expect(resource_class.actions).to eq [ :nothing, :eat, :sleep ] + expect(resource_class.actions).to eq %i{nothing eat sleep} end it "allowed_actions includes those actions" do - expect(resource_class.allowed_actions).to eq [ :nothing, :eat, :sleep ] + expect(resource_class.allowed_actions).to eq %i{nothing eat sleep} end it "resource.allowed_actions includes those actions" do - expect(resource.allowed_actions).to eq [ :nothing, :eat, :sleep ] + expect(resource.allowed_actions).to eq %i{nothing eat sleep} end end describe "when allowed_actions is set to an array" do let(:resource_class) do Class.new(Chef::Resource::LWRPBase) do - allowed_actions [ :eat, :sleep ] + allowed_actions %i{eat sleep} end end let(:resource) do resource_class.new("blah") end it "actions includes those actions" do - expect(resource_class.actions).to eq [ :nothing, :eat, :sleep ] + expect(resource_class.actions).to eq %i{nothing eat sleep} end it "allowed_actions includes those actions" do - expect(resource_class.allowed_actions).to eq [ :nothing, :eat, :sleep ] + expect(resource_class.allowed_actions).to eq %i{nothing eat sleep} end it "resource.allowed_actions includes those actions" do - expect(resource.allowed_actions).to eq [ :nothing, :eat, :sleep ] + expect(resource.allowed_actions).to eq %i{nothing eat sleep} end end end diff --git a/spec/unit/mixin/params_validate_spec.rb b/spec/unit/mixin/params_validate_spec.rb index 1cc7fef58e..29d69af403 100644 --- a/spec/unit/mixin/params_validate_spec.rb +++ b/spec/unit/mixin/params_validate_spec.rb @@ -236,7 +236,7 @@ describe Chef::Mixin::ParamsValidate do { one: { kind_of: String, - respond_to: [ :to_s, :upcase ], + respond_to: %i{to_s upcase}, regex: /^is good/, callbacks: { "should be your friend" => lambda do |a| @@ -260,7 +260,7 @@ describe Chef::Mixin::ParamsValidate do { one: { kind_of: String, - respond_to: [ :to_s, :upcase ], + respond_to: %i{to_s upcase}, regex: /^is good/, callbacks: { "should be your friend" => lambda do |a| @@ -334,22 +334,22 @@ describe Chef::Mixin::ParamsValidate do it "asserts that a value returns false from a predicate method" do expect do @vo.validate({ not_blank: "should pass" }, - { not_blank: { cannot_be: [ :nil, :empty ] } }) + { not_blank: { cannot_be: %i{nil empty} } }) end.not_to raise_error expect do @vo.validate({ not_blank: "" }, - { not_blank: { cannot_be: [ :nil, :empty ] } }) + { not_blank: { cannot_be: %i{nil empty} } }) end.to raise_error(Chef::Exceptions::ValidationFailed) end it "allows a custom validation message" do expect do @vo.validate({ not_blank: "should pass" }, - { not_blank: { cannot_be: [ :nil, :empty ], validation_message: "my validation message" } }) + { not_blank: { cannot_be: %i{nil empty}, validation_message: "my validation message" } }) end.not_to raise_error expect do @vo.validate({ not_blank: "" }, - { not_blank: { cannot_be: [ :nil, :empty ], validation_message: "my validation message" } }) + { not_blank: { cannot_be: %i{nil empty}, validation_message: "my validation message" } }) end.to raise_error(Chef::Exceptions::ValidationFailed, "my validation message") end diff --git a/spec/unit/mixin/properties_spec.rb b/spec/unit/mixin/properties_spec.rb index ee0c252381..25b94178e5 100644 --- a/spec/unit/mixin/properties_spec.rb +++ b/spec/unit/mixin/properties_spec.rb @@ -31,7 +31,7 @@ module ChefMixinPropertiesSpec end it "A.properties has a, ab, and ac with types 'a', ['a', 'b'], and ['b', 'c']" do - expect(A.properties.keys).to eq [ :a, :ab, :ac, :d ] + expect(A.properties.keys).to eq %i{a ab ac d} expect(A.properties[:a].validation_options[:is]).to eq "a" expect(A.properties[:ab].validation_options[:is]).to eq %w{a b} expect(A.properties[:ac].validation_options[:is]).to eq %w{a c} @@ -46,13 +46,13 @@ module ChefMixinPropertiesSpec end it "B.properties has b, ab, and bc with types 'b', nil and ['b', 'c']" do - expect(B.properties.keys).to eq [ :b, :ab, :bc ] + expect(B.properties.keys).to eq %i{b ab bc} expect(B.properties[:b].validation_options[:is]).to eq "b" expect(B.properties[:ab].validation_options[:is]).to be_nil expect(B.properties[:bc].validation_options[:is]).to eq %w{b c} end it "C.properties has a, b, c, ac and bc with merged types" do - expect(C.properties.keys).to eq [ :a, :ab, :ac, :d, :b, :bc, :c ] + expect(C.properties.keys).to eq %i{a ab ac d b bc c} expect(C.properties[:a].validation_options[:is]).to eq "a" expect(C.properties[:b].validation_options[:is]).to eq "b" expect(C.properties[:c].validation_options[:is]).to eq "c" @@ -99,7 +99,7 @@ module ChefMixinPropertiesSpec end it "Outerest.properties.validation_options[:is] inner, outer, outerest" do - expect(Outerest.properties.keys).to eq [:inner, :outer, :outerest] + expect(Outerest.properties.keys).to eq %i{inner outer outerest} end end end diff --git a/spec/unit/mixin/shell_out_spec.rb b/spec/unit/mixin/shell_out_spec.rb index 4f8e4dafac..1c4f59b50b 100644 --- a/spec/unit/mixin/shell_out_spec.rb +++ b/spec/unit/mixin/shell_out_spec.rb @@ -51,7 +51,7 @@ describe Chef::Mixin::ShellOut do let(:retobj) { instance_double(Mixlib::ShellOut, "error!" => false) } let(:cmd) { "echo '#{rand(1000)}'" } - [ :shell_out, :shell_out! ].each do |method| + %i{shell_out shell_out!}.each do |method| describe "##{method}" do describe "when the last argument is a Hash" do @@ -248,7 +248,7 @@ describe Chef::Mixin::ShellOut do let(:provider) { new_resource.provider_for_action(:install) } describe "on Chef-15", chef: ">= 15" do - [ :shell_out, :shell_out! ].each do |method| + %i{shell_out shell_out!}.each do |method| stubbed_method = (method == :shell_out) ? :shell_out_compacted : :shell_out_compacted! it "#{method} defaults to 900 seconds" do expect(provider).to receive(stubbed_method).with("foo", timeout: 900) @@ -284,7 +284,7 @@ describe Chef::Mixin::ShellOut do let(:new_resource) { Chef::Resource::Package.new("foo") } let(:provider) { new_resource.provider_for_action(:install) } - [ :shell_out, :shell_out! ].each do |method| + %i{shell_out shell_out!}.each do |method| stubbed_method = (method == :shell_out) ? :shell_out_compacted : :shell_out_compacted! it "#{method} defaults to 900 seconds" do expect(provider).to receive(stubbed_method).with("foo", timeout: 900) diff --git a/spec/unit/mixin/windows_architecture_helper_spec.rb b/spec/unit/mixin/windows_architecture_helper_spec.rb index 4559702e1c..06acbe49c9 100644 --- a/spec/unit/mixin/windows_architecture_helper_spec.rb +++ b/spec/unit/mixin/windows_architecture_helper_spec.rb @@ -23,7 +23,7 @@ describe Chef::Mixin::WindowsArchitectureHelper do include Chef::Mixin::WindowsArchitectureHelper before do - @valid_architectures = [ :i386, :x86_64 ] + @valid_architectures = %i{i386 x86_64} @invalid_architectures = [ "i386", "x86_64", :x64, :x86, :arm ] @node_i386 = Chef::Node.new diff --git a/spec/unit/node/attribute_spec.rb b/spec/unit/node/attribute_spec.rb index 29e299566b..1b9a9841e5 100644 --- a/spec/unit/node/attribute_spec.rb +++ b/spec/unit/node/attribute_spec.rb @@ -182,7 +182,7 @@ describe Chef::Node::Attribute do expect { Chef::Node::Attribute.new({}, {}, {}, {}) }.not_to raise_error end - [ :normal, :default, :override, :automatic ].each do |accessor| + %i{normal default override automatic}.each do |accessor| it "should set #{accessor}" do na = Chef::Node::Attribute.new({ normal: true }, { default: true }, { override: true }, { automatic: true }) expect(na.send(accessor)).to eq({ accessor.to_s => true }) @@ -546,7 +546,7 @@ describe Chef::Node::Attribute do expect(@attributes["music"]["this"]).not_to have_key("must") end - [:include?, :key?, :member?].each do |method| + %i{include? key? member?}.each do |method| it "should alias the method #{method} to itself" do expect(@attributes).to respond_to(method) end diff --git a/spec/unit/node/immutable_collections_spec.rb b/spec/unit/node/immutable_collections_spec.rb index 2208c45717..f543123dfd 100644 --- a/spec/unit/node/immutable_collections_spec.rb +++ b/spec/unit/node/immutable_collections_spec.rb @@ -145,25 +145,25 @@ describe Chef::Node::ImmutableMash do end end - [ - :[]=, - :clear, - :default=, - :default_proc=, - :delete, - :delete_if, - :keep_if, - :merge!, - :update, - :reject!, - :replace, - :select!, - :shift, - :write, - :write!, - :unlink, - :unlink!, - ].each do |mutator| + %i{ + \[\]= + clear + default= + default_proc= + delete + delete_if + keep_if + merge! + update + reject! + replace + select! + shift + write + write! + unlink + unlink! + }.each do |mutator| it "doesn't allow mutation via `#{mutator}'" do expect { @immutable_mash.send(mutator) }.to raise_error(Chef::Exceptions::ImmutableAttributeModification) end @@ -190,36 +190,36 @@ describe Chef::Node::ImmutableArray do # with ImmutableMash, above ### - [ - :<<, - :[]=, - :clear, - :collect!, - :compact!, - :default=, - :default_proc=, - :delete, - :delete_at, - :delete_if, - :fill, - :flatten!, - :insert, - :keep_if, - :map!, - :merge!, - :pop, - :push, - :reject!, - :reverse!, - :replace, - :select!, - :shift, - :slice!, - :sort!, - :sort_by!, - :uniq!, - :unshift, - ].each do |mutator| + %i{ + << + \[\]= + clear + collect! + compact! + default= + default_proc= + delete + delete_at + delete_if + fill + flatten! + insert + keep_if + map! + merge! + pop + push + reject! + reverse! + replace + select! + shift + slice! + sort! + sort_by! + uniq! + unshift + }.each do |mutator| it "does not allow mutation via `#{mutator}" do expect { @immutable_array.send(mutator) }.to raise_error(Chef::Exceptions::ImmutableAttributeModification) end diff --git a/spec/unit/property/validation_spec.rb b/spec/unit/property/validation_spec.rb index 412fc72682..514d1666be 100644 --- a/spec/unit/property/validation_spec.rb +++ b/spec/unit/property/validation_spec.rb @@ -232,19 +232,19 @@ describe "Chef::Resource.property validation" do [ :b ] validation_test ":a, is: :b", - [ :a, :b ], + %i{a b}, [ :c ] validation_test ":a, is: [ :b, :c ]", - [ :a, :b, :c ], + %i{a b c}, [ :d ] validation_test "[ :a, :b ], is: :c", - [ :a, :b, :c ], + %i{a b c}, [ :d ] validation_test "[ :a, :b ], is: [ :c, :d ]", - [ :a, :b, :c, :d ], + %i{a b c d}, [ :e ] validation_test "nil", @@ -280,12 +280,12 @@ describe "Chef::Resource.property validation" do [ :b ] validation_test "is: [ :a, :b ]", - [ :a, :b ], - [ [ :a, :b ] ] + %i{a b}, + [ %i{a b} ] validation_test "is: [ [ :a, :b ] ]", - [ [ :a, :b ] ], - [ :a, :b ] + [ %i{a b} ], + %i{a b} # Regex validation_test "is: /abc/", @@ -353,13 +353,13 @@ describe "Chef::Resource.property validation" do :nil_is_valid validation_test "equal_to: [ :a, :b ]", - [ :a, :b ], - [ [ :a, :b ] ], + %i{a b}, + [ %i{a b} ], :nil_is_valid validation_test "equal_to: [ [ :a, :b ] ]", - [ [ :a, :b ] ], - [ :a, :b ], + [ %i{a b} ], + %i{a b}, :nil_is_valid validation_test "equal_to: nil", diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb index 7d04e38068..b2e992f8eb 100644 --- a/spec/unit/property_spec.rb +++ b/spec/unit/property_spec.rb @@ -1086,13 +1086,13 @@ describe "Chef::Resource.property" do expect do module ::PropertySpecPropertyTypes include Chef::Mixin::Properties - property_type(is: [:a, :b], default: :c) + property_type(is: %i{a b}, default: :c) end end.to raise_error(Chef::Exceptions::ValidationFailed) expect do module ::PropertySpecPropertyTypes include Chef::Mixin::Properties - property_type(is: [:a, :b], default: :b) + property_type(is: %i{a b}, default: :b) end end.not_to raise_error end @@ -1101,8 +1101,8 @@ describe "Chef::Resource.property" do before :all do module ::PropertySpecPropertyTypes include Chef::Mixin::Properties - ABType = property_type(is: [:a, :b]) - CDType = property_type(is: [:c, :d]) + ABType = property_type(is: %i{a b}) + CDType = property_type(is: %i{c d}) end end @@ -1305,7 +1305,7 @@ describe "Chef::Resource.property" do it "copies only foo when bar and name are excluded" do thing_one_resource.foo "foo" thing_one_resource.bar "bar" - thing_two_resource.copy_properties_from(thing_one_resource, exclude: [ :name, :bar ]) + thing_two_resource.copy_properties_from(thing_one_resource, exclude: %i{name bar}) expect(thing_two_resource.name).to eql("name_two") expect(thing_two_resource.foo).to eql("foo") expect(thing_two_resource.bar).to eql(nil) diff --git a/spec/unit/provider/cron_spec.rb b/spec/unit/provider/cron_spec.rb index 6bfc18c359..4cd8a140af 100644 --- a/spec/unit/provider/cron_spec.rb +++ b/spec/unit/provider/cron_spec.rb @@ -401,7 +401,7 @@ describe Chef::Provider::Cron do @provider.current_resource = @current_resource end - [:minute, :hour, :day, :month, :weekday, :command, :mailto, :path, :shell, :home].each do |property| + %i{minute hour day month weekday command mailto path shell home}.each do |property| it "should return true if #{property} doesn't match" do @new_resource.send(property, "something_else") expect(@provider.cron_different?).to eql(true) diff --git a/spec/unit/provider/group/groupadd_spec.rb b/spec/unit/provider/group/groupadd_spec.rb index 84997a258d..79586eac71 100644 --- a/spec/unit/provider/group/groupadd_spec.rb +++ b/spec/unit/provider/group/groupadd_spec.rb @@ -155,7 +155,7 @@ describe Chef::Provider::Group::Groupadd do end end - [:add_member, :remove_member, :set_members].each do |m| + %i{add_member remove_member set_members}.each do |m| it "should raise an error when calling #{m}" do expect { provider.send(m, [ ]) }.to raise_error(Chef::Exceptions::Group, "you must override #{m} in #{provider}") end diff --git a/spec/unit/provider/group_spec.rb b/spec/unit/provider/group_spec.rb index bacb711d1b..87391b6288 100644 --- a/spec/unit/provider/group_spec.rb +++ b/spec/unit/provider/group_spec.rb @@ -85,7 +85,7 @@ describe Chef::Provider::User do end describe "when determining if the system is already in the target state" do - [ :gid, :members ].each do |property| + %i{gid members}.each do |property| it "should return true if #{property} doesn't match" do allow(@current_resource).to receive(property).and_return("looooooooooooooooooool") expect(@provider.compare_group).to be_truthy diff --git a/spec/unit/provider/mount/solaris_spec.rb b/spec/unit/provider/mount/solaris_spec.rb index 4e73bc77b5..37c7eb8e38 100644 --- a/spec/unit/provider/mount/solaris_spec.rb +++ b/spec/unit/provider/mount/solaris_spec.rb @@ -103,7 +103,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do describe "#define_resource_requirements" do before do # we're not testing the actual actions so stub them all out - [:mount_fs, :umount_fs, :remount_fs, :enable_fs, :disable_fs].each { |m| allow(provider).to receive(m) } + %i{mount_fs umount_fs remount_fs enable_fs disable_fs}.each { |m| allow(provider).to receive(m) } end it "run_action(:mount) should raise an error if the device does not exist" do diff --git a/spec/unit/provider/package/yum/yum_cache_spec.rb b/spec/unit/provider/package/yum/yum_cache_spec.rb index 6b2a617ac8..9867c31c37 100644 --- a/spec/unit/provider/package/yum/yum_cache_spec.rb +++ b/spec/unit/provider/package/yum/yum_cache_spec.rb @@ -60,7 +60,7 @@ describe Chef::Provider::Package::Yum::YumCache do expect( yum_cache.version_available?("foo", "1.2.3", "x86_64") ).to be true end - [ :refresh, :reload, :reload_installed, :reload_provides, :reset, :reset_installed ].each do |method| + %i{refresh reload reload_installed reload_provides reset reset_installed}.each do |method| it "restarts the python helper when #{method} is called" do expect( python_helper ).to receive(:restart) yum_cache.send(method) diff --git a/spec/unit/resource/dnf_package_spec.rb b/spec/unit/resource/dnf_package_spec.rb index f4262a0396..70d949c340 100644 --- a/spec/unit/resource/dnf_package_spec.rb +++ b/spec/unit/resource/dnf_package_spec.rb @@ -64,7 +64,7 @@ describe Chef::Resource::DnfPackage, "flush_cache" do end it "allows you to set the flush timing with an array" do - flush_array = [ :before, :after ] + flush_array = %i{before after} flush_hash = { before: true, after: true } resource.flush_cache(flush_array) expect(resource.flush_cache).to eq(flush_hash) diff --git a/spec/unit/resource/dsc_resource_spec.rb b/spec/unit/resource/dsc_resource_spec.rb index 04e1305163..e0beb309ab 100644 --- a/spec/unit/resource/dsc_resource_spec.rb +++ b/spec/unit/resource/dsc_resource_spec.rb @@ -41,7 +41,7 @@ describe Chef::Resource::DscResource do end it "has an ed_actions property with only the `:run` and `:nothing` properties" 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(%i{run nothing}.to_set) end it "allows the resource property to be set" do diff --git a/spec/unit/resource/group_spec.rb b/spec/unit/resource/group_spec.rb index 6d9df79299..ae7103b9b5 100644 --- a/spec/unit/resource/group_spec.rb +++ b/spec/unit/resource/group_spec.rb @@ -96,7 +96,7 @@ end describe Chef::Resource::Group, "members" do let(:resource) { Chef::Resource::Group.new("fakey_fakerton") } - [ :users, :members].each do |method| + %i{users members}.each do |method| it "(#{method}) allows a String and coerces it to an Array" do resource.send(method, "some_user") expect(resource.send(method)).to eql(["some_user"]) diff --git a/spec/unit/resource/powershell_script_spec.rb b/spec/unit/resource/powershell_script_spec.rb index dc9b62b16c..a1c5e4c5b0 100644 --- a/spec/unit/resource/powershell_script_spec.rb +++ b/spec/unit/resource/powershell_script_spec.rb @@ -61,7 +61,7 @@ describe Chef::Resource::PowershellScript do it "inherits exactly the :cwd, :environment, :group, :path, :user, :umask, :architecture, :elevated properties from a parent resource class" do inherited_difference = Chef::Resource::PowershellScript.guard_inherited_attributes - - [:cwd, :environment, :group, :path, :user, :umask, :architecture, :elevated ] + %i{cwd environment group path user umask architecture elevated} expect(inherited_difference).to eq([]) end diff --git a/spec/unit/resource/registry_key_spec.rb b/spec/unit/resource/registry_key_spec.rb index 47d624a758..c674e3eddd 100644 --- a/spec/unit/resource/registry_key_spec.rb +++ b/spec/unit/resource/registry_key_spec.rb @@ -152,7 +152,7 @@ describe Chef::Resource::RegistryKey, "recursive" do end it "does not allow an array" do - expect { resource.recursive([:nose, :chin]) }.to raise_error(ArgumentError) + expect { resource.recursive(%i{nose chin}) }.to raise_error(ArgumentError) end it "does not allow a string" do @@ -167,7 +167,7 @@ end describe Chef::Resource::RegistryKey, "architecture" do let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') } - [ :i386, :x86_64, :machine ].each do |arch| + %i{i386 x86_64 machine}.each do |arch| it "allows #{arch} as a symbol" do resource.architecture(arch) expect(resource.architecture).to eql(arch) @@ -183,7 +183,7 @@ describe Chef::Resource::RegistryKey, "architecture" do end it "does not allow an array" do - expect { resource.architecture([:nose, :chin]) }.to raise_error(ArgumentError) + expect { resource.architecture(%i{nose chin}) }.to raise_error(ArgumentError) end it "does not allow a string" do diff --git a/spec/unit/resource/service_spec.rb b/spec/unit/resource/service_spec.rb index 7c2b46a0dc..be88d82f3b 100644 --- a/spec/unit/resource/service_spec.rb +++ b/spec/unit/resource/service_spec.rb @@ -167,7 +167,7 @@ describe Chef::Resource::Service do end it "allows you to set what features this resource supports as an array" do - support_array = [ :status, :restart ] + support_array = %i{status restart} support_hash = { status: true, restart: true } resource.supports(support_array) expect(resource.supports).to eq(support_hash) diff --git a/spec/unit/resource/windows_service_spec.rb b/spec/unit/resource/windows_service_spec.rb index b44a86d04a..53cf1bc0f8 100644 --- a/spec/unit/resource/windows_service_spec.rb +++ b/spec/unit/resource/windows_service_spec.rb @@ -48,7 +48,7 @@ describe Chef::Resource::WindowsService, "initialize" do expect { resource.action :unmask }.not_to raise_error end - [:automatic, :manual, :disabled].each do |type| + %i{automatic manual disabled}.each do |type| it "supports setting startup_type property to #{type.inspect}" do resource.startup_type type expect(resource.startup_type).to eql(type) @@ -69,7 +69,7 @@ describe Chef::Resource::WindowsService, "initialize" do end end - [:automatic, :manual, :disabled].each do |type| + %i{automatic manual disabled}.each do |type| it "supports setting startup_type property to #{type.inspect}" do resource.startup_type type expect(resource.startup_type).to eql(type) diff --git a/spec/unit/resource/windows_task_spec.rb b/spec/unit/resource/windows_task_spec.rb index b152d879f6..d08849d4be 100644 --- a/spec/unit/resource/windows_task_spec.rb +++ b/spec/unit/resource/windows_task_spec.rb @@ -356,7 +356,7 @@ describe Chef::Resource::WindowsTask, :windows_only do context "#validate_idle_time" do it "raises error if frequency is not :on_idle" do - [:minute, :hourly, :daily, :weekly, :monthly, :once, :on_logon, :onstart, :none].each do |frequency| + %i{minute hourly daily weekly monthly once on_logon onstart none}.each do |frequency| expect { resource.send(:validate_idle_time, 5, frequency) }.to raise_error(ArgumentError, "idle_time property is only valid for tasks that run on_idle") end end @@ -374,7 +374,7 @@ describe Chef::Resource::WindowsTask, :windows_only do end it "does not raises error if idle_time is not set for other frequencies" do - [:minute, :hourly, :daily, :weekly, :monthly, :once, :on_logon, :onstart, :none].each do |frequency| + %i{minute hourly daily weekly monthly once on_logon onstart none}.each do |frequency| expect { resource.send(:validate_idle_time, nil, frequency) }.not_to raise_error end end diff --git a/spec/unit/resource/windows_uac_spec.rb b/spec/unit/resource/windows_uac_spec.rb index 05c1cad4a0..6f9137c341 100644 --- a/spec/unit/resource/windows_uac_spec.rb +++ b/spec/unit/resource/windows_uac_spec.rb @@ -24,7 +24,7 @@ describe Chef::Resource::WindowsUac do expect(resource.resource_name).to eql(:windows_uac) end - [:no_prompt, :secure_prompt_for_creds, :secure_prompt_for_consent, :prompt_for_creds, :prompt_for_consent, :prompt_for_consent_non_windows_binaries].each do |val| + %i{no_prompt secure_prompt_for_creds secure_prompt_for_consent prompt_for_creds prompt_for_consent prompt_for_consent_non_windows_binaries}.each do |val| it "the consent_behavior_admins property accepts :#{val}" do expect { resource.consent_behavior_admins val }.not_to raise_error(ArgumentError) end @@ -34,7 +34,7 @@ describe Chef::Resource::WindowsUac do expect { resource.consent_behavior_admins :bogus }.to raise_error(ArgumentError) end - [:auto_deny, :secure_prompt_for_creds, :prompt_for_creds].each do |val| + %i{auto_deny secure_prompt_for_creds prompt_for_creds}.each do |val| it "the consent_behavior_users property accepts :#{val}" do expect { resource.consent_behavior_users val }.not_to raise_error(ArgumentError) end diff --git a/spec/unit/resource/yum_package_spec.rb b/spec/unit/resource/yum_package_spec.rb index 0b79a447a3..d0383a8cec 100644 --- a/spec/unit/resource/yum_package_spec.rb +++ b/spec/unit/resource/yum_package_spec.rb @@ -95,7 +95,7 @@ describe Chef::Resource::YumPackage, "flush_cache" do end it "should allow you to set the flush timing with an array" do - flush_array = [ :before, :after ] + flush_array = %i{before after} flush_hash = { before: true, after: true } @resource.flush_cache(flush_array) expect(@resource.flush_cache).to eq(flush_hash) diff --git a/spec/unit/resource_inspector_spec.rb b/spec/unit/resource_inspector_spec.rb index aef92732b3..c0852be3b2 100644 --- a/spec/unit/resource_inspector_spec.rb +++ b/spec/unit/resource_inspector_spec.rb @@ -39,7 +39,7 @@ describe ResourceInspector do it "returns a hash with required data" do expect(subject[:description]).to eq "A dummy resource" - expect(subject[:actions]).to match_array [:nothing, :dummy] + expect(subject[:actions]).to match_array %i{nothing dummy} end context "excluding built in properties" do diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb index 1c8e991566..5ca563a7ef 100644 --- a/spec/unit/resource_spec.rb +++ b/spec/unit/resource_spec.rb @@ -115,14 +115,14 @@ describe Chef::Resource do it "sets a list of state attributes" do resource_class = Class.new(Chef::Resource) resource_class.state_attrs(:checksum, :owner, :group, :mode) - expect(resource_class.state_attrs).to match_array([:checksum, :owner, :group, :mode]) + expect(resource_class.state_attrs).to match_array(%i{checksum owner group mode}) end it "inherits state attributes from the superclass" do resource_class = Class.new(Chef::Resource) resource_subclass = Class.new(resource_class) resource_class.state_attrs(:checksum, :owner, :group, :mode) - expect(resource_subclass.state_attrs).to match_array([:checksum, :owner, :group, :mode]) + expect(resource_subclass.state_attrs).to match_array(%i{checksum owner group mode}) end it "combines inherited state attributes with non-inherited state attributes" do @@ -130,7 +130,7 @@ describe Chef::Resource do resource_subclass = Class.new(resource_class) resource_class.state_attrs(:checksum, :owner) resource_subclass.state_attrs(:group, :mode) - expect(resource_subclass.state_attrs).to match_array([:checksum, :owner, :group, :mode]) + expect(resource_subclass.state_attrs).to match_array(%i{checksum owner group mode}) end end @@ -157,7 +157,7 @@ describe Chef::Resource do it "describes its state" do resource_state = file_resource.state_for_resource_reporter - expect(resource_state.keys).to match_array([:checksum, :owner, :group, :mode]) + expect(resource_state.keys).to match_array(%i{checksum owner group mode}) expect(resource_state[:checksum]).to eq("abc123") expect(resource_state[:owner]).to eq("root") expect(resource_state[:group]).to eq("wheel") @@ -510,11 +510,11 @@ describe Chef::Resource do context "when the resource has a property with a default" do let(:resource_class) { Class.new(Chef::Resource) { property :a, default: 1 } } it "should include the default in the hash" do - expect(resource.to_hash.keys.sort).to eq([:a, :allowed_actions, :params, :provider, :updated, - :updated_by_last_action, :before, - :name, :source_line, - :action, :elapsed_time, - :default_guard_interpreter, :guard_interpreter].sort) + expect(resource.to_hash.keys.sort).to eq(%i{a allowed_actions params provider updated + updated_by_last_action before + name source_line + action elapsed_time + default_guard_interpreter guard_interpreter}.sort) expect(resource.to_hash[:name]).to eq "funk" expect(resource.to_hash[:a]).to eq 1 end @@ -522,11 +522,11 @@ describe Chef::Resource do it "should convert to a hash" do hash = resource.to_hash - expected_keys = [ :allowed_actions, :params, :provider, :updated, - :updated_by_last_action, :before, - :name, :source_line, - :action, :elapsed_time, - :default_guard_interpreter, :guard_interpreter ] + expected_keys = %i{allowed_actions params provider updated + updated_by_last_action before + name source_line + action elapsed_time + default_guard_interpreter guard_interpreter} expect(hash.keys - expected_keys).to eq([]) expect(expected_keys - hash.keys).to eq([]) expect(hash[:name]).to eql("funk") @@ -1118,8 +1118,8 @@ describe Chef::Resource do end context "with an array action" do - before { resource.action([:two, :one]) } - it { is_expected.to eq [:two, :one] } + before { resource.action(%i{two one}) } + it { is_expected.to eq %i{two one} } end context "with an assignment" do @@ -1128,8 +1128,8 @@ describe Chef::Resource do end context "with an array assignment" do - before { resource.action = [:two, :one] } - it { is_expected.to eq [:two, :one] } + before { resource.action = %i{two one} } + it { is_expected.to eq %i{two one} } end context "with an invalid action" do @@ -1166,8 +1166,8 @@ describe Chef::Resource do end context "with an array default action" do - let(:default_action) { [:two, :one] } - it { is_expected.to eq [:two, :one] } + let(:default_action) { %i{two one} } + it { is_expected.to eq %i{two one} } end end diff --git a/spec/unit/run_context/cookbook_compiler_spec.rb b/spec/unit/run_context/cookbook_compiler_spec.rb index 607333416d..cc9330a1b6 100644 --- a/spec/unit/run_context/cookbook_compiler_spec.rb +++ b/spec/unit/run_context/cookbook_compiler_spec.rb @@ -217,14 +217,14 @@ describe Chef::RunContext::CookbookCompiler do it "should return an array of cookbook names as symbols without duplicates" do node.run_list("test-with-circular-deps::default", "circular-dep1::default", "circular-dep2::default") - expect(compiler.cookbook_order).to eq([:"circular-dep2", - :"circular-dep1", - :"test-with-circular-deps"]) + expect(compiler.cookbook_order).to eq(%i{circular-dep2 + circular-dep1 + test-with-circular-deps}) end it "determines if a cookbook is in the list of cookbooks reachable by dependency" do node.run_list("test-with-deps::default", "test-with-deps::server") - expect(compiler.cookbook_order).to eq([:dependency1, :dependency2, :"test-with-deps"]) + expect(compiler.cookbook_order).to eq(%i{dependency1 dependency2 test-with-deps}) expect(compiler.unreachable_cookbook?(:dependency1)).to be_falsey expect(compiler.unreachable_cookbook?(:dependency2)).to be_falsey expect(compiler.unreachable_cookbook?(:'test-with-deps')).to be_falsey diff --git a/spec/unit/runner_spec.rb b/spec/unit/runner_spec.rb index 1effe3157c..ffb0cd523f 100644 --- a/spec/unit/runner_spec.rb +++ b/spec/unit/runner_spec.rb @@ -295,7 +295,7 @@ describe Chef::Runner do # execution, and schedule delayed actions :second and :third on the first # resource. The duplicate actions should "collapse" to a single notification # and order should be preserved. - expect(SnitchyProvider.all_actions_called).to eq([:first, :first, :second, :third]) + expect(SnitchyProvider.all_actions_called).to eq(%i{first first second third}) end it "executes delayed notifications in the order they were declared" do @@ -321,7 +321,7 @@ describe Chef::Runner do third_resource.notifies(:third_action, first_resource, :delayed) runner.converge - expect(SnitchyProvider.all_actions_called).to eq([:first, :first, :second, :third]) + expect(SnitchyProvider.all_actions_called).to eq(%i{first first second third}) end it "does not fire notifications if the resource was not updated by the last action executed" do @@ -347,7 +347,7 @@ describe Chef::Runner do runner.converge # All of the resources should only fire once: - expect(SnitchyProvider.all_actions_called).to eq([:first, :second, :third]) + expect(SnitchyProvider.all_actions_called).to eq(%i{first second third}) # all of the resources should be marked as updated for reporting purposes expect(first_resource).to be_updated |