summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2019-07-02 15:11:54 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2019-07-02 15:11:54 -0700
commite71560df5cebbfb209089c6255e37e65f0e34d95 (patch)
tree5cd0a1d01eb9609d7f5681b2e04faa902de67e84
parent7a1a6c8ef26c787e4b6dd1602f3d158b37e81720 (diff)
downloadchef-e71560df5cebbfb209089c6255e37e65f0e34d95.tar.gz
Style/SymbolArray
start enforcing using %i{} instead of arrays of symbols Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--ext/win32-eventlog/Rakefile2
-rw-r--r--lib/chef/application/windows_service_manager.rb2
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb2
-rw-r--r--lib/chef/config.rb2
-rw-r--r--lib/chef/cookbook/metadata.rb8
-rw-r--r--lib/chef/cookbook_version.rb2
-rw-r--r--lib/chef/http.rb2
-rw-r--r--lib/chef/knife/bootstrap.rb2
-rw-r--r--lib/chef/knife/bootstrap/train_connector.rb2
-rw-r--r--lib/chef/mixin/securable.rb2
-rw-r--r--lib/chef/mixin/template.rb2
-rw-r--r--lib/chef/node/attribute.rb208
-rw-r--r--lib/chef/node/attribute_collections.rb2
-rw-r--r--lib/chef/node/mixin/immutablize_array.rb282
-rw-r--r--lib/chef/node/mixin/immutablize_hash.rb260
-rw-r--r--lib/chef/platform/service_helpers.rb2
-rw-r--r--lib/chef/property.rb2
-rw-r--r--lib/chef/provider/cron.rb8
-rw-r--r--lib/chef/provider/launchd.rb26
-rw-r--r--lib/chef/provider/package/dpkg.rb2
-rw-r--r--lib/chef/provider/package/yum/python_helper.rb2
-rw-r--r--lib/chef/provider/registry_key.rb2
-rw-r--r--lib/chef/provider/subversion.rb2
-rw-r--r--lib/chef/provider/user.rb2
-rw-r--r--lib/chef/provider/user/windows.rb2
-rw-r--r--lib/chef/resource.rb4
-rw-r--r--lib/chef/resource/dsc_resource.rb2
-rw-r--r--lib/chef/resource/link.rb2
-rw-r--r--lib/chef/resource/log.rb2
-rw-r--r--lib/chef/resource/registry_key.rb6
-rw-r--r--lib/chef/resource/remote_file.rb2
-rw-r--r--lib/chef/resource/route.rb2
-rw-r--r--lib/chef/resource/windows_ad_join.rb2
-rw-r--r--lib/chef/resource/windows_feature.rb2
-rw-r--r--lib/chef/resource/windows_firewall_rule.rb8
-rw-r--r--lib/chef/resource/windows_service.rb2
-rw-r--r--lib/chef/resource/windows_task.rb30
-rw-r--r--lib/chef/resource/windows_uac.rb8
-rw-r--r--lib/chef/resource/windows_workgroup.rb2
-rw-r--r--lib/chef/resource_collection.rb4
-rw-r--r--lib/chef/resource_collection/resource_list.rb2
-rw-r--r--lib/chef/version_class.rb2
-rw-r--r--lib/chef/win32/api/crypto.rb18
-rw-r--r--lib/chef/win32/api/error.rb8
-rw-r--r--lib/chef/win32/api/file.rb28
-rw-r--r--lib/chef/win32/api/installer.rb6
-rw-r--r--lib/chef/win32/api/memory.rb8
-rw-r--r--lib/chef/win32/api/net.rb74
-rw-r--r--lib/chef/win32/api/process.rb4
-rw-r--r--lib/chef/win32/api/psapi.rb2
-rw-r--r--lib/chef/win32/api/registry.rb6
-rw-r--r--lib/chef/win32/api/security.rb130
-rw-r--r--lib/chef/win32/api/synchronization.rb10
-rw-r--r--lib/chef/win32/api/system.rb14
-rw-r--r--lib/chef/win32/api/unicode.rb6
-rw-r--r--lib/chef/win32/eventlog.rb2
-rw-r--r--lib/chef/win32/file/version_info.rb28
-rw-r--r--spec/functional/file_content_management/deploy_strategies_spec.rb42
-rw-r--r--spec/functional/mixin/user_context_spec.rb2
-rw-r--r--spec/functional/resource/reboot_spec.rb2
-rw-r--r--spec/functional/resource/windows_service_spec.rb2
-rw-r--r--spec/functional/win32/security_spec.rb2
-rw-r--r--spec/functional/win32/service_manager_spec.rb2
-rw-r--r--spec/integration/recipes/lwrp_inline_resources_spec.rb2
-rw-r--r--spec/integration/recipes/recipe_dsl_spec.rb12
-rw-r--r--spec/support/shared/unit/file_system_support.rb2
-rw-r--r--spec/support/shared/unit/platform_introspector.rb22
-rw-r--r--spec/support/shared/unit/provider/file.rb2
-rw-r--r--spec/support/shared/unit/script_resource.rb2
-rw-r--r--spec/unit/cookbook/metadata_spec.rb8
-rw-r--r--spec/unit/data_bag_item_spec.rb12
-rw-r--r--spec/unit/dsl/declare_resource_spec.rb2
-rw-r--r--spec/unit/dsl/platform_introspection_spec.rb4
-rw-r--r--spec/unit/event_dispatch/dsl_spec.rb2
-rw-r--r--spec/unit/knife_spec.rb2
-rw-r--r--spec/unit/lwrp_spec.rb26
-rw-r--r--spec/unit/mixin/params_validate_spec.rb12
-rw-r--r--spec/unit/mixin/properties_spec.rb8
-rw-r--r--spec/unit/mixin/shell_out_spec.rb6
-rw-r--r--spec/unit/mixin/windows_architecture_helper_spec.rb2
-rw-r--r--spec/unit/node/attribute_spec.rb4
-rw-r--r--spec/unit/node/immutable_collections_spec.rb98
-rw-r--r--spec/unit/property/validation_spec.rb24
-rw-r--r--spec/unit/property_spec.rb10
-rw-r--r--spec/unit/provider/cron_spec.rb2
-rw-r--r--spec/unit/provider/group/groupadd_spec.rb2
-rw-r--r--spec/unit/provider/group_spec.rb2
-rw-r--r--spec/unit/provider/mount/solaris_spec.rb2
-rw-r--r--spec/unit/provider/package/yum/yum_cache_spec.rb2
-rw-r--r--spec/unit/resource/dnf_package_spec.rb2
-rw-r--r--spec/unit/resource/dsc_resource_spec.rb2
-rw-r--r--spec/unit/resource/group_spec.rb2
-rw-r--r--spec/unit/resource/powershell_script_spec.rb2
-rw-r--r--spec/unit/resource/registry_key_spec.rb6
-rw-r--r--spec/unit/resource/service_spec.rb2
-rw-r--r--spec/unit/resource/windows_service_spec.rb4
-rw-r--r--spec/unit/resource/windows_task_spec.rb4
-rw-r--r--spec/unit/resource/windows_uac_spec.rb4
-rw-r--r--spec/unit/resource/yum_package_spec.rb2
-rw-r--r--spec/unit/resource_inspector_spec.rb2
-rw-r--r--spec/unit/resource_spec.rb40
-rw-r--r--spec/unit/run_context/cookbook_compiler_spec.rb8
-rw-r--r--spec/unit/runner_spec.rb6
-rw-r--r--tasks/rspec.rb2
104 files changed, 834 insertions, 834 deletions
diff --git a/ext/win32-eventlog/Rakefile b/ext/win32-eventlog/Rakefile
index 1b974670e5..a4f032d04e 100644
--- a/ext/win32-eventlog/Rakefile
+++ b/ext/win32-eventlog/Rakefile
@@ -23,7 +23,7 @@ CC = "gcc".freeze
ensure_present [MC, RC, CC]
task build: [EVT_RESOURCE_OBJECT, EVT_SHARED_OBJECT]
-task default: [:build, :register]
+task default: %i{build register}
file EVT_RC_FILE => EVT_MC_FILE do
sh "#{MC} #{EVT_MC_FILE}"
diff --git a/lib/chef/application/windows_service_manager.rb b/lib/chef/application/windows_service_manager.rb
index 2921c3d964..655cc3fe96 100644
--- a/lib/chef/application/windows_service_manager.rb
+++ b/lib/chef/application/windows_service_manager.rb
@@ -78,7 +78,7 @@ class Chef
raise ArgumentError, "Service definition is not provided" if service_options.nil?
- required_options = [:service_name, :service_display_name, :service_description, :service_file_path]
+ required_options = %i{service_name service_display_name service_description service_file_path}
required_options.each do |req_option|
if !service_options.key?(req_option)
diff --git a/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb b/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb
index 336f3592d5..67b7e992b3 100644
--- a/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb
@@ -139,7 +139,7 @@ class Chef
are_same = true
Chef::ChefFS::CommandLine.diff_entries(self, other, nil, :name_only).each do |type, old_entry, new_entry|
- if [ :directory_to_file, :file_to_directory, :deleted, :added, :modified ].include?(type)
+ if %i{directory_to_file file_to_directory deleted added modified}.include?(type)
are_same = false
end
end
diff --git a/lib/chef/config.rb b/lib/chef/config.rb
index 759818261e..135ae622f7 100644
--- a/lib/chef/config.rb
+++ b/lib/chef/config.rb
@@ -74,7 +74,7 @@ class Chef
# by redefining the config_attr_writer to not warn for these options.
#
# REMOVEME once the warnings for these configurables are removed from Ohai.
- [ :log_level, :log_location ].each do |option|
+ %i{log_level log_location}.each do |option|
config_attr_writer option do |value|
value
end
diff --git a/lib/chef/cookbook/metadata.rb b/lib/chef/cookbook/metadata.rb
index ff12d865c3..1060eaa09c 100644
--- a/lib/chef/cookbook/metadata.rb
+++ b/lib/chef/cookbook/metadata.rb
@@ -53,10 +53,10 @@ class Chef
OHAI_VERSIONS = "ohai_versions".freeze
GEMS = "gems".freeze
- COMPARISON_FIELDS = [ :name, :description, :long_description, :maintainer,
- :maintainer_email, :license, :platforms, :dependencies,
- :providing, :recipes, :version, :source_url, :issues_url,
- :privacy, :chef_versions, :ohai_versions, :gems ].freeze
+ COMPARISON_FIELDS = %i{name description long_description maintainer
+ maintainer_email license platforms dependencies
+ providing recipes version source_url issues_url
+ privacy chef_versions ohai_versions gems}.freeze
VERSION_CONSTRAINTS = { depends: DEPENDENCIES,
provides: PROVIDING,
diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb
index 6ef66a0337..e149947603 100644
--- a/lib/chef/cookbook_version.rb
+++ b/lib/chef/cookbook_version.rb
@@ -42,7 +42,7 @@ class Chef
def_delegator :@cookbook_manifest, :files_for
def_delegator :@cookbook_manifest, :each_file
- COOKBOOK_SEGMENTS = [ :resources, :providers, :recipes, :definitions, :libraries, :attributes, :files, :templates, :root_files ].freeze
+ COOKBOOK_SEGMENTS = %i{resources providers recipes definitions libraries attributes files templates root_files}.freeze
attr_reader :all_files
diff --git a/lib/chef/http.rb b/lib/chef/http.rb
index 546b9c0fbe..b5f6a91c5d 100644
--- a/lib/chef/http.rb
+++ b/lib/chef/http.rb
@@ -382,7 +382,7 @@ class Chef
elsif response.kind_of?(Net::HTTPNotModified) # Must be tested before Net::HTTPRedirection because it's subclass.
[response, request, false]
elsif redirect_location = redirected_to(response)
- if [:GET, :HEAD].include?(method)
+ if %i{GET HEAD}.include?(method)
follow_redirect do
redirected_url = url + redirect_location
if http_disable_auth_on_redirect
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb
index 7eb20e6dfb..ea0ff2d064 100644
--- a/lib/chef/knife/bootstrap.rb
+++ b/lib/chef/knife/bootstrap.rb
@@ -1015,7 +1015,7 @@ class Chef
non_interactive: false,
keys_only: false,
key_files: [],
- auth_methods: [:password, :keyboard_interactive],
+ auth_methods: %i{password keyboard_interactive},
}
end
diff --git a/lib/chef/knife/bootstrap/train_connector.rb b/lib/chef/knife/bootstrap/train_connector.rb
index 490be38f3e..8487116f08 100644
--- a/lib/chef/knife/bootstrap/train_connector.rb
+++ b/lib/chef/knife/bootstrap/train_connector.rb
@@ -23,7 +23,7 @@ class Chef
class Knife
class Bootstrap < Knife
class TrainConnector
- SSH_CONFIG_OVERRIDE_KEYS ||= [:user, :port, :proxy].freeze
+ SSH_CONFIG_OVERRIDE_KEYS ||= %i{user port proxy}.freeze
MKTEMP_WIN_COMMAND ||= <<~EOM.freeze
$parent = [System.IO.Path]::GetTempPath();
diff --git a/lib/chef/mixin/securable.rb b/lib/chef/mixin/securable.rb
index eb59f184d1..9da8ae4c2f 100644
--- a/lib/chef/mixin/securable.rb
+++ b/lib/chef/mixin/securable.rb
@@ -128,7 +128,7 @@ class Chef
if permission < 0 || permission > 1 << 32
raise ArgumentError, "permissions flags must be positive and <= 32 bits (#{permission})"
end
- elsif !([:full_control, :modify, :read_execute, :read, :write].include?(permission.to_sym))
+ elsif !(%i{full_control modify read_execute read write}.include?(permission.to_sym))
raise ArgumentError, "permissions parameter must be :full_control, :modify, :read_execute, :read, :write or an integer representing Windows permission flags"
end
end
diff --git a/lib/chef/mixin/template.rb b/lib/chef/mixin/template.rb
index 38de13e6b6..488a80acdb 100644
--- a/lib/chef/mixin/template.rb
+++ b/lib/chef/mixin/template.rb
@@ -184,7 +184,7 @@ class Chef
def _extend_modules(module_names)
module_names.each do |mod|
- context_methods = [:node, :render, :render_template, :render_template_from_string]
+ context_methods = %i{node render render_template render_template_from_string}
context_methods.each do |core_method|
if mod.method_defined?(core_method) || mod.private_method_defined?(core_method)
Chef::Log.warn("Core template method `#{core_method}' overridden by extension module #{mod}")
diff --git a/lib/chef/node/attribute.rb b/lib/chef/node/attribute.rb
index 2fc5d55a8e..ae3e3bd7ac 100644
--- a/lib/chef/node/attribute.rb
+++ b/lib/chef/node/attribute.rb
@@ -51,109 +51,109 @@ class Chef
# List of the component attribute hashes, in order of precedence, low to
# high.
- COMPONENTS = [
- :@default,
- :@env_default,
- :@role_default,
- :@force_default,
- :@normal,
- :@override,
- :@role_override,
- :@env_override,
- :@force_override,
- :@automatic,
- ].freeze
-
- DEFAULT_COMPONENTS = [
- :@default,
- :@env_default,
- :@role_default,
- :@force_default,
- ].freeze
-
- OVERRIDE_COMPONENTS = [
- :@override,
- :@role_override,
- :@env_override,
- :@force_override,
- ].freeze
-
- ENUM_METHODS = [
- :all?,
- :any?,
- :assoc,
- :chunk,
- :collect,
- :collect_concat,
- :compare_by_identity,
- :compare_by_identity?,
- :count,
- :cycle,
- :detect,
- :drop,
- :drop_while,
- :each,
- :each_cons,
- :each_entry,
- :each_key,
- :each_pair,
- :each_slice,
- :each_value,
- :each_with_index,
- :each_with_object,
- :empty?,
- :entries,
- :except,
- :fetch,
- :find,
- :find_all,
- :find_index,
- :first,
- :flat_map,
- :flatten,
- :grep,
- :group_by,
- :has_value?,
- :include?,
- :index,
- :inject,
- :invert,
- :key,
- :keys,
- :length,
- :map,
- :max,
- :max_by,
- :merge,
- :min,
- :min_by,
- :minmax,
- :minmax_by,
- :none?,
- :one?,
- :partition,
- :rassoc,
- :reduce,
- :reject,
- :reverse_each,
- :select,
- :size,
- :slice_before,
- :sort,
- :sort_by,
- :store,
- :symbolize_keys,
- :take,
- :take_while,
- :to_a,
- :to_h,
- :to_hash,
- :to_set,
- :value?,
- :values,
- :values_at,
- :zip,
- ].freeze
+ COMPONENTS = %i{
+ @default
+ @env_default
+ @role_default
+ @force_default
+ @normal
+ @override
+ @role_override
+ @env_override
+ @force_override
+ @automatic
+ }.freeze
+
+ DEFAULT_COMPONENTS = %i{
+ @default
+ @env_default
+ @role_default
+ @force_default
+ }.freeze
+
+ OVERRIDE_COMPONENTS = %i{
+ @override
+ @role_override
+ @env_override
+ @force_override
+ }.freeze
+
+ ENUM_METHODS = %i{
+ all?
+ any?
+ assoc
+ chunk
+ collect
+ collect_concat
+ compare_by_identity
+ compare_by_identity?
+ count
+ cycle
+ detect
+ drop
+ drop_while
+ each
+ each_cons
+ each_entry
+ each_key
+ each_pair
+ each_slice
+ each_value
+ each_with_index
+ each_with_object
+ empty?
+ entries
+ except
+ fetch
+ find
+ find_all
+ find_index
+ first
+ flat_map
+ flatten
+ grep
+ group_by
+ has_value?
+ include?
+ index
+ inject
+ invert
+ key
+ keys
+ length
+ map
+ max
+ max_by
+ merge
+ min
+ min_by
+ minmax
+ minmax_by
+ none?
+ one?
+ partition
+ rassoc
+ reduce
+ reject
+ reverse_each
+ select
+ size
+ slice_before
+ sort
+ sort_by
+ store
+ symbolize_keys
+ take
+ take_while
+ to_a
+ to_h
+ to_hash
+ to_set
+ value?
+ values
+ values_at
+ zip
+ }.freeze
ENUM_METHODS.each do |delegated_method|
define_method(delegated_method) do |*args, &block|
@@ -487,7 +487,7 @@ class Chef
end
def inspect
- "#<#{self.class} " << (COMPONENTS + [:@merged_attributes, :@properties]).map do |iv|
+ "#<#{self.class} " << (COMPONENTS + %i{@merged_attributes @properties}).map do |iv|
"#{iv}=#{instance_variable_get(iv).inspect}"
end.join(", ") << ">"
end
diff --git a/lib/chef/node/attribute_collections.rb b/lib/chef/node/attribute_collections.rb
index 3f19321afa..dadc209ae9 100644
--- a/lib/chef/node/attribute_collections.rb
+++ b/lib/chef/node/attribute_collections.rb
@@ -106,7 +106,7 @@ class Chef
# Methods that mutate a VividMash. Each of them is overridden so that it
# also invalidates the cached merged_attributes on the root Attribute
# object.
- MUTATOR_METHODS = Chef::Node::Mixin::ImmutablizeHash::DISALLOWED_MUTATOR_METHODS - [ :write, :write!, :unlink, :unlink! ]
+ MUTATOR_METHODS = Chef::Node::Mixin::ImmutablizeHash::DISALLOWED_MUTATOR_METHODS - %i{write write! unlink unlink!}
# For all of the mutating methods on Mash, override them so that they
# also invalidate the cached `merged_attributes` on the root Attribute
diff --git a/lib/chef/node/mixin/immutablize_array.rb b/lib/chef/node/mixin/immutablize_array.rb
index a2b8649268..2788f5635e 100644
--- a/lib/chef/node/mixin/immutablize_array.rb
+++ b/lib/chef/node/mixin/immutablize_array.rb
@@ -21,150 +21,150 @@ class Chef
module ImmutablizeArray
# Allowed methods that MUST NOT mutate the object
# (if any of these methods mutate the underlying object that is a bug that needs to be fixed)
- ALLOWED_METHODS = [
- :&,
- :*,
- :+,
- :-,
- :[],
- :abbrev,
- :all?,
- :any?,
- :assoc,
- :at,
- :bsearch,
- :bsearch_index,
- :chain,
- :chunk,
- :chunk_while,
- :collect,
- :collect_concat,
- :combination,
- :compact,
- :count,
- :cycle,
- :detect,
- :difference,
- :dig,
- :drop,
- :drop_while,
- :each,
- :each_cons,
- :each_entry,
- :each_index,
- :each_slice,
- :each_with_index,
- :each_with_object,
- :empty?,
- :entries,
- :fetch,
- :filter,
- :find,
- :find_all,
- :find_index,
- :first,
- :flat_map,
- :flatten,
- :grep,
- :grep_v,
- :group_by,
- :include?,
- :index,
- :inject,
- :join,
- :last,
- :lazy,
- :length,
- :map,
- :max,
- :max_by,
- :member?,
- :min,
- :min_by,
- :minmax,
- :minmax_by,
- :none?,
- :one?,
- :pack,
- :partition,
- :permutation,
- :product,
- :rassoc,
- :reduce,
- :reject,
- :repeated_combination,
- :repeated_permutation,
- :reverse,
- :reverse_each,
- :rindex,
- :rotate,
- :sample,
- :save_plist,
- :select,
- :shelljoin,
- :shuffle,
- :size,
- :slice,
- :slice_after,
- :slice_before,
- :slice_when,
- :sort,
- :sort_by,
- :sum,
- :take,
- :take_while,
- :to_a,
- :to_ary,
- :to_csv,
- :to_h,
- :to_plist,
- :to_set,
- :transpose,
- :union,
- :uniq,
- :values_at,
- :zip,
- :|,
- ].freeze
+ ALLOWED_METHODS = %i{
+ &
+ *
+ +
+ -
+ \[\]
+ abbrev
+ all?
+ any?
+ assoc
+ at
+ bsearch
+ bsearch_index
+ chain
+ chunk
+ chunk_while
+ collect
+ collect_concat
+ combination
+ compact
+ count
+ cycle
+ detect
+ difference
+ dig
+ drop
+ drop_while
+ each
+ each_cons
+ each_entry
+ each_index
+ each_slice
+ each_with_index
+ each_with_object
+ empty?
+ entries
+ fetch
+ filter
+ find
+ find_all
+ find_index
+ first
+ flat_map
+ flatten
+ grep
+ grep_v
+ group_by
+ include?
+ index
+ inject
+ join
+ last
+ lazy
+ length
+ map
+ max
+ max_by
+ member?
+ min
+ min_by
+ minmax
+ minmax_by
+ none?
+ one?
+ pack
+ partition
+ permutation
+ product
+ rassoc
+ reduce
+ reject
+ repeated_combination
+ repeated_permutation
+ reverse
+ reverse_each
+ rindex
+ rotate
+ sample
+ save_plist
+ select
+ shelljoin
+ shuffle
+ size
+ slice
+ slice_after
+ slice_before
+ slice_when
+ sort
+ sort_by
+ sum
+ take
+ take_while
+ to_a
+ to_ary
+ to_csv
+ to_h
+ to_plist
+ to_set
+ transpose
+ union
+ uniq
+ values_at
+ zip
+ |
+ }.freeze
# A list of methods that mutate Array. Each of these is overridden to
# raise an error, making this instances of this class more or less
# immutable.
- DISALLOWED_MUTATOR_METHODS = [
- :<<,
- :[]=,
- :append,
- :clear,
- :collect!,
- :compact!,
- :concat,
- :default=,
- :default_proc=,
- :delete,
- :delete_at,
- :delete_if,
- :fill,
- :filter!,
- :flatten!,
- :insert,
- :keep_if,
- :map!,
- :merge!,
- :pop,
- :prepend,
- :push,
- :reject!,
- :replace,
- :reverse!,
- :rotate!,
- :select!,
- :shift,
- :shuffle!,
- :slice!,
- :sort!,
- :sort_by!,
- :uniq!,
- :unshift,
- ].freeze
+ DISALLOWED_MUTATOR_METHODS = %i{
+ <<
+ \[\]=
+ append
+ clear
+ collect!
+ compact!
+ concat
+ default=
+ default_proc=
+ delete
+ delete_at
+ delete_if
+ fill
+ filter!
+ flatten!
+ insert
+ keep_if
+ map!
+ merge!
+ pop
+ prepend
+ push
+ reject!
+ replace
+ reverse!
+ rotate!
+ select!
+ shift
+ shuffle!
+ slice!
+ sort!
+ sort_by!
+ uniq!
+ unshift
+ }.freeze
# Redefine all of the methods that mutate a Hash to raise an error when called.
# This is the magic that makes this object "Immutable"
diff --git a/lib/chef/node/mixin/immutablize_hash.rb b/lib/chef/node/mixin/immutablize_hash.rb
index 109390ed74..2cf65d2b2e 100644
--- a/lib/chef/node/mixin/immutablize_hash.rb
+++ b/lib/chef/node/mixin/immutablize_hash.rb
@@ -21,136 +21,136 @@ class Chef
module ImmutablizeHash
# allowed methods that MUST NOT mutate the object
# (if any of these methods mutate the underlying object that is a bug that needs to be fixed)
- ALLOWED_METHODS = [
- :<,
- :<=,
- :>,
- :>=,
- :[],
- :all?,
- :any?,
- :assoc,
- :chain,
- :chunk,
- :chunk_while,
- :collect,
- :collect_concat,
- :compact,
- :compare_by_identity,
- :compare_by_identity?,
- :count,
- :cycle,
- :default,
- :default_proc,
- :detect,
- :dig,
- :drop,
- :drop_while,
- :each,
- :each_cons,
- :each_entry,
- :each_key,
- :each_pair,
- :each_slice,
- :each_value,
- :each_with_index,
- :each_with_object,
- :empty?,
- :entries,
- :fetch,
- :fetch_values,
- :filter,
- :find,
- :find_all,
- :find_index,
- :first,
- :flat_map,
- :flatten,
- :grep,
- :grep_v,
- :group_by,
- :has_key?,
- :has_value?,
- :include?,
- :index,
- :inject,
- :invert,
- :key,
- :key?,
- :keys,
- :lazy,
- :length,
- :map,
- :max,
- :max_by,
- :member?,
- :merge,
- :min,
- :min_by,
- :minmax,
- :minmax_by,
- :none?,
- :normalize_param,
- :one?,
- :partition,
- :rassoc,
- :reduce,
- :reject,
- :reverse_each,
- :save_plist,
- :select,
- :size,
- :slice,
- :slice_after,
- :slice_before,
- :slice_when,
- :sort,
- :sort_by,
- :sum,
- :take,
- :take_while,
- :to_a,
- :to_h,
- :to_hash,
- :to_plist,
- :to_proc,
- :to_set,
- :to_xml_attributes,
- :transform_keys,
- :transform_values,
- :uniq,
- :value?,
- :values,
- :values_at,
- :zip,
- ].freeze
- DISALLOWED_MUTATOR_METHODS = [
- :[]=,
- :clear,
- :collect!,
- :compact!,
- :default=,
- :default_proc=,
- :delete,
- :delete_if,
- :filter!,
- :keep_if,
- :map!,
- :merge!,
- :rehash,
- :reject!,
- :replace,
- :select!,
- :shift,
- :store,
- :transform_keys!,
- :transform_values!,
- :unlink!,
- :unlink,
- :update,
- :write!,
- :write,
- ].freeze
+ ALLOWED_METHODS = %i{
+ <
+ <=
+ >
+ >=
+ \[\]
+ all?
+ any?
+ assoc
+ chain
+ chunk
+ chunk_while
+ collect
+ collect_concat
+ compact
+ compare_by_identity
+ compare_by_identity?
+ count
+ cycle
+ default
+ default_proc
+ detect
+ dig
+ drop
+ drop_while
+ each
+ each_cons
+ each_entry
+ each_key
+ each_pair
+ each_slice
+ each_value
+ each_with_index
+ each_with_object
+ empty?
+ entries
+ fetch
+ fetch_values
+ filter
+ find
+ find_all
+ find_index
+ first
+ flat_map
+ flatten
+ grep
+ grep_v
+ group_by
+ has_key?
+ has_value?
+ include?
+ index
+ inject
+ invert
+ key
+ key?
+ keys
+ lazy
+ length
+ map
+ max
+ max_by
+ member?
+ merge
+ min
+ min_by
+ minmax
+ minmax_by
+ none?
+ normalize_param
+ one?
+ partition
+ rassoc
+ reduce
+ reject
+ reverse_each
+ save_plist
+ select
+ size
+ slice
+ slice_after
+ slice_before
+ slice_when
+ sort
+ sort_by
+ sum
+ take
+ take_while
+ to_a
+ to_h
+ to_hash
+ to_plist
+ to_proc
+ to_set
+ to_xml_attributes
+ transform_keys
+ transform_values
+ uniq
+ value?
+ values
+ values_at
+ zip
+ }.freeze
+ DISALLOWED_MUTATOR_METHODS = %i{
+ \[\]=
+ clear
+ collect!
+ compact!
+ default=
+ default_proc=
+ delete
+ delete_if
+ filter!
+ keep_if
+ map!
+ merge!
+ rehash
+ reject!
+ replace
+ select!
+ shift
+ store
+ transform_keys!
+ transform_values!
+ unlink!
+ unlink
+ update
+ write!
+ write
+ }.freeze
# Redefine all of the methods that mutate a Hash to raise an error when called.
# This is the magic that makes this object "Immutable"
diff --git a/lib/chef/platform/service_helpers.rb b/lib/chef/platform/service_helpers.rb
index 2faec6fc8a..dddddbe90e 100644
--- a/lib/chef/platform/service_helpers.rb
+++ b/lib/chef/platform/service_helpers.rb
@@ -72,7 +72,7 @@ class Chef
configs = []
if file_exist?(Chef.path_to("/etc/init.d/#{service_name}"))
- configs += [ :initd, :systemd ]
+ configs += %i{initd systemd}
end
if file_exist?(Chef.path_to("/etc/init/#{service_name}.conf"))
diff --git a/lib/chef/property.rb b/lib/chef/property.rb
index 24dbd56f2c..5c9a62bed2 100644
--- a/lib/chef/property.rb
+++ b/lib/chef/property.rb
@@ -322,7 +322,7 @@ class Chef
#
def validation_options
@validation_options ||= options.reject do |k, v|
- [:declared_in, :name, :instance_variable_name, :desired_state, :identity, :default, :name_property, :coerce, :required, :nillable, :sensitive, :description, :introduced, :deprecated, :default_description, :skip_docs].include?(k)
+ %i{declared_in name instance_variable_name desired_state identity default name_property coerce required nillable sensitive description introduced deprecated default_description skip_docs}.include?(k)
end
end
diff --git a/lib/chef/provider/cron.rb b/lib/chef/provider/cron.rb
index 7a6f3d666f..ec810739ab 100644
--- a/lib/chef/provider/cron.rb
+++ b/lib/chef/provider/cron.rb
@@ -25,9 +25,9 @@ class Chef
provides :cron, os: ["!aix", "!solaris2"]
- SPECIAL_TIME_VALUES = [:reboot, :yearly, :annually, :monthly, :weekly, :daily, :midnight, :hourly].freeze
- CRON_ATTRIBUTES = [:minute, :hour, :day, :month, :weekday, :time, :command, :mailto, :path, :shell, :home, :environment].freeze
- WEEKDAY_SYMBOLS = [:sunday, :monday, :tuesday, :wednesday, :thursday, :friday, :saturday].freeze
+ SPECIAL_TIME_VALUES = %i{reboot yearly annually monthly weekly daily midnight hourly}.freeze
+ CRON_ATTRIBUTES = %i{minute hour day month weekday time command mailto path shell home environment}.freeze
+ WEEKDAY_SYMBOLS = %i{sunday monday tuesday wednesday thursday friday saturday}.freeze
CRON_PATTERN = /\A([-0-9*,\/]+)\s([-0-9*,\/]+)\s([-0-9*,\/]+)\s([-0-9*,\/]+|[a-zA-Z]{3})\s([-0-9*,\/]+|[a-zA-Z]{3})\s(.*)/.freeze
SPECIAL_PATTERN = /\A(@(#{SPECIAL_TIME_VALUES.join('|')}))\s(.*)/.freeze
@@ -219,7 +219,7 @@ class Chef
def get_crontab_entry
newcron = ""
newcron << "# Chef Name: #{new_resource.name}\n"
- [ :mailto, :path, :shell, :home ].each do |v|
+ %i{mailto path shell home}.each do |v|
newcron << "#{v.to_s.upcase}=\"#{new_resource.send(v)}\"\n" if new_resource.send(v)
end
new_resource.environment.each do |name, value|
diff --git a/lib/chef/provider/launchd.rb b/lib/chef/provider/launchd.rb
index 838ec22abd..4f20a417a6 100644
--- a/lib/chef/provider/launchd.rb
+++ b/lib/chef/provider/launchd.rb
@@ -29,18 +29,18 @@ class Chef
extend Forwardable
provides :launchd, os: "darwin"
- def_delegators :new_resource, *[
- :backup,
- :cookbook,
- :group,
- :label,
- :mode,
- :owner,
- :path,
- :source,
- :session_type,
- :type,
- ]
+ def_delegators :new_resource, *%i{
+ backup
+ cookbook
+ group
+ label
+ mode
+ owner
+ path
+ source
+ session_type
+ type
+ }
def load_current_resource
current_resource = Chef::Resource::Launchd.new(new_resource.name)
@@ -114,7 +114,7 @@ class Chef
console_user = Etc.getpwuid(::File.stat("/dev/console").uid).name
root = console_user == "root"
agent = type == "agent"
- invalid_action = [:delete, :disable, :enable, :restart].include?(action)
+ invalid_action = %i{delete disable enable restart}.include?(action)
lltstype = ""
if new_resource.limit_load_to_session_type
lltstype = new_resource.limit_load_to_session_type
diff --git a/lib/chef/provider/package/dpkg.rb b/lib/chef/provider/package/dpkg.rb
index eaeb5c8fce..47bc53ba8a 100644
--- a/lib/chef/provider/package/dpkg.rb
+++ b/lib/chef/provider/package/dpkg.rb
@@ -218,7 +218,7 @@ class Chef
#
# @return [Boolean] true if we're doing :install or :upgrade
def installing?
- [:install, :upgrade].include?(action)
+ %i{install upgrade}.include?(action)
end
end
diff --git a/lib/chef/provider/package/yum/python_helper.rb b/lib/chef/provider/package/yum/python_helper.rb
index af0f25bea9..f99b17bcce 100644
--- a/lib/chef/provider/package/yum/python_helper.rb
+++ b/lib/chef/provider/package/yum/python_helper.rb
@@ -165,7 +165,7 @@ class Chef
end
# Special handling for certain action / param combos
- if [:whatinstalled, :whatavailable].include?(action)
+ if %i{whatinstalled whatavailable}.include?(action)
add_version(hash, parameters["version"]) unless parameters["version"].nil?
end
diff --git a/lib/chef/provider/registry_key.rb b/lib/chef/provider/registry_key.rb
index 11d9f3f9b3..9a9df61b2b 100644
--- a/lib/chef/provider/registry_key.rb
+++ b/lib/chef/provider/registry_key.rb
@@ -122,7 +122,7 @@ class Chef
new_resource.unscrubbed_values.each do |value|
if @name_hash.key?(value[:name].downcase)
current_value = @name_hash[value[:name].downcase]
- if [:dword, :dword_big_endian, :qword].include? value[:type]
+ if %i{dword dword_big_endian qword}.include? value[:type]
value[:data] = value[:data].to_i
end
unless current_value[:type] == value[:type] && current_value[:data] == value[:data]
diff --git a/lib/chef/provider/subversion.rb b/lib/chef/provider/subversion.rb
index d28bb3c53a..dd3ece4786 100644
--- a/lib/chef/provider/subversion.rb
+++ b/lib/chef/provider/subversion.rb
@@ -36,7 +36,7 @@ class Chef
def load_current_resource
@current_resource = Chef::Resource::Subversion.new(new_resource.name)
- unless [:export, :force_export].include?(Array(new_resource.action).first)
+ unless %i{export force_export}.include?(Array(new_resource.action).first)
if current_revision = find_current_revision
current_resource.revision current_revision
end
diff --git a/lib/chef/provider/user.rb b/lib/chef/provider/user.rb
index da739e41ec..38fe233d76 100644
--- a/lib/chef/provider/user.rb
+++ b/lib/chef/provider/user.rb
@@ -109,7 +109,7 @@ class Chef
def compare_user
return true if !new_resource.home.nil? && Pathname.new(new_resource.home).cleanpath != Pathname.new(current_resource.home).cleanpath
- [ :comment, :shell, :password, :uid, :gid ].each do |user_attrib|
+ %i{comment shell password uid gid}.each do |user_attrib|
return true if !new_resource.send(user_attrib).nil? && new_resource.send(user_attrib).to_s != current_resource.send(user_attrib).to_s
end
diff --git a/lib/chef/provider/user/windows.rb b/lib/chef/provider/user/windows.rb
index 892759e93f..6d50e2c8ee 100644
--- a/lib/chef/provider/user/windows.rb
+++ b/lib/chef/provider/user/windows.rb
@@ -65,7 +65,7 @@ class Chef
logger.trace("#{new_resource} password has changed")
return true
end
- [ :uid, :comment, :home, :shell, :full_name ].any? do |user_attrib|
+ %i{uid comment home shell full_name}.any? do |user_attrib|
!new_resource.send(user_attrib).nil? && new_resource.send(user_attrib) != current_resource.send(user_attrib)
end
end
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index f1184094f1..d5f830063f 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -1197,9 +1197,9 @@ class Chef
#
# FORBIDDEN_IVARS do not show up when the resource is converted to JSON (ie. hidden from data_collector and sending to the chef server via #to_json/to_h/as_json/inspect)
- FORBIDDEN_IVARS = [:@run_context, :@logger, :@not_if, :@only_if, :@enclosing_provider, :@description, :@introduced, :@examples, :@validation_message, :@deprecated, :@default_description, :@skip_docs, :@executed_by_runner].freeze
+ FORBIDDEN_IVARS = %i{@run_context @logger @not_if @only_if @enclosing_provider @description @introduced @examples @validation_message @deprecated @default_description @skip_docs @executed_by_runner}.freeze
# HIDDEN_IVARS do not show up when the resource is displayed to the user as text (ie. in the error inspector output via #to_text)
- HIDDEN_IVARS = [:@allowed_actions, :@resource_name, :@source_line, :@run_context, :@logger, :@name, :@not_if, :@only_if, :@elapsed_time, :@enclosing_provider, :@description, :@introduced, :@examples, :@validation_message, :@deprecated, :@default_description, :@skip_docs, :@executed_by_runner].freeze
+ HIDDEN_IVARS = %i{@allowed_actions @resource_name @source_line @run_context @logger @name @not_if @only_if @elapsed_time @enclosing_provider @description @introduced @examples @validation_message @deprecated @default_description @skip_docs @executed_by_runner}.freeze
include Chef::Mixin::ConvertToClassName
extend Chef::Mixin::ConvertToClassName
diff --git a/lib/chef/resource/dsc_resource.rb b/lib/chef/resource/dsc_resource.rb
index 8d03231367..3ccc30f0fb 100644
--- a/lib/chef/resource/dsc_resource.rb
+++ b/lib/chef/resource/dsc_resource.rb
@@ -99,7 +99,7 @@ class Chef
# If the set method of the DSC resource indicate that a reboot
# is necessary, reboot_action provides the mechanism for a reboot to
# be requested.
- property :reboot_action, Symbol, default: :nothing, equal_to: [:nothing, :reboot_now, :request_reboot],
+ property :reboot_action, Symbol, default: :nothing, equal_to: %i{nothing reboot_now request_reboot},
introduced: "12.6",
description: "Use to request an immediate reboot or to queue a reboot using the :reboot_now (immediate reboot) or :request_reboot (queued reboot) actions built into the reboot resource."
diff --git a/lib/chef/resource/link.rb b/lib/chef/resource/link.rb
index 66388a6463..dd618845bf 100644
--- a/lib/chef/resource/link.rb
+++ b/lib/chef/resource/link.rb
@@ -57,7 +57,7 @@ class Chef
property :link_type, [String, Symbol],
description: "The type of link: :symbolic or :hard.",
coerce: proc { |arg| arg.kind_of?(String) ? arg.to_sym : arg },
- equal_to: [ :symbolic, :hard ], default: :symbolic
+ equal_to: %i{symbolic hard}, default: :symbolic
property :group, [String, Integer],
description: "A group name or ID number that identifies the group associated with a symbolic link.",
diff --git a/lib/chef/resource/log.rb b/lib/chef/resource/log.rb
index 4f76ea12de..98cf0fb204 100644
--- a/lib/chef/resource/log.rb
+++ b/lib/chef/resource/log.rb
@@ -43,7 +43,7 @@ class Chef
description: "The message to be added to a log file. If not specified we'll use the resource's name instead."
property :level, Symbol,
- equal_to: [ :debug, :info, :warn, :error, :fatal ], default: :info,
+ equal_to: %i{debug info warn error fatal}, default: :info,
description: "The logging level to display this message at."
allowed_actions :write
diff --git a/lib/chef/resource/registry_key.rb b/lib/chef/resource/registry_key.rb
index cd4edda5a9..a5c99313bf 100644
--- a/lib/chef/resource/registry_key.rb
+++ b/lib/chef/resource/registry_key.rb
@@ -88,7 +88,7 @@ class Chef
raise ArgumentError, "Missing name key in RegistryKey values hash" unless v.key?(:name)
v.each_key do |key|
- raise ArgumentError, "Bad key #{key} in RegistryKey values hash" unless [:name, :type, :data].include?(key)
+ raise ArgumentError, "Bad key #{key} in RegistryKey values hash" unless %i{name type data}.include?(key)
end
raise ArgumentError, "Type of name => #{v[:name]} should be string" unless v[:name].is_a?(String)
@@ -103,7 +103,7 @@ class Chef
end
property :recursive, [TrueClass, FalseClass], default: false
- property :architecture, Symbol, default: :machine, equal_to: [:machine, :x86_64, :i386]
+ property :architecture, Symbol, default: :machine, equal_to: %i{machine x86_64 i386}
private
@@ -123,7 +123,7 @@ class Chef
# Some data types may raise errors when sent as json. Returns true if this
# value's data may need to be converted to a checksum.
def needs_checksum?(value)
- unsafe_types = [:binary, :dword, :dword_big_endian, :qword]
+ unsafe_types = %i{binary dword dword_big_endian qword}
unsafe_types.include?(value[:type])
end
diff --git a/lib/chef/resource/remote_file.rb b/lib/chef/resource/remote_file.rb
index d654829ee7..7dcfeb3c2c 100644
--- a/lib/chef/resource/remote_file.rb
+++ b/lib/chef/resource/remote_file.rb
@@ -98,7 +98,7 @@ class Chef
property :remote_password, String, sensitive: true
- property :authentication, equal_to: [:remote, :local], default: :remote
+ property :authentication, equal_to: %i{remote local}, default: :remote
def after_created
validate_identity_platform(remote_user, remote_password, remote_domain)
diff --git a/lib/chef/resource/route.rb b/lib/chef/resource/route.rb
index 42302afe6a..ecd63966cf 100644
--- a/lib/chef/resource/route.rb
+++ b/lib/chef/resource/route.rb
@@ -50,7 +50,7 @@ class Chef
property :route_type, [Symbol, String],
description: "",
- equal_to: [:host, :net], default: :host, desired_state: false
+ equal_to: %i{host net}, default: :host, desired_state: false
end
end
end
diff --git a/lib/chef/resource/windows_ad_join.rb b/lib/chef/resource/windows_ad_join.rb
index e62b931a75..23faa60ee5 100644
--- a/lib/chef/resource/windows_ad_join.rb
+++ b/lib/chef/resource/windows_ad_join.rb
@@ -48,7 +48,7 @@ class Chef
description: "The path to the Organizational Unit where the host will be placed."
property :reboot, Symbol,
- equal_to: [:immediate, :delayed, :never, :request_reboot, :reboot_now],
+ equal_to: %i{immediate delayed never request_reboot reboot_now},
validation_message: "The reboot property accepts :immediate (reboot as soon as the resource completes), :delayed (reboot once the #{Chef::Dist::PRODUCT} run completes), and :never (Don't reboot)",
description: "Controls the system reboot behavior post domain joining. Reboot immediately, after the #{Chef::Dist::PRODUCT} run completes, or never. Note that a reboot is necessary for changes to take effect.",
default: :immediate
diff --git a/lib/chef/resource/windows_feature.rb b/lib/chef/resource/windows_feature.rb
index e937c6f990..cc80284019 100644
--- a/lib/chef/resource/windows_feature.rb
+++ b/lib/chef/resource/windows_feature.rb
@@ -44,7 +44,7 @@ class Chef
property :install_method, Symbol,
description: "The underlying installation method to use for feature installation. Specify ':windows_feature_dism' for DISM or ':windows_feature_powershell' for PowerShell.",
- equal_to: [:windows_feature_dism, :windows_feature_powershell, :windows_feature_servermanagercmd],
+ equal_to: %i{windows_feature_dism windows_feature_powershell windows_feature_servermanagercmd},
default: :windows_feature_dism
property :timeout, Integer,
diff --git a/lib/chef/resource/windows_firewall_rule.rb b/lib/chef/resource/windows_firewall_rule.rb
index f933ba9139..5ac38bc8b7 100644
--- a/lib/chef/resource/windows_firewall_rule.rb
+++ b/lib/chef/resource/windows_firewall_rule.rb
@@ -54,7 +54,7 @@ class Chef
description: "The remote port the firewall rule applies to."
property :direction, [Symbol, String],
- default: :inbound, equal_to: [:inbound, :outbound],
+ default: :inbound, equal_to: %i{inbound outbound},
description: "The direction of the firewall rule. Direction means either inbound or outbound traffic.",
coerce: proc { |d| d.is_a?(String) ? d.downcase.to_sym : d }
@@ -63,12 +63,12 @@ class Chef
description: "The protocol the firewall rule applies to."
property :firewall_action, [Symbol, String],
- default: :allow, equal_to: [:allow, :block, :notconfigured],
+ default: :allow, equal_to: %i{allow block notconfigured},
description: "The action of the firewall rule.",
coerce: proc { |f| f.is_a?(String) ? f.downcase.to_sym : f }
property :profile, [Symbol, String],
- default: :any, equal_to: [:public, :private, :domain, :any, :notapplicable],
+ default: :any, equal_to: %i{public private domain any notapplicable},
description: "The profile the firewall rule applies to.",
coerce: proc { |p| p.is_a?(String) ? p.downcase.to_sym : p }
@@ -79,7 +79,7 @@ class Chef
description: "The service the firewall rule applies to."
property :interface_type, [Symbol, String],
- default: :any, equal_to: [:any, :wireless, :wired, :remoteaccess],
+ default: :any, equal_to: %i{any wireless wired remoteaccess},
description: "The interface type the firewall rule applies to.",
coerce: proc { |i| i.is_a?(String) ? i.downcase.to_sym : i }
diff --git a/lib/chef/resource/windows_service.rb b/lib/chef/resource/windows_service.rb
index 91c3450603..b8ee4edf9c 100644
--- a/lib/chef/resource/windows_service.rb
+++ b/lib/chef/resource/windows_service.rb
@@ -58,7 +58,7 @@ class Chef
# - :manual
# - :disabled
# Reference: https://github.com/chef/win32-service/blob/ffi/lib/win32/windows/constants.rb#L49-L54
- property :startup_type, [Symbol], equal_to: [:automatic, :manual, :disabled], default: :automatic, coerce: proc { |x|
+ property :startup_type, [Symbol], equal_to: %i{automatic manual disabled}, default: :automatic, coerce: proc { |x|
if x.is_a?(Integer)
ALLOWED_START_TYPES.invert.fetch(x) do
Chef::Log.warn("Unsupported startup_type #{x}, falling back to :automatic")
diff --git a/lib/chef/resource/windows_task.rb b/lib/chef/resource/windows_task.rb
index db3eb11b96..0ce5bf2031 100644
--- a/lib/chef/resource/windows_task.rb
+++ b/lib/chef/resource/windows_task.rb
@@ -49,7 +49,7 @@ class Chef
property :password, String,
description: "The user’s password. The user property must be set if using this property."
- property :run_level, Symbol, equal_to: [:highest, :limited],
+ property :run_level, Symbol, equal_to: %i{highest limited},
description: "Run with ':limited' or ':highest' privileges.",
default: :limited
@@ -64,16 +64,16 @@ class Chef
property :frequency_modifier, [Integer, String],
default: 1
- property :frequency, Symbol, equal_to: [:minute,
- :hourly,
- :daily,
- :weekly,
- :monthly,
- :once,
- :on_logon,
- :onstart,
- :on_idle,
- :none],
+ property :frequency, Symbol, equal_to: %i{minute
+ hourly
+ daily
+ weekly
+ monthly
+ once
+ on_logon
+ onstart
+ on_idle
+ none},
description: "The frequency with which to run the task."
property :start_day, String,
@@ -175,7 +175,7 @@ class Chef
end
def validate_frequency(frequency)
- if frequency.nil? || !([:minute, :hourly, :daily, :weekly, :monthly, :once, :on_logon, :onstart, :on_idle, :none].include?(frequency))
+ if frequency.nil? || !(%i{minute hourly daily weekly monthly once on_logon onstart on_idle none}.include?(frequency))
raise ArgumentError, "Frequency needs to be provided. Valid frequencies are :minute, :hourly, :daily, :weekly, :monthly, :once, :on_logon, :onstart, :on_idle, :none."
end
end
@@ -201,7 +201,7 @@ class Chef
end
def validate_random_delay(random_delay, frequency)
- if [:on_logon, :onstart, :on_idle, :none].include? frequency
+ if %i{on_logon onstart on_idle none}.include? frequency
raise ArgumentError, "`random_delay` property is supported only for frequency :once, :minute, :hourly, :daily, :weekly and :monthly"
end
@@ -256,7 +256,7 @@ class Chef
alias non_system_user? password_required?
def validate_create_frequency_modifier(frequency, frequency_modifier)
- if ([:on_logon, :onstart, :on_idle, :none].include?(frequency)) && ( frequency_modifier != 1)
+ if (%i{on_logon onstart on_idle none}.include?(frequency)) && ( frequency_modifier != 1)
raise ArgumentError, "frequency_modifier property not supported with frequency :#{frequency}"
end
@@ -288,7 +288,7 @@ class Chef
end
def validate_create_day(day, frequency, frequency_modifier)
- raise ArgumentError, "day property is only valid for tasks that run monthly or weekly" unless [:weekly, :monthly].include?(frequency)
+ raise ArgumentError, "day property is only valid for tasks that run monthly or weekly" unless %i{weekly monthly}.include?(frequency)
# This has been verified with schtask.exe https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/schtasks#d-dayday--
# verified with earlier code if day "*" is given with frequency it raised exception Invalid value for /D option
diff --git a/lib/chef/resource/windows_uac.rb b/lib/chef/resource/windows_uac.rb
index f53767f4b8..c4d5b53c14 100644
--- a/lib/chef/resource/windows_uac.rb
+++ b/lib/chef/resource/windows_uac.rb
@@ -44,12 +44,12 @@ class Chef
property :consent_behavior_admins, Symbol,
description: 'Behavior of the elevation prompt for administrators in Admin Approval Mode. Sets HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA\ConsentPromptBehaviorAdmin.',
- equal_to: [:no_prompt, :secure_prompt_for_creds, :secure_prompt_for_consent, :prompt_for_creds, :prompt_for_consent, :prompt_for_consent_non_windows_binaries],
+ equal_to: %i{no_prompt secure_prompt_for_creds secure_prompt_for_consent prompt_for_creds prompt_for_consent prompt_for_consent_non_windows_binaries},
default: :prompt_for_consent_non_windows_binaries
property :consent_behavior_users, Symbol,
description: 'Behavior of the elevation prompt for standard users. Sets HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA\ConsentPromptBehaviorUser.',
- equal_to: [:auto_deny, :secure_prompt_for_creds, :prompt_for_creds],
+ equal_to: %i{auto_deny secure_prompt_for_creds prompt_for_creds},
default: :prompt_for_creds
action :configure do
@@ -79,14 +79,14 @@ class Chef
#
# @return [Integer]
def consent_behavior_admins_symbol_to_reg(sym)
- [:no_prompt, :secure_prompt_for_creds, :secure_prompt_for_consent, :prompt_for_creds, :prompt_for_consent, :prompt_for_consent_non_windows_binaries].index(sym)
+ %i{no_prompt secure_prompt_for_creds secure_prompt_for_consent prompt_for_creds prompt_for_consent prompt_for_consent_non_windows_binaries}.index(sym)
end
# converts the symbols we use in the consent_behavior_users property into numbers 0-2 based on their array index
#
# @return [Integer]
def consent_behavior_users_symbol_to_reg(sym)
- [:auto_deny, :secure_prompt_for_creds, :prompt_for_creds].index(sym)
+ %i{auto_deny secure_prompt_for_creds prompt_for_creds}.index(sym)
end
end
end
diff --git a/lib/chef/resource/windows_workgroup.rb b/lib/chef/resource/windows_workgroup.rb
index f455c013af..b1ae5c2b95 100644
--- a/lib/chef/resource/windows_workgroup.rb
+++ b/lib/chef/resource/windows_workgroup.rb
@@ -45,7 +45,7 @@ class Chef
desired_state: false
property :reboot, Symbol,
- equal_to: [:never, :request_reboot, :reboot_now],
+ equal_to: %i{never request_reboot reboot_now},
validation_message: "The reboot property accepts :immediate (reboot as soon as the resource completes), :delayed (reboot once the #{Chef::Dist::PRODUCT} run completes), and :never (Don't reboot)",
description: "Controls the system reboot behavior post workgroup joining. Reboot immediately, after the #{Chef::Dist::PRODUCT} run completes, or never. Note that a reboot is necessary for changes to take effect.",
coerce: proc { |x| clarify_reboot(x) },
diff --git a/lib/chef/resource_collection.rb b/lib/chef/resource_collection.rb
index 716f84b92c..31cc917a9f 100644
--- a/lib/chef/resource_collection.rb
+++ b/lib/chef/resource_collection.rb
@@ -87,9 +87,9 @@ class Chef
# Read-only methods are simple to delegate - doing that below
resource_list_methods = Enumerable.instance_methods +
- [:iterator, :all_resources, :[], :each, :execute_each_resource, :each_index, :empty?] -
+ %i{iterator all_resources \[\] each execute_each_resource each_index empty?} -
[:find] # find overridden below
- resource_set_methods = [:resources, :keys, :validate_lookup_spec!]
+ resource_set_methods = %i{resources keys validate_lookup_spec!}
def_delegators :resource_list, *resource_list_methods
def_delegators :resource_set, *resource_set_methods
diff --git a/lib/chef/resource_collection/resource_list.rb b/lib/chef/resource_collection/resource_list.rb
index 8afbd5dd06..5f69908a5e 100644
--- a/lib/chef/resource_collection/resource_list.rb
+++ b/lib/chef/resource_collection/resource_list.rb
@@ -36,7 +36,7 @@ class Chef
private :resources
# Delegate direct access methods to the @resources array
# 4 extra methods here are not included in the Enumerable's instance methods
- direct_access_methods = Enumerable.instance_methods + [ :[], :each, :each_index, :empty? ]
+ direct_access_methods = Enumerable.instance_methods + %i{\[\] each each_index empty?}
def_delegators :resources, *(direct_access_methods)
def initialize
diff --git a/lib/chef/version_class.rb b/lib/chef/version_class.rb
index f98673b019..68acaf1e44 100644
--- a/lib/chef/version_class.rb
+++ b/lib/chef/version_class.rb
@@ -33,7 +33,7 @@ class Chef
end
def <=>(other)
- [:major, :minor, :patch].each do |method|
+ %i{major minor patch}.each do |method|
version = send(method)
begin
ans = (version <=> other.send(method))
diff --git a/lib/chef/win32/api/crypto.rb b/lib/chef/win32/api/crypto.rb
index 1b73ac65d1..13828dd62a 100644
--- a/lib/chef/win32/api/crypto.rb
+++ b/lib/chef/win32/api/crypto.rb
@@ -47,15 +47,15 @@ class Chef
end
- safe_attach_function :CryptProtectData, [
- :PDATA_BLOB,
- :LPCWSTR,
- :PDATA_BLOB,
- :pointer,
- :PCRYPTPROTECT_PROMPTSTRUCT,
- :DWORD,
- :PDATA_BLOB,
- ], :BOOL
+ safe_attach_function :CryptProtectData, %i{
+ PDATA_BLOB
+ LPCWSTR
+ PDATA_BLOB
+ pointer
+ PCRYPTPROTECT_PROMPTSTRUCT
+ DWORD
+ PDATA_BLOB
+ }, :BOOL
end
end
diff --git a/lib/chef/win32/api/error.rb b/lib/chef/win32/api/error.rb
index 618ce266f6..79b65c8509 100644
--- a/lib/chef/win32/api/error.rb
+++ b/lib/chef/win32/api/error.rb
@@ -905,8 +905,8 @@ DWORD WINAPI FormatMessage(
__in_opt va_list *Arguments
);
=end
- safe_attach_function :FormatMessageA, [:DWORD, :HANDLE, :DWORD, :DWORD, :LPTSTR, :DWORD, :varargs], :DWORD
- safe_attach_function :FormatMessageW, [:DWORD, :HANDLE, :DWORD, :DWORD, :LPWSTR, :DWORD, :varargs], :DWORD
+ safe_attach_function :FormatMessageA, %i{DWORD HANDLE DWORD DWORD LPTSTR DWORD varargs}, :DWORD
+ safe_attach_function :FormatMessageW, %i{DWORD HANDLE DWORD DWORD LPWSTR DWORD varargs}, :DWORD
=begin
DWORD WINAPI GetLastError(void);
@@ -918,7 +918,7 @@ void WINAPI SetLastError(
);
=end
safe_attach_function :SetLastError, [:DWORD], :void
- safe_attach_function :SetLastErrorEx, [:DWORD, :DWORD], :void
+ safe_attach_function :SetLastErrorEx, %i{DWORD DWORD}, :void
=begin
UINT WINAPI GetErrorMode(void);s
=end
@@ -938,7 +938,7 @@ HMODULE WINAPI LoadLibraryEx(
_In_ DWORD dwFlags
);
=end
- safe_attach_function :LoadLibraryExW, [:LPCTSTR, :HANDLE, :DWORD], :HANDLE
+ safe_attach_function :LoadLibraryExW, %i{LPCTSTR HANDLE DWORD}, :HANDLE
=begin
https://msdn.microsoft.com/en-us/library/windows/desktop/ms683152(v=vs.85).aspx
diff --git a/lib/chef/win32/api/file.rb b/lib/chef/win32/api/file.rb
index eea46ce87d..bdc2d6f6e5 100644
--- a/lib/chef/win32/api/file.rb
+++ b/lib/chef/win32/api/file.rb
@@ -369,7 +369,7 @@ HANDLE WINAPI CreateFile(
__in_opt HANDLE hTemplateFile
);
=end
- safe_attach_function :CreateFileW, [:LPCTSTR, :DWORD, :DWORD, :LPSECURITY_ATTRIBUTES, :DWORD, :DWORD, :pointer], :HANDLE
+ safe_attach_function :CreateFileW, %i{LPCTSTR DWORD DWORD LPSECURITY_ATTRIBUTES DWORD DWORD pointer}, :HANDLE
=begin
BOOL WINAPI FindClose(
@@ -393,7 +393,7 @@ DWORD WINAPI GetFinalPathNameByHandle(
__in DWORD dwFlags
);
=end
- safe_attach_function :GetFinalPathNameByHandleW, [:HANDLE, :LPTSTR, :DWORD, :DWORD], :DWORD
+ safe_attach_function :GetFinalPathNameByHandleW, %i{HANDLE LPTSTR DWORD DWORD}, :DWORD
=begin
BOOL WINAPI GetFileInformationByHandle(
@@ -401,7 +401,7 @@ BOOL WINAPI GetFileInformationByHandle(
__out LPBY_HANDLE_FILE_INFORMATION lpFileInformation
);
=end
- safe_attach_function :GetFileInformationByHandle, [:HANDLE, :LPBY_HANDLE_FILE_INFORMATION], :BOOL
+ safe_attach_function :GetFileInformationByHandle, %i{HANDLE LPBY_HANDLE_FILE_INFORMATION}, :BOOL
=begin
HANDLE WINAPI FindFirstFile(
@@ -409,7 +409,7 @@ HANDLE WINAPI FindFirstFile(
__out LPWIN32_FIND_DATA lpFindFileData
);
=end
- safe_attach_function :FindFirstFileW, [:LPCTSTR, :LPWIN32_FIND_DATA], :HANDLE
+ safe_attach_function :FindFirstFileW, %i{LPCTSTR LPWIN32_FIND_DATA}, :HANDLE
=begin
BOOL WINAPI CreateHardLink(
@@ -418,7 +418,7 @@ BOOL WINAPI CreateHardLink(
__reserved LPSECURITY_ATTRIBUTES lpSecurityAttributes
);
=end
- safe_attach_function :CreateHardLinkW, [:LPCTSTR, :LPCTSTR, :LPSECURITY_ATTRIBUTES], :BOOLEAN
+ safe_attach_function :CreateHardLinkW, %i{LPCTSTR LPCTSTR LPSECURITY_ATTRIBUTES}, :BOOLEAN
=begin
BOOLEAN WINAPI CreateSymbolicLink(
@@ -427,7 +427,7 @@ BOOLEAN WINAPI CreateSymbolicLink(
__in DWORD dwFlags
);
=end
- safe_attach_function :CreateSymbolicLinkW, [:LPTSTR, :LPTSTR, :DWORD], :BOOLEAN
+ safe_attach_function :CreateSymbolicLinkW, %i{LPTSTR LPTSTR DWORD}, :BOOLEAN
=begin
DWORD WINAPI GetLongPathName(
@@ -436,7 +436,7 @@ DWORD WINAPI GetLongPathName(
__in DWORD cchBuffer
);
=end
- safe_attach_function :GetLongPathNameW, [:LPCTSTR, :LPTSTR, :DWORD], :DWORD
+ safe_attach_function :GetLongPathNameW, %i{LPCTSTR LPTSTR DWORD}, :DWORD
=begin
DWORD WINAPI GetShortPathName(
@@ -445,7 +445,7 @@ DWORD WINAPI GetShortPathName(
__in DWORD cchBuffer
);
=end
- safe_attach_function :GetShortPathNameW, [:LPCTSTR, :LPTSTR, :DWORD], :DWORD
+ safe_attach_function :GetShortPathNameW, %i{LPCTSTR LPTSTR DWORD}, :DWORD
=begin
BOOL WINAPI DeviceIoControl(
@@ -459,7 +459,7 @@ BOOL WINAPI DeviceIoControl(
__inout_opt LPOVERLAPPED lpOverlapped
);
=end
- safe_attach_function :DeviceIoControl, [:HANDLE, :DWORD, :LPVOID, :DWORD, :LPVOID, :DWORD, :LPDWORD, :pointer], :BOOL
+ safe_attach_function :DeviceIoControl, %i{HANDLE DWORD LPVOID DWORD LPVOID DWORD LPDWORD pointer}, :BOOL
# BOOL WINAPI DeleteVolumeMountPoint(
# _In_ LPCTSTR lpszVolumeMountPoint
@@ -470,14 +470,14 @@ BOOL WINAPI DeviceIoControl(
# _In_ LPCTSTR lpszVolumeMountPoint,
# _In_ LPCTSTR lpszVolumeName
# );
- safe_attach_function :SetVolumeMountPointW, [:LPCTSTR, :LPCTSTR], :BOOL
+ safe_attach_function :SetVolumeMountPointW, %i{LPCTSTR LPCTSTR}, :BOOL
# BOOL WINAPI GetVolumeNameForVolumeMountPoint(
# _In_ LPCTSTR lpszVolumeMountPoint,
# _Out_ LPTSTR lpszVolumeName,
# _In_ DWORD cchBufferLength
# );
- safe_attach_function :GetVolumeNameForVolumeMountPointW, [:LPCTSTR, :LPTSTR, :DWORD], :BOOL
+ safe_attach_function :GetVolumeNameForVolumeMountPointW, %i{LPCTSTR LPTSTR DWORD}, :BOOL
=begin
BOOL WINAPI GetFileVersionInfo(
@@ -487,7 +487,7 @@ BOOL WINAPI GetFileVersionInfo(
_Out_ LPVOID lpData
);
=end
- safe_attach_function :GetFileVersionInfoW, [:LPCTSTR, :DWORD, :DWORD, :LPVOID], :BOOL
+ safe_attach_function :GetFileVersionInfoW, %i{LPCTSTR DWORD DWORD LPVOID}, :BOOL
=begin
DWORD WINAPI GetFileVersionInfoSize(
@@ -495,7 +495,7 @@ DWORD WINAPI GetFileVersionInfoSize(
_Out_opt_ LPDWORD lpdwHandle
);
=end
- safe_attach_function :GetFileVersionInfoSizeW, [:LPCTSTR, :LPDWORD], :DWORD
+ safe_attach_function :GetFileVersionInfoSizeW, %i{LPCTSTR LPDWORD}, :DWORD
=begin
BOOL WINAPI VerQueryValue(
@@ -505,7 +505,7 @@ BOOL WINAPI VerQueryValue(
_Out_ PUINT puLen
);
=end
- safe_attach_function :VerQueryValueW, [:LPCVOID, :LPCTSTR, :LPVOID, :PUINT], :BOOL
+ safe_attach_function :VerQueryValueW, %i{LPCVOID LPCTSTR LPVOID PUINT}, :BOOL
###############################################
# Helpers
diff --git a/lib/chef/win32/api/installer.rb b/lib/chef/win32/api/installer.rb
index 118afe8c8f..5af1be7eba 100644
--- a/lib/chef/win32/api/installer.rb
+++ b/lib/chef/win32/api/installer.rb
@@ -44,7 +44,7 @@ UINT MsiOpenPackage(
_Out_ MSIHANDLE *hProduct
);
=end
- safe_attach_function :msi_open_package, :MsiOpenPackageExA, [ :string, :int, :pointer ], :int
+ safe_attach_function :msi_open_package, :MsiOpenPackageExA, %i{string int pointer}, :int
=begin
UINT MsiGetProductProperty(
@@ -54,7 +54,7 @@ UINT MsiGetProductProperty(
_Inout_ DWORD *pcchValueBuf
);
=end
- safe_attach_function :msi_get_product_property, :MsiGetProductPropertyA, [ :pointer, :pointer, :pointer, :pointer ], :int
+ safe_attach_function :msi_get_product_property, :MsiGetProductPropertyA, %i{pointer pointer pointer pointer}, :int
=begin
UINT MsiGetProductInfo(
@@ -64,7 +64,7 @@ UINT MsiGetProductInfo(
_Inout_ DWORD *pcchValueBuf
);
=end
- safe_attach_function :msi_get_product_info, :MsiGetProductInfoA, [ :pointer, :pointer, :pointer, :pointer ], :int
+ safe_attach_function :msi_get_product_info, :MsiGetProductInfoA, %i{pointer pointer pointer pointer}, :int
=begin
UINT MsiCloseHandle(
diff --git a/lib/chef/win32/api/memory.rb b/lib/chef/win32/api/memory.rb
index 369ab5e650..cd7d9f0eb0 100644
--- a/lib/chef/win32/api/memory.rb
+++ b/lib/chef/win32/api/memory.rb
@@ -56,7 +56,7 @@ HLOCAL WINAPI LocalAlloc(
__in SIZE_T uBytes
);
=end
- safe_attach_function :LocalAlloc, [ :UINT, :SIZE_T ], :pointer
+ safe_attach_function :LocalAlloc, %i{UINT SIZE_T}, :pointer
=begin
UINT WINAPI LocalFlags(
@@ -79,7 +79,7 @@ HLOCAL WINAPI LocalReAlloc(
__in UINT uFlags
);
=end
- safe_attach_function :LocalReAlloc, [ :pointer, :SIZE_T, :UINT ], :pointer
+ safe_attach_function :LocalReAlloc, %i{pointer SIZE_T UINT}, :pointer
=begin
UINT WINAPI LocalSize(
@@ -95,9 +95,9 @@ UINT WINAPI LocalSize(
ffi_lib FFI::Library::LIBC
safe_attach_function :malloc, [:size_t], :pointer
safe_attach_function :calloc, [:size_t], :pointer
- safe_attach_function :realloc, [:pointer, :size_t], :pointer
+ safe_attach_function :realloc, %i{pointer size_t}, :pointer
safe_attach_function :free, [:pointer], :void
- safe_attach_function :memcpy, [:pointer, :pointer, :size_t], :pointer
+ safe_attach_function :memcpy, %i{pointer pointer size_t}, :pointer
end
end
diff --git a/lib/chef/win32/api/net.rb b/lib/chef/win32/api/net.rb
index 392a442962..182c31cf66 100644
--- a/lib/chef/win32/api/net.rb
+++ b/lib/chef/win32/api/net.rb
@@ -169,9 +169,9 @@ class Chef
# _In_ LPBYTE buf,
# _Out_ LPDWORD parm_err
# );
- safe_attach_function :NetLocalGroupAdd, [
- :LPCWSTR, :DWORD, :LPBYTE, :LPDWORD
- ], :DWORD
+ safe_attach_function :NetLocalGroupAdd, %i{
+ LPCWSTR DWORD LPBYTE LPDWORD
+ }, :DWORD
# NET_API_STATUS NetLocalGroupSetInfo(
# _In_ LPCWSTR servername,
@@ -180,15 +180,15 @@ class Chef
# _In_ LPBYTE buf,
# _Out_ LPDWORD parm_err
# );
- safe_attach_function :NetLocalGroupSetInfo, [
- :LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :LPDWORD
- ], :DWORD
+ safe_attach_function :NetLocalGroupSetInfo, %i{
+ LPCWSTR LPCWSTR DWORD LPBYTE LPDWORD
+ }, :DWORD
# NET_API_STATUS NetLocalGroupDel(
# _In_ LPCWSTR servername,
# _In_ LPCWSTR groupname
# );
- safe_attach_function :NetLocalGroupDel, [:LPCWSTR, :LPCWSTR], :DWORD
+ safe_attach_function :NetLocalGroupDel, %i{LPCWSTR LPCWSTR}, :DWORD
# NET_API_STATUS NetLocalGroupGetMembers(
# _In_ LPCWSTR servername,
@@ -200,10 +200,10 @@ class Chef
# _Out_ LPDWORD totalentries,
# _Inout_ PDWORD_PTR resumehandle
# );
- safe_attach_function :NetLocalGroupGetMembers, [
- :LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :DWORD,
- :LPDWORD, :LPDWORD, :PDWORD_PTR
- ], :DWORD
+ safe_attach_function :NetLocalGroupGetMembers, %i{
+ LPCWSTR LPCWSTR DWORD LPBYTE DWORD
+ LPDWORD LPDWORD PDWORD_PTR
+ }, :DWORD
# NET_API_STATUS NetUserEnum(
# _In_ LPCWSTR servername,
@@ -215,10 +215,10 @@ class Chef
# _Out_ LPDWORD totalentries,
# _Inout_ LPDWORD resume_handle
# );
- safe_attach_function :NetUserEnum, [
- :LPCWSTR, :DWORD, :DWORD, :LPBYTE,
- :DWORD, :LPDWORD, :LPDWORD, :LPDWORD
- ], :DWORD
+ safe_attach_function :NetUserEnum, %i{
+ LPCWSTR DWORD DWORD LPBYTE
+ DWORD LPDWORD LPDWORD LPDWORD
+ }, :DWORD
# NET_API_STATUS NetApiBufferFree(
# _In_ LPVOID Buffer
@@ -231,9 +231,9 @@ class Chef
# _In_ LPBYTE buf,
# _Out_ LPDWORD parm_err
# );
- safe_attach_function :NetUserAdd, [
- :LMSTR, :DWORD, :LPBYTE, :LPDWORD
- ], :DWORD
+ safe_attach_function :NetUserAdd, %i{
+ LMSTR DWORD LPBYTE LPDWORD
+ }, :DWORD
# NET_API_STATUS NetLocalGroupAddMembers(
# _In_ LPCWSTR servername,
@@ -242,9 +242,9 @@ class Chef
# _In_ LPBYTE buf,
# _In_ DWORD totalentries
# );
- safe_attach_function :NetLocalGroupAddMembers, [
- :LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :DWORD
- ], :DWORD
+ safe_attach_function :NetLocalGroupAddMembers, %i{
+ LPCWSTR LPCWSTR DWORD LPBYTE DWORD
+ }, :DWORD
# NET_API_STATUS NetLocalGroupSetMembers(
# _In_ LPCWSTR servername,
@@ -253,9 +253,9 @@ class Chef
# _In_ LPBYTE buf,
# _In_ DWORD totalentries
# );
- safe_attach_function :NetLocalGroupSetMembers, [
- :LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :DWORD
- ], :DWORD
+ safe_attach_function :NetLocalGroupSetMembers, %i{
+ LPCWSTR LPCWSTR DWORD LPBYTE DWORD
+ }, :DWORD
# NET_API_STATUS NetLocalGroupDelMembers(
# _In_ LPCWSTR servername,
@@ -264,9 +264,9 @@ class Chef
# _In_ LPBYTE buf,
# _In_ DWORD totalentries
# );
- safe_attach_function :NetLocalGroupDelMembers, [
- :LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :DWORD
- ], :DWORD
+ safe_attach_function :NetLocalGroupDelMembers, %i{
+ LPCWSTR LPCWSTR DWORD LPBYTE DWORD
+ }, :DWORD
# NET_API_STATUS NetUserGetInfo(
# _In_ LPCWSTR servername,
@@ -274,9 +274,9 @@ class Chef
# _In_ DWORD level,
# _Out_ LPBYTE *bufptr
# );
- safe_attach_function :NetUserGetInfo, [
- :LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE
- ], :DWORD
+ safe_attach_function :NetUserGetInfo, %i{
+ LPCWSTR LPCWSTR DWORD LPBYTE
+ }, :DWORD
# NET_API_STATUS NetApiBufferFree(
# _In_ LPVOID Buffer
@@ -290,22 +290,22 @@ class Chef
# _In_ LPBYTE buf,
# _Out_ LPDWORD parm_err
# );
- safe_attach_function :NetUserSetInfo, [
- :LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :LPDWORD
- ], :DWORD
+ safe_attach_function :NetUserSetInfo, %i{
+ LPCWSTR LPCWSTR DWORD LPBYTE LPDWORD
+ }, :DWORD
# NET_API_STATUS NetUserDel(
# _In_ LPCWSTR servername,
# _In_ LPCWSTR username
# );
- safe_attach_function :NetUserDel, [:LPCWSTR, :LPCWSTR], :DWORD
+ safe_attach_function :NetUserDel, %i{LPCWSTR LPCWSTR}, :DWORD
# NET_API_STATUS NetUseDel(
# _In_ LMSTR UncServerName,
# _In_ LMSTR UseName,
# _In_ DWORD ForceCond
# );
- safe_attach_function :NetUseDel, [:LMSTR, :LMSTR, :DWORD], :DWORD
+ safe_attach_function :NetUseDel, %i{LMSTR LMSTR DWORD}, :DWORD
# NET_API_STATUS NetUseGetInfo(
# _In_ LMSTR UncServerName,
@@ -313,7 +313,7 @@ class Chef
# _In_ DWORD Level,
# _Out_ LPBYTE *BufPtr
# );
- safe_attach_function :NetUseGetInfo, [:LMSTR, :LMSTR, :DWORD, :pointer], :DWORD
+ safe_attach_function :NetUseGetInfo, %i{LMSTR LMSTR DWORD pointer}, :DWORD
# NET_API_STATUS NetUseAdd(
# _In_ LMSTR UncServerName,
@@ -321,7 +321,7 @@ class Chef
# _In_ LPBYTE Buf,
# _Out_ LPDWORD ParmError
# );
- safe_attach_function :NetUseAdd, [:LMSTR, :DWORD, :LPBYTE, :LPDWORD], :DWORD
+ safe_attach_function :NetUseAdd, %i{LMSTR DWORD LPBYTE LPDWORD}, :DWORD
end
end
end
diff --git a/lib/chef/win32/api/process.rb b/lib/chef/win32/api/process.rb
index 3ac6a5c222..81a411e099 100644
--- a/lib/chef/win32/api/process.rb
+++ b/lib/chef/win32/api/process.rb
@@ -31,10 +31,10 @@ class Chef
ffi_lib "kernel32"
safe_attach_function :GetCurrentProcess, [], :HANDLE
- safe_attach_function :GetProcessHandleCount, [ :HANDLE, :LPDWORD ], :BOOL
+ safe_attach_function :GetProcessHandleCount, %i{HANDLE LPDWORD}, :BOOL
safe_attach_function :GetProcessId, [ :HANDLE ], :DWORD
safe_attach_function :CloseHandle, [ :HANDLE ], :BOOL
- safe_attach_function :IsWow64Process, [ :HANDLE, :PBOOL ], :BOOL
+ safe_attach_function :IsWow64Process, %i{HANDLE PBOOL}, :BOOL
end
end
diff --git a/lib/chef/win32/api/psapi.rb b/lib/chef/win32/api/psapi.rb
index 852cb9710b..491fe22c50 100644
--- a/lib/chef/win32/api/psapi.rb
+++ b/lib/chef/win32/api/psapi.rb
@@ -43,7 +43,7 @@ class Chef
ffi_lib "psapi"
- safe_attach_function :GetProcessMemoryInfo, [ :HANDLE, :pointer, :DWORD ], :BOOL
+ safe_attach_function :GetProcessMemoryInfo, %i{HANDLE pointer DWORD}, :BOOL
end
end
diff --git a/lib/chef/win32/api/registry.rb b/lib/chef/win32/api/registry.rb
index c368add37a..49f0da0010 100644
--- a/lib/chef/win32/api/registry.rb
+++ b/lib/chef/win32/api/registry.rb
@@ -36,14 +36,14 @@ class Chef
# _In_ REGSAM samDesired,
# _Reserved_ DWORD Reserved
# );
- safe_attach_function :RegDeleteKeyExW, [ :HKEY, :LPCTSTR, :LONG, :DWORD ], :LONG
- safe_attach_function :RegDeleteKeyExA, [ :HKEY, :LPCTSTR, :LONG, :DWORD ], :LONG
+ safe_attach_function :RegDeleteKeyExW, %i{HKEY LPCTSTR LONG DWORD}, :LONG
+ safe_attach_function :RegDeleteKeyExA, %i{HKEY LPCTSTR LONG DWORD}, :LONG
# LONG WINAPI RegDeleteValue(
# _In_ HKEY hKey,
# _In_opt_ LPCTSTR lpValueName
# );
- safe_attach_function :RegDeleteValueW, [ :HKEY, :LPCTSTR ], :LONG
+ safe_attach_function :RegDeleteValueW, %i{HKEY LPCTSTR}, :LONG
end
end
diff --git a/lib/chef/win32/api/security.rb b/lib/chef/win32/api/security.rb
index a856fbd0a1..b651283758 100644
--- a/lib/chef/win32/api/security.rb
+++ b/lib/chef/win32/api/security.rb
@@ -216,21 +216,21 @@ class Chef
# Win32 API Bindings
###############################################
- SE_OBJECT_TYPE = enum :SE_OBJECT_TYPE, [
- :SE_UNKNOWN_OBJECT_TYPE,
- :SE_FILE_OBJECT,
- :SE_SERVICE,
- :SE_PRINTER,
- :SE_REGISTRY_KEY,
- :SE_LMSHARE,
- :SE_KERNEL_OBJECT,
- :SE_WINDOW_OBJECT,
- :SE_DS_OBJECT,
- :SE_DS_OBJECT_ALL,
- :SE_PROVIDER_DEFINED_OBJECT,
- :SE_WMIGUID_OBJECT,
- :SE_REGISTRY_WOW64_32KEY,
- ]
+ SE_OBJECT_TYPE = enum :SE_OBJECT_TYPE, %i{
+ SE_UNKNOWN_OBJECT_TYPE
+ SE_FILE_OBJECT
+ SE_SERVICE
+ SE_PRINTER
+ SE_REGISTRY_KEY
+ SE_LMSHARE
+ SE_KERNEL_OBJECT
+ SE_WINDOW_OBJECT
+ SE_DS_OBJECT
+ SE_DS_OBJECT_ALL
+ SE_PROVIDER_DEFINED_OBJECT
+ SE_WMIGUID_OBJECT
+ SE_REGISTRY_WOW64_32KEY
+ }
SID_NAME_USE = enum :SID_NAME_USE, [
:SidTypeUser, 1,
@@ -298,12 +298,12 @@ class Chef
end
# https://msdn.microsoft.com/en-us/library/windows/desktop/aa379572%28v=vs.85%29.aspx
- SECURITY_IMPERSONATION_LEVEL = enum :SECURITY_IMPERSONATION_LEVEL, [
- :SecurityAnonymous,
- :SecurityIdentification,
- :SecurityImpersonation,
- :SecurityDelegation,
- ]
+ SECURITY_IMPERSONATION_LEVEL = enum :SECURITY_IMPERSONATION_LEVEL, %i{
+ SecurityAnonymous
+ SecurityIdentification
+ SecurityImpersonation
+ SecurityDelegation
+ }
# https://msdn.microsoft.com/en-us/library/windows/desktop/bb530718%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
ELEVATION_TYPE = enum :ELEVATION_TYPE, [
@@ -415,58 +415,58 @@ class Chef
ffi_lib "advapi32"
- safe_attach_function :AccessCheck, [:pointer, :HANDLE, :DWORD, :pointer, :pointer, :pointer, :pointer, :pointer], :BOOL
- safe_attach_function :AddAce, [ :pointer, :DWORD, :DWORD, :LPVOID, :DWORD ], :BOOL
- safe_attach_function :AddAccessAllowedAce, [ :pointer, :DWORD, :DWORD, :pointer ], :BOOL
- safe_attach_function :AddAccessAllowedAceEx, [ :pointer, :DWORD, :DWORD, :DWORD, :pointer ], :BOOL
- safe_attach_function :AddAccessDeniedAce, [ :pointer, :DWORD, :DWORD, :pointer ], :BOOL
- safe_attach_function :AddAccessDeniedAceEx, [ :pointer, :DWORD, :DWORD, :DWORD, :pointer ], :BOOL
- safe_attach_function :AdjustTokenPrivileges, [ :HANDLE, :BOOL, :pointer, :DWORD, :pointer, :PDWORD ], :BOOL
- safe_attach_function :ConvertSidToStringSidA, [ :pointer, :pointer ], :BOOL
- safe_attach_function :ConvertStringSidToSidW, [ :pointer, :pointer ], :BOOL
- safe_attach_function :DeleteAce, [ :pointer, :DWORD ], :BOOL
- safe_attach_function :DuplicateToken, [:HANDLE, :SECURITY_IMPERSONATION_LEVEL, :PHANDLE], :BOOL
- safe_attach_function :EqualSid, [ :pointer, :pointer ], :BOOL
+ safe_attach_function :AccessCheck, %i{pointer HANDLE DWORD pointer pointer pointer pointer pointer}, :BOOL
+ safe_attach_function :AddAce, %i{pointer DWORD DWORD LPVOID DWORD}, :BOOL
+ safe_attach_function :AddAccessAllowedAce, %i{pointer DWORD DWORD pointer}, :BOOL
+ safe_attach_function :AddAccessAllowedAceEx, %i{pointer DWORD DWORD DWORD pointer}, :BOOL
+ safe_attach_function :AddAccessDeniedAce, %i{pointer DWORD DWORD pointer}, :BOOL
+ safe_attach_function :AddAccessDeniedAceEx, %i{pointer DWORD DWORD DWORD pointer}, :BOOL
+ safe_attach_function :AdjustTokenPrivileges, %i{HANDLE BOOL pointer DWORD pointer PDWORD}, :BOOL
+ safe_attach_function :ConvertSidToStringSidA, %i{pointer pointer}, :BOOL
+ safe_attach_function :ConvertStringSidToSidW, %i{pointer pointer}, :BOOL
+ safe_attach_function :DeleteAce, %i{pointer DWORD}, :BOOL
+ safe_attach_function :DuplicateToken, %i{HANDLE SECURITY_IMPERSONATION_LEVEL PHANDLE}, :BOOL
+ safe_attach_function :EqualSid, %i{pointer pointer}, :BOOL
safe_attach_function :FreeSid, [ :pointer ], :pointer
- safe_attach_function :GetAce, [ :pointer, :DWORD, :pointer ], :BOOL
- safe_attach_function :GetFileSecurityW, [:LPCWSTR, :DWORD, :pointer, :DWORD, :pointer], :BOOL
+ safe_attach_function :GetAce, %i{pointer DWORD pointer}, :BOOL
+ safe_attach_function :GetFileSecurityW, %i{LPCWSTR DWORD pointer DWORD pointer}, :BOOL
safe_attach_function :GetLengthSid, [ :pointer ], :DWORD
- safe_attach_function :GetNamedSecurityInfoW, [ :LPWSTR, :SE_OBJECT_TYPE, :DWORD, :pointer, :pointer, :pointer, :pointer, :pointer ], :DWORD
- safe_attach_function :GetSecurityDescriptorControl, [ :pointer, :PWORD, :LPDWORD], :BOOL
- safe_attach_function :GetSecurityDescriptorDacl, [ :pointer, :LPBOOL, :pointer, :LPBOOL ], :BOOL
- safe_attach_function :GetSecurityDescriptorGroup, [ :pointer, :pointer, :LPBOOL], :BOOL
- safe_attach_function :GetSecurityDescriptorOwner, [ :pointer, :pointer, :LPBOOL], :BOOL
- safe_attach_function :GetSecurityDescriptorSacl, [ :pointer, :LPBOOL, :pointer, :LPBOOL ], :BOOL
- safe_attach_function :InitializeAcl, [ :pointer, :DWORD, :DWORD ], :BOOL
- safe_attach_function :InitializeSecurityDescriptor, [ :pointer, :DWORD ], :BOOL
+ safe_attach_function :GetNamedSecurityInfoW, %i{LPWSTR SE_OBJECT_TYPE DWORD pointer pointer pointer pointer pointer}, :DWORD
+ safe_attach_function :GetSecurityDescriptorControl, %i{pointer PWORD LPDWORD}, :BOOL
+ safe_attach_function :GetSecurityDescriptorDacl, %i{pointer LPBOOL pointer LPBOOL}, :BOOL
+ safe_attach_function :GetSecurityDescriptorGroup, %i{pointer pointer LPBOOL}, :BOOL
+ safe_attach_function :GetSecurityDescriptorOwner, %i{pointer pointer LPBOOL}, :BOOL
+ safe_attach_function :GetSecurityDescriptorSacl, %i{pointer LPBOOL pointer LPBOOL}, :BOOL
+ safe_attach_function :InitializeAcl, %i{pointer DWORD DWORD}, :BOOL
+ safe_attach_function :InitializeSecurityDescriptor, %i{pointer DWORD}, :BOOL
safe_attach_function :IsValidAcl, [ :pointer ], :BOOL
safe_attach_function :IsValidSecurityDescriptor, [ :pointer ], :BOOL
safe_attach_function :IsValidSid, [ :pointer ], :BOOL
- safe_attach_function :LookupAccountNameW, [ :LPCWSTR, :LPCWSTR, :pointer, :LPDWORD, :LPWSTR, :LPDWORD, :pointer ], :BOOL
- safe_attach_function :LookupAccountSidW, [ :LPCWSTR, :pointer, :LPWSTR, :LPDWORD, :LPWSTR, :LPDWORD, :pointer ], :BOOL
- safe_attach_function :LookupPrivilegeNameW, [ :LPCWSTR, :PLUID, :LPWSTR, :LPDWORD ], :BOOL
- safe_attach_function :LookupPrivilegeDisplayNameW, [ :LPCWSTR, :LPCWSTR, :LPWSTR, :LPDWORD, :LPDWORD ], :BOOL
- safe_attach_function :LookupPrivilegeValueW, [ :LPCWSTR, :LPCWSTR, :PLUID ], :BOOL
- safe_attach_function :LsaAddAccountRights, [ :pointer, :pointer, :pointer, :ULONG ], :NTSTATUS
- safe_attach_function :LsaRemoveAccountRights, [ :pointer, :pointer, :BOOL, :pointer, :ULONG ], :NTSTATUS
+ safe_attach_function :LookupAccountNameW, %i{LPCWSTR LPCWSTR pointer LPDWORD LPWSTR LPDWORD pointer}, :BOOL
+ safe_attach_function :LookupAccountSidW, %i{LPCWSTR pointer LPWSTR LPDWORD LPWSTR LPDWORD pointer}, :BOOL
+ safe_attach_function :LookupPrivilegeNameW, %i{LPCWSTR PLUID LPWSTR LPDWORD}, :BOOL
+ safe_attach_function :LookupPrivilegeDisplayNameW, %i{LPCWSTR LPCWSTR LPWSTR LPDWORD LPDWORD}, :BOOL
+ safe_attach_function :LookupPrivilegeValueW, %i{LPCWSTR LPCWSTR PLUID}, :BOOL
+ safe_attach_function :LsaAddAccountRights, %i{pointer pointer pointer ULONG}, :NTSTATUS
+ safe_attach_function :LsaRemoveAccountRights, %i{pointer pointer BOOL pointer ULONG}, :NTSTATUS
safe_attach_function :LsaClose, [ :LSA_HANDLE ], :NTSTATUS
- safe_attach_function :LsaEnumerateAccountRights, [ :LSA_HANDLE, :PSID, :PLSA_UNICODE_STRING, :PULONG ], :NTSTATUS
+ safe_attach_function :LsaEnumerateAccountRights, %i{LSA_HANDLE PSID PLSA_UNICODE_STRING PULONG}, :NTSTATUS
safe_attach_function :LsaFreeMemory, [ :PVOID ], :NTSTATUS
safe_attach_function :LsaNtStatusToWinError, [ :NTSTATUS ], :ULONG
- safe_attach_function :LsaOpenPolicy, [ :PLSA_UNICODE_STRING, :PLSA_OBJECT_ATTRIBUTES, :DWORD, :PLSA_HANDLE ], :NTSTATUS
- safe_attach_function :MakeAbsoluteSD, [ :pointer, :pointer, :LPDWORD, :pointer, :LPDWORD, :pointer, :LPDWORD, :pointer, :LPDWORD, :pointer, :LPDWORD], :BOOL
- safe_attach_function :MapGenericMask, [ :PDWORD, :PGENERICMAPPING ], :void
- safe_attach_function :OpenProcessToken, [ :HANDLE, :DWORD, :PHANDLE ], :BOOL
- safe_attach_function :QuerySecurityAccessMask, [ :DWORD, :LPDWORD ], :void
- safe_attach_function :SetFileSecurityW, [ :LPWSTR, :DWORD, :pointer ], :BOOL
- safe_attach_function :SetNamedSecurityInfoW, [ :LPWSTR, :SE_OBJECT_TYPE, :DWORD, :pointer, :pointer, :pointer, :pointer ], :DWORD
- safe_attach_function :SetSecurityAccessMask, [ :DWORD, :LPDWORD ], :void
- safe_attach_function :SetSecurityDescriptorDacl, [ :pointer, :BOOL, :pointer, :BOOL ], :BOOL
- safe_attach_function :SetSecurityDescriptorGroup, [ :pointer, :pointer, :BOOL ], :BOOL
- safe_attach_function :SetSecurityDescriptorOwner, [ :pointer, :pointer, :BOOL ], :BOOL
- safe_attach_function :SetSecurityDescriptorSacl, [ :pointer, :BOOL, :pointer, :BOOL ], :BOOL
- safe_attach_function :GetTokenInformation, [ :HANDLE, :TOKEN_INFORMATION_CLASS, :pointer, :DWORD, :PDWORD ], :BOOL
- safe_attach_function :LogonUserW, [:LPTSTR, :LPTSTR, :LPTSTR, :DWORD, :DWORD, :PHANDLE], :BOOL
+ safe_attach_function :LsaOpenPolicy, %i{PLSA_UNICODE_STRING PLSA_OBJECT_ATTRIBUTES DWORD PLSA_HANDLE}, :NTSTATUS
+ safe_attach_function :MakeAbsoluteSD, %i{pointer pointer LPDWORD pointer LPDWORD pointer LPDWORD pointer LPDWORD pointer LPDWORD}, :BOOL
+ safe_attach_function :MapGenericMask, %i{PDWORD PGENERICMAPPING}, :void
+ safe_attach_function :OpenProcessToken, %i{HANDLE DWORD PHANDLE}, :BOOL
+ safe_attach_function :QuerySecurityAccessMask, %i{DWORD LPDWORD}, :void
+ safe_attach_function :SetFileSecurityW, %i{LPWSTR DWORD pointer}, :BOOL
+ safe_attach_function :SetNamedSecurityInfoW, %i{LPWSTR SE_OBJECT_TYPE DWORD pointer pointer pointer pointer}, :DWORD
+ safe_attach_function :SetSecurityAccessMask, %i{DWORD LPDWORD}, :void
+ safe_attach_function :SetSecurityDescriptorDacl, %i{pointer BOOL pointer BOOL}, :BOOL
+ safe_attach_function :SetSecurityDescriptorGroup, %i{pointer pointer BOOL}, :BOOL
+ safe_attach_function :SetSecurityDescriptorOwner, %i{pointer pointer BOOL}, :BOOL
+ safe_attach_function :SetSecurityDescriptorSacl, %i{pointer BOOL pointer BOOL}, :BOOL
+ safe_attach_function :GetTokenInformation, %i{HANDLE TOKEN_INFORMATION_CLASS pointer DWORD PDWORD}, :BOOL
+ safe_attach_function :LogonUserW, %i{LPTSTR LPTSTR LPTSTR DWORD DWORD PHANDLE}, :BOOL
safe_attach_function :ImpersonateLoggedOnUser, [:HANDLE], :BOOL
safe_attach_function :RevertToSelf, [], :BOOL
diff --git a/lib/chef/win32/api/synchronization.rb b/lib/chef/win32/api/synchronization.rb
index 19ca24bf00..aaedf2dd89 100644
--- a/lib/chef/win32/api/synchronization.rb
+++ b/lib/chef/win32/api/synchronization.rb
@@ -56,8 +56,8 @@ HANDLE WINAPI CreateMutex(
_In_opt_ LPCTSTR lpName
);
=end
- safe_attach_function :CreateMutexW, [ :LPSECURITY_ATTRIBUTES, :BOOL, :LPCTSTR ], :HANDLE
- safe_attach_function :CreateMutexA, [ :LPSECURITY_ATTRIBUTES, :BOOL, :LPCTSTR ], :HANDLE
+ safe_attach_function :CreateMutexW, %i{LPSECURITY_ATTRIBUTES BOOL LPCTSTR}, :HANDLE
+ safe_attach_function :CreateMutexA, %i{LPSECURITY_ATTRIBUTES BOOL LPCTSTR}, :HANDLE
=begin
DWORD WINAPI WaitForSingleObject(
@@ -65,7 +65,7 @@ DWORD WINAPI WaitForSingleObject(
_In_ DWORD dwMilliseconds
);
=end
- safe_attach_function :WaitForSingleObject, [ :HANDLE, :DWORD ], :DWORD
+ safe_attach_function :WaitForSingleObject, %i{HANDLE DWORD}, :DWORD
=begin
BOOL WINAPI ReleaseMutex(
@@ -81,8 +81,8 @@ HANDLE WINAPI OpenMutex(
_In_ LPCTSTR lpName
);
=end
- safe_attach_function :OpenMutexW, [ :DWORD, :BOOL, :LPCTSTR ], :HANDLE
- safe_attach_function :OpenMutexA, [ :DWORD, :BOOL, :LPCTSTR ], :HANDLE
+ safe_attach_function :OpenMutexW, %i{DWORD BOOL LPCTSTR}, :HANDLE
+ safe_attach_function :OpenMutexA, %i{DWORD BOOL LPCTSTR}, :HANDLE
end
end
end
diff --git a/lib/chef/win32/api/system.rb b/lib/chef/win32/api/system.rb
index ebe89f357f..48054c0b4f 100644
--- a/lib/chef/win32/api/system.rb
+++ b/lib/chef/win32/api/system.rb
@@ -177,7 +177,7 @@ BOOL WINAPI GetProductInfo(
__out PDWORD pdwReturnedProductType
);
=end
- safe_attach_function :GetProductInfo, [:DWORD, :DWORD, :DWORD, :DWORD, :PDWORD], :BOOL
+ safe_attach_function :GetProductInfo, %i{DWORD DWORD DWORD DWORD PDWORD}, :BOOL
=begin
int WINAPI GetSystemMetrics(
@@ -192,8 +192,8 @@ UINT WINAPI GetSystemWow64Directory(
_In_ UINT uSize
);
=end
- safe_attach_function :GetSystemWow64DirectoryW, [:LPTSTR, :UINT], :UINT
- safe_attach_function :GetSystemWow64DirectoryA, [:LPTSTR, :UINT], :UINT
+ safe_attach_function :GetSystemWow64DirectoryW, %i{LPTSTR UINT}, :UINT
+ safe_attach_function :GetSystemWow64DirectoryA, %i{LPTSTR UINT}, :UINT
=begin
BOOL WINAPI Wow64DisableWow64FsRedirection(
@@ -220,8 +220,8 @@ LRESULT WINAPI SendMessageTimeout(
_Out_opt_ PDWORD_PTR lpdwResult
);
=end
- safe_attach_function :SendMessageTimeoutW, [:HWND, :UINT, :WPARAM, :LPARAM, :UINT, :UINT, :PDWORD_PTR], :LRESULT
- safe_attach_function :SendMessageTimeoutA, [:HWND, :UINT, :WPARAM, :LPARAM, :UINT, :UINT, :PDWORD_PTR], :LRESULT
+ safe_attach_function :SendMessageTimeoutW, %i{HWND UINT WPARAM LPARAM UINT UINT PDWORD_PTR}, :LRESULT
+ safe_attach_function :SendMessageTimeoutA, %i{HWND UINT WPARAM LPARAM UINT UINT PDWORD_PTR}, :LRESULT
=begin
DWORD WINAPI ExpandEnvironmentStrings(
@@ -230,8 +230,8 @@ DWORD WINAPI ExpandEnvironmentStrings(
_In_ DWORD nSize
);
=end
- safe_attach_function :ExpandEnvironmentStringsW, [:pointer, :pointer, :DWORD], :DWORD
- safe_attach_function :ExpandEnvironmentStringsA, [:pointer, :pointer, :DWORD], :DWORD
+ safe_attach_function :ExpandEnvironmentStringsW, %i{pointer pointer DWORD}, :DWORD
+ safe_attach_function :ExpandEnvironmentStringsA, %i{pointer pointer DWORD}, :DWORD
end
end
end
diff --git a/lib/chef/win32/api/unicode.rb b/lib/chef/win32/api/unicode.rb
index 05c098fc62..70aee58df6 100644
--- a/lib/chef/win32/api/unicode.rb
+++ b/lib/chef/win32/api/unicode.rb
@@ -101,7 +101,7 @@ BOOL IsTextUnicode(
__inout LPINT lpiResult
);
=end
- safe_attach_function :IsTextUnicode, [:pointer, :int, :LPINT], :BOOL
+ safe_attach_function :IsTextUnicode, %i{pointer int LPINT}, :BOOL
=begin
int MultiByteToWideChar(
@@ -113,7 +113,7 @@ int MultiByteToWideChar(
__in int cchWideChar
);
=end
- safe_attach_function :MultiByteToWideChar, [:UINT, :DWORD, :LPCSTR, :int, :LPWSTR, :int], :int
+ safe_attach_function :MultiByteToWideChar, %i{UINT DWORD LPCSTR int LPWSTR int}, :int
=begin
int WideCharToMultiByte(
@@ -127,7 +127,7 @@ int WideCharToMultiByte(
__out LPBOOL lpUsedDefaultChar
);
=end
- safe_attach_function :WideCharToMultiByte, [:UINT, :DWORD, :LPCWSTR, :int, :LPSTR, :int, :LPCSTR, :LPBOOL], :int
+ safe_attach_function :WideCharToMultiByte, %i{UINT DWORD LPCWSTR int LPSTR int LPCSTR LPBOOL}, :int
end
end
diff --git a/lib/chef/win32/eventlog.rb b/lib/chef/win32/eventlog.rb
index e8c63bf13a..4997c0c4c0 100644
--- a/lib/chef/win32/eventlog.rb
+++ b/lib/chef/win32/eventlog.rb
@@ -19,7 +19,7 @@
if Chef::Platform.windows?
if !defined? Chef::Win32EventLogLoaded
if defined? Windows::Constants
- [:INFINITE, :WAIT_FAILED, :FORMAT_MESSAGE_IGNORE_INSERTS, :ERROR_INSUFFICIENT_BUFFER].each do |c|
+ %i{INFINITE WAIT_FAILED FORMAT_MESSAGE_IGNORE_INSERTS ERROR_INSUFFICIENT_BUFFER}.each do |c|
# These are redefined in 'win32/eventlog'
Windows::Constants.send(:remove_const, c) if Windows::Constants.const_defined? c
end
diff --git a/lib/chef/win32/file/version_info.rb b/lib/chef/win32/file/version_info.rb
index 10337a409b..f74c98b86d 100644
--- a/lib/chef/win32/file/version_info.rb
+++ b/lib/chef/win32/file/version_info.rb
@@ -34,20 +34,20 @@ class Chef
# defining method for each predefined version resource string
# see https://msdn.microsoft.com/en-us/library/windows/desktop/ms647464(v=vs.85).aspx
- [
- :Comments,
- :CompanyName,
- :FileDescription,
- :FileVersion,
- :InternalName,
- :LegalCopyright,
- :LegalTrademarks,
- :OriginalFilename,
- :ProductName,
- :ProductVersion,
- :PrivateBuild,
- :SpecialBuild,
- ].each do |method|
+ %i{
+ Comments
+ CompanyName
+ FileDescription
+ FileVersion
+ InternalName
+ LegalCopyright
+ LegalTrademarks
+ OriginalFilename
+ ProductName
+ ProductVersion
+ PrivateBuild
+ SpecialBuild
+ }.each do |method|
define_method method do
begin
get_version_info_string(method.to_s)
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
diff --git a/tasks/rspec.rb b/tasks/rspec.rb
index afd7d12705..2d20a0ffa7 100644
--- a/tasks/rspec.rb
+++ b/tasks/rspec.rb
@@ -77,7 +77,7 @@ begin
t.pattern = FileList["spec/unit/node_spec.rb", "spec/unit/role_spec.rb"]
end
- [:unit, :functional, :integration, :stress].each do |sub|
+ %i{unit functional integration stress}.each do |sub|
desc "Run the specs under spec/#{sub}"
RSpec::Core::RakeTask.new(sub) do |t|
t.rspec_opts = %w{--profile}