summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorey Hemminger <hemminger@hotmail.com>2022-01-05 13:37:05 -0600
committerGitHub <noreply@github.com>2022-01-05 13:37:05 -0600
commit0edab93f9e86ee2d72229c6ddf1f21c0444be582 (patch)
treec9bbcda5ff6181f89691075f52b403066302957f
parent58ee2ef63d83f841946ef5a2743e2dc6efcadb3c (diff)
parentcc11e0d66dd3c5169c63ee6b10c0f454aa2f5b44 (diff)
downloadchef-0edab93f9e86ee2d72229c6ddf1f21c0444be582.tar.gz
Merge branch 'chef:main' into patch-1
-rw-r--r--CHANGELOG.md30
-rw-r--r--Dockerfile2
-rw-r--r--Gemfile2
-rw-r--r--Gemfile.lock44
-rw-r--r--VERSION2
-rw-r--r--chef-bin/lib/chef-bin/version.rb2
-rw-r--r--chef-config/lib/chef-config/config.rb10
-rw-r--r--chef-config/lib/chef-config/version.rb2
-rw-r--r--chef-utils/lib/chef-utils/version.rb2
-rw-r--r--kitchen-tests/cookbooks/end_to_end/recipes/_habitat_service.rb8
-rw-r--r--kitchen-tests/cookbooks/end_to_end/recipes/_homebrew_tap.rb5
-rw-r--r--kitchen-tests/cookbooks/end_to_end/recipes/macos.rb1
-rw-r--r--knife/lib/chef/knife/acl_bulk_add.rb2
-rw-r--r--knife/lib/chef/knife/acl_bulk_remove.rb2
-rw-r--r--knife/lib/chef/knife/bootstrap.rb5
-rw-r--r--knife/lib/chef/knife/core/gem_glob_loader.rb2
-rw-r--r--knife/lib/chef/knife/core/generic_presenter.rb2
-rw-r--r--knife/lib/chef/knife/core/subcommand_loader.rb4
-rw-r--r--knife/lib/chef/knife/version.rb2
-rw-r--r--knife/spec/knife_spec_helper.rb4
-rw-r--r--knife/spec/support/platform_helpers.rb2
-rw-r--r--knife/spec/unit/knife/environment_list_spec.rb2
-rw-r--r--lib/chef/application/exit_code.rb28
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb2
-rw-r--r--lib/chef/chef_fs/file_system/repository/base_file.rb2
-rw-r--r--lib/chef/chef_fs/file_system/repository/file_system_entry.rb2
-rw-r--r--lib/chef/cookbook/syntax_check.rb2
-rw-r--r--lib/chef/cookbook_uploader.rb2
-rw-r--r--lib/chef/cookbook_version.rb2
-rw-r--r--lib/chef/provider/ifconfig.rb2
-rw-r--r--lib/chef/provider/package.rb2
-rw-r--r--lib/chef/provider/user/mac.rb6
-rw-r--r--lib/chef/resource.rb4
-rw-r--r--lib/chef/resource/habitat/habitat_sup.rb2
-rw-r--r--lib/chef/resource/habitat/habitat_sup_windows.rb2
-rw-r--r--lib/chef/resource/homebrew_tap.rb2
-rw-r--r--lib/chef/resource/inspec_waiver_file_entry.rb2
-rw-r--r--lib/chef/resource/launchd.rb4
-rw-r--r--lib/chef/resource/remote_file.rb2
-rw-r--r--lib/chef/resource_reporter.rb2
-rw-r--r--lib/chef/run_lock.rb2
-rw-r--r--lib/chef/secret_fetcher/azure_key_vault.rb4
-rw-r--r--lib/chef/util/dsc/configuration_generator.rb2
-rw-r--r--lib/chef/version.rb2
-rw-r--r--omnibus/Gemfile.lock4
-rw-r--r--spec/functional/resource/cookbook_file_spec.rb2
-rw-r--r--spec/functional/resource/dsc_script_spec.rb4
-rw-r--r--spec/functional/resource/template_spec.rb2
-rw-r--r--spec/integration/client/client_spec.rb2
-rw-r--r--spec/spec_helper.rb6
-rw-r--r--spec/support/platform_helpers.rb2
-rw-r--r--spec/support/ruby_installer.rb2
-rw-r--r--spec/support/shared/functional/file_resource.rb4
-rw-r--r--spec/support/shared/functional/http.rb18
-rw-r--r--spec/support/shared/unit/provider/useradd_based_user_provider.rb2
-rw-r--r--spec/unit/dsl/registry_helper_spec.rb12
-rw-r--r--spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb2
-rw-r--r--spec/unit/lwrp_spec.rb4
-rw-r--r--spec/unit/provider/dsc_script_spec.rb16
-rw-r--r--spec/unit/provider/group/usermod_spec.rb4
-rw-r--r--spec/unit/provider/ifconfig/aix_spec.rb28
-rw-r--r--spec/unit/provider/ifconfig/debian_spec.rb2
-rw-r--r--spec/unit/provider/ifconfig/redhat_spec.rb2
-rw-r--r--spec/unit/provider/ifconfig_spec.rb6
-rw-r--r--spec/unit/provider/remote_file/cache_control_data_spec.rb6
-rw-r--r--spec/unit/provider/service/gentoo_service_spec.rb4
-rw-r--r--spec/unit/provider/service/upstart_service_spec.rb6
-rw-r--r--spec/unit/provider/user/solaris_spec.rb2
-rw-r--r--spec/unit/resource/conditional_spec.rb8
-rw-r--r--spec/unit/resource_spec.rb4
-rwxr-xr-xtasks/docs.rb2
71 files changed, 194 insertions, 179 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6b5327dfd1..3e12b09932 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,13 +1,38 @@
<!-- usage documentation: http://expeditor-docs.es.chef.io/configuration/changelog/ -->
This changelog lists individual merged pull requests to Chef Infra Client and geared towards developers. For a list of significant changes per release see the [Chef Infra Client Release Notes](https://docs.chef.io/release_notes_client/).
-<!-- latest_release -->
+<!-- latest_release 17.9.30 -->
+## [v17.9.30](https://github.com/chef/chef/tree/v17.9.30) (2022-01-04)
+
+#### Merged Pull Requests
+- Simplify file reads [#12386](https://github.com/chef/chef/pull/12386) ([tas50](https://github.com/tas50))
<!-- latest_release -->
-<!-- release_rollup -->
+<!-- release_rollup since=17.9.26 -->
+### Changes not yet released to stable
+
+#### Merged Pull Requests
+- Resolve Performance/RegexpMatch warnings [#12411](https://github.com/chef/chef/pull/12411) ([tas50](https://github.com/tas50)) <!-- 17.9.27 -->
+- Resolve Performance/Count warning [#12410](https://github.com/chef/chef/pull/12410) ([tas50](https://github.com/tas50)) <!-- 17.9.28 -->
+- Reduce 213 requires from each knife call [#12409](https://github.com/chef/chef/pull/12409) ([tas50](https://github.com/tas50)) <!-- 17.9.29 -->
+- Simplify file reads [#12386](https://github.com/chef/chef/pull/12386) ([tas50](https://github.com/tas50)) <!-- 17.9.30 -->
<!-- release_rollup -->
<!-- latest_stable_release -->
+## [v17.9.26](https://github.com/chef/chef/tree/v17.9.26) (2022-01-05)
+
+#### Merged Pull Requests
+- homebrew_tap: Fix failures due to missing `full` property [#12418](https://github.com/chef/chef/pull/12418) ([jweyer8](https://github.com/jweyer8))
+- Bump chef/chefstyle to c72bbc6a79ab0859755981f99d76635cd5bc275a [#12420](https://github.com/chef/chef/pull/12420) ([chef-expeditor[bot]](https://github.com/chef-expeditor[bot]))
+- Bump omnibus-software from `4707275` to `b6dd27a` in /omnibus [#12425](https://github.com/chef/chef/pull/12425) ([dependabot[bot]](https://github.com/dependabot[bot]))
+- Fix typo in subscribes method documentation [#12419](https://github.com/chef/chef/pull/12419) ([gravitystorm](https://github.com/gravitystorm))
+- Resolve Style/MapToHash chefstyle warning [#12421](https://github.com/chef/chef/pull/12421) ([tas50](https://github.com/tas50))
+- Resolve Style/SelectByRegexp warnings [#12422](https://github.com/chef/chef/pull/12422) ([tas50](https://github.com/tas50))
+- Resolve Performance/StringIdentifierArgument warnings [#12414](https://github.com/chef/chef/pull/12414) ([tas50](https://github.com/tas50))
+- Resolve Performance/RedundantSortBlock warnings [#12413](https://github.com/chef/chef/pull/12413) ([tas50](https://github.com/tas50))
+- Resolve all Performance/RedundantEqualityComparisonBlock warnings [#12412](https://github.com/chef/chef/pull/12412) ([tas50](https://github.com/tas50))
+<!-- latest_stable_release -->
+
## [v17.9.18](https://github.com/chef/chef/tree/v17.9.18) (2021-12-23)
#### Merged Pull Requests
@@ -40,7 +65,6 @@ This changelog lists individual merged pull requests to Chef Infra Client and ge
- Unpin ohai in omnibus Gemfile [#12383](https://github.com/chef/chef/pull/12383) ([jeremiahsnapp](https://github.com/jeremiahsnapp))
- Add missing require statements [#12405](https://github.com/chef/chef/pull/12405) ([jasonwbarnett](https://github.com/jasonwbarnett))
- Bump omnibus-software from `d2525ab` to `4707275` in /omnibus [#12404](https://github.com/chef/chef/pull/12404) ([dependabot[bot]](https://github.com/dependabot[bot]))
-<!-- latest_stable_release -->
## [v17.8.25](https://github.com/chef/chef/tree/v17.8.25) (2021-12-01)
diff --git a/Dockerfile b/Dockerfile
index 7b9b7a1302..0a7459defc 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -18,7 +18,7 @@ FROM busybox
LABEL maintainer="Chef Software, Inc. <docker@chef.io>"
ARG CHANNEL=stable
-ARG VERSION=17.9.18
+ARG VERSION=17.9.26
ARG ARCH=x86_64
ARG PKG_VERSION=6
diff --git a/Gemfile b/Gemfile
index 4923e3e4a6..affd8adcc0 100644
--- a/Gemfile
+++ b/Gemfile
@@ -29,7 +29,7 @@ group(:omnibus_package, :pry) do
# some work is ongoing? https://github.com/deivid-rodriguez/pry-byebug/issues/343
gem "pry", "= 0.13.0"
# byebug does not install on freebsd on ruby 3.0
- gem "pry-byebug" unless RUBY_PLATFORM =~ /freebsd/i
+ gem "pry-byebug" unless RUBY_PLATFORM.match?(/freebsd/i)
gem "pry-stack_explorer"
end
diff --git a/Gemfile.lock b/Gemfile.lock
index 4b1a09470e..9862aa4967 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,17 +1,17 @@
GIT
remote: https://github.com/chef/chefstyle.git
- revision: 8b945f7083df2459718f023304116b8404a83a7d
+ revision: d3050865f4c7b4be668397007d9964ce2d54e6ee
branch: main
specs:
- chefstyle (2.1.3)
- rubocop (= 1.23.0)
+ chefstyle (2.2.0)
+ rubocop (= 1.24.1)
GIT
remote: https://github.com/chef/ohai.git
- revision: 795c6f0bac2c47dd94ea1e7bf55b1a906d2a14dd
+ revision: e86d186661a599703fe929497b33c5f7a3257d49
branch: main
specs:
- ohai (17.9.0)
+ ohai (17.9.1)
chef-config (>= 14.12, < 18)
chef-utils (>= 16.0, < 18)
ffi (~> 1.9)
@@ -35,12 +35,12 @@ GIT
PATH
remote: .
specs:
- chef (17.9.18)
+ chef (17.9.30)
addressable
aws-sdk-s3 (~> 1.91)
aws-sdk-secretsmanager (~> 1.46)
- chef-config (= 17.9.18)
- chef-utils (= 17.9.18)
+ chef-config (= 17.9.30)
+ chef-utils (= 17.9.30)
chef-vault
chef-zero (>= 14.0.11)
corefoundation (~> 0.3.4)
@@ -66,12 +66,12 @@ PATH
train-winrm (>= 0.2.5)
uuidtools (>= 2.1.5, < 3.0)
vault (~> 0.16)
- chef (17.9.18-universal-mingw32)
+ chef (17.9.30-universal-mingw32)
addressable
aws-sdk-s3 (~> 1.91)
aws-sdk-secretsmanager (~> 1.46)
- chef-config (= 17.9.18)
- chef-utils (= 17.9.18)
+ chef-config (= 17.9.30)
+ chef-utils (= 17.9.30)
chef-vault
chef-zero (>= 14.0.11)
corefoundation (~> 0.3.4)
@@ -112,15 +112,15 @@ PATH
PATH
remote: chef-bin
specs:
- chef-bin (17.9.18)
- chef (= 17.9.18)
+ chef-bin (17.9.30)
+ chef (= 17.9.30)
PATH
remote: chef-config
specs:
- chef-config (17.9.18)
+ chef-config (17.9.30)
addressable
- chef-utils (= 17.9.18)
+ chef-utils (= 17.9.30)
fuzzyurl
mixlib-config (>= 2.2.12, < 4.0)
mixlib-shellout (>= 2.0, < 4.0)
@@ -129,7 +129,7 @@ PATH
PATH
remote: chef-utils
specs:
- chef-utils (17.9.18)
+ chef-utils (17.9.30)
concurrent-ruby
GEM
@@ -142,8 +142,8 @@ GEM
mixlib-shellout (>= 2.0, < 4.0)
ast (2.4.2)
aws-eventstream (1.2.0)
- aws-partitions (1.543.0)
- aws-sdk-core (3.125.0)
+ aws-partitions (1.544.0)
+ aws-sdk-core (3.125.1)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.525.0)
aws-sigv4 (~> 1.1)
@@ -151,7 +151,7 @@ GEM
aws-sdk-kms (1.53.0)
aws-sdk-core (~> 3, >= 3.125.0)
aws-sigv4 (~> 1.1)
- aws-sdk-s3 (1.110.0)
+ aws-sdk-s3 (1.111.0)
aws-sdk-core (~> 3, >= 3.125.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.4)
@@ -329,16 +329,16 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.3)
- rubocop (1.23.0)
+ rubocop (1.24.1)
parallel (~> 1.10)
parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
- rubocop-ast (>= 1.12.0, < 2.0)
+ rubocop-ast (>= 1.15.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
- rubocop-ast (1.15.0)
+ rubocop-ast (1.15.1)
parser (>= 3.0.1.1)
ruby-progressbar (1.11.0)
ruby2_keywords (0.0.5)
diff --git a/VERSION b/VERSION
index 1f677817ff..51e6b2f393 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-17.9.18 \ No newline at end of file
+17.9.30 \ No newline at end of file
diff --git a/chef-bin/lib/chef-bin/version.rb b/chef-bin/lib/chef-bin/version.rb
index 954a419613..4d51682e5c 100644
--- a/chef-bin/lib/chef-bin/version.rb
+++ b/chef-bin/lib/chef-bin/version.rb
@@ -21,7 +21,7 @@
module ChefBin
CHEFBIN_ROOT = File.expand_path("..", __dir__)
- VERSION = "17.9.18".freeze
+ VERSION = "17.9.30".freeze
end
#
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb
index 3eb8c8475c..970ee840a9 100644
--- a/chef-config/lib/chef-config/config.rb
+++ b/chef-config/lib/chef-config/config.rb
@@ -1223,7 +1223,7 @@ module ChefConfig
"en.UTF-8"
else
# Will match en_ZZ.UTF-8, en_ZZ.utf-8, en_ZZ.UTF8, en_ZZ.utf8
- guesses = locales.select { |l| l =~ /^en_.*UTF-?8$/i }
+ guesses = locales.grep(/^en_.*UTF-?8$/i)
unless guesses.empty?
guessed_locale = guesses.first
# Transform into the form en_ZZ.UTF-8
@@ -1287,10 +1287,10 @@ module ChefConfig
require "digest/md5" unless defined?(Digest::MD5)
# Remove pre-existing constants if they do exist to reduce the
# amount of log spam and warnings.
- Digest.send(:remove_const, "SHA1") if Digest.const_defined?("SHA1")
- Digest.const_set("SHA1", OpenSSL::Digest::SHA1)
- OpenSSL::Digest.send(:remove_const, "MD5") if OpenSSL::Digest.const_defined?("MD5")
- OpenSSL::Digest.const_set("MD5", Digest::MD5)
+ Digest.send(:remove_const, "SHA1") if Digest.const_defined?(:SHA1)
+ Digest.const_set(:SHA1, OpenSSL::Digest::SHA1)
+ OpenSSL::Digest.send(:remove_const, "MD5") if OpenSSL::Digest.const_defined?(:MD5)
+ OpenSSL::Digest.const_set(:MD5, Digest::MD5)
ChefConfig.logger.debug "FIPS mode is enabled."
end
end
diff --git a/chef-config/lib/chef-config/version.rb b/chef-config/lib/chef-config/version.rb
index 7593d77449..98b05e9df2 100644
--- a/chef-config/lib/chef-config/version.rb
+++ b/chef-config/lib/chef-config/version.rb
@@ -15,5 +15,5 @@
module ChefConfig
CHEFCONFIG_ROOT = File.expand_path("..", __dir__)
- VERSION = "17.9.18".freeze
+ VERSION = "17.9.30".freeze
end
diff --git a/chef-utils/lib/chef-utils/version.rb b/chef-utils/lib/chef-utils/version.rb
index b3979e81db..70ce042f18 100644
--- a/chef-utils/lib/chef-utils/version.rb
+++ b/chef-utils/lib/chef-utils/version.rb
@@ -16,5 +16,5 @@
module ChefUtils
CHEFUTILS_ROOT = File.expand_path("..", __dir__)
- VERSION = "17.9.18"
+ VERSION = "17.9.30"
end
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/_habitat_service.rb b/kitchen-tests/cookbooks/end_to_end/recipes/_habitat_service.rb
index d928e01466..294cb982b0 100644
--- a/kitchen-tests/cookbooks/end_to_end/recipes/_habitat_service.rb
+++ b/kitchen-tests/cookbooks/end_to_end/recipes/_habitat_service.rb
@@ -39,7 +39,7 @@ ruby_block "wait-for-nginx-load" do
end
ruby_block "wait-for-nginx-up" do
block do
- raise "nginx not loaded" unless `hab svc status core/nginx`.match(/standalone\s+up\s+up/)
+ raise "nginx not loaded" unless `hab svc status core/nginx`.match?(/standalone\s+up\s+up/)
end
retries 8
retry_delay 10
@@ -78,7 +78,7 @@ end
ruby_block "wait-for-redis-started" do
block do
sleep 10
- raise "redis not started" unless `hab svc status core/redis`.match(/standalone\s+up\s+up/)
+ raise "redis not started" unless `hab svc status core/redis`.match?(/standalone\s+up\s+up/)
end
retries 8
retry_delay 10
@@ -96,7 +96,7 @@ end
ruby_block "wait-for-redis-stopped" do
block do
sleep 10
- raise "redis not stopped" unless `hab svc status core/redis`.match(/standalone\s+down\s+down/)
+ raise "redis not stopped" unless `hab svc status core/redis`.match?(/standalone\s+down\s+down/)
end
retries 8
retry_delay 10
@@ -251,7 +251,7 @@ ruby_block "wait-for-consul-load" do
end
ruby_block "wait-for-consul-startup" do
block do
- raise "consul not started" unless `hab svc status core/consul`.match(/standalone\s+up\s+up/)
+ raise "consul not started" unless `hab svc status core/consul`.match?(/standalone\s+up\s+up/)
end
retries 8
retry_delay 10
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/_homebrew_tap.rb b/kitchen-tests/cookbooks/end_to_end/recipes/_homebrew_tap.rb
new file mode 100644
index 0000000000..16600a92a0
--- /dev/null
+++ b/kitchen-tests/cookbooks/end_to_end/recipes/_homebrew_tap.rb
@@ -0,0 +1,5 @@
+homebrew_tap "chef/chef"
+
+homebrew_tap "chef/chef" do
+ action :untap
+end \ No newline at end of file
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/macos.rb b/kitchen-tests/cookbooks/end_to_end/recipes/macos.rb
index b83eb74506..213ef2d516 100644
--- a/kitchen-tests/cookbooks/end_to_end/recipes/macos.rb
+++ b/kitchen-tests/cookbooks/end_to_end/recipes/macos.rb
@@ -109,3 +109,4 @@ include_recipe "::_macos_userdefaults"
include_recipe "::_ohai_hint"
include_recipe "::_openssl"
include_recipe "::_chef_gem"
+include_recipe "::_homebrew_tap"
diff --git a/knife/lib/chef/knife/acl_bulk_add.rb b/knife/lib/chef/knife/acl_bulk_add.rb
index 4992fe2afa..bdd2e0fdc4 100644
--- a/knife/lib/chef/knife/acl_bulk_add.rb
+++ b/knife/lib/chef/knife/acl_bulk_add.rb
@@ -56,7 +56,7 @@ class Chef
objects_to_modify = []
all_objects = rest.get_rest(object_type)
- objects_to_modify = all_objects.keys.select { |object_name| object_name =~ object_name_matcher }
+ objects_to_modify = all_objects.keys.grep(object_name_matcher)
if objects_to_modify.empty?
ui.info "No #{object_type} match the expression /#{regex}/"
diff --git a/knife/lib/chef/knife/acl_bulk_remove.rb b/knife/lib/chef/knife/acl_bulk_remove.rb
index 0f35f1e2fb..fce76f250d 100644
--- a/knife/lib/chef/knife/acl_bulk_remove.rb
+++ b/knife/lib/chef/knife/acl_bulk_remove.rb
@@ -61,7 +61,7 @@ class Chef
objects_to_modify = []
all_objects = rest.get_rest(object_type)
- objects_to_modify = all_objects.keys.select { |object_name| object_name =~ object_name_matcher }
+ objects_to_modify = all_objects.keys.grep(object_name_matcher)
if objects_to_modify.empty?
ui.info "No #{object_type} match the expression /#{regex}/"
diff --git a/knife/lib/chef/knife/bootstrap.rb b/knife/lib/chef/knife/bootstrap.rb
index 8909abd45b..e2b9993e60 100644
--- a/knife/lib/chef/knife/bootstrap.rb
+++ b/knife/lib/chef/knife/bootstrap.rb
@@ -20,6 +20,7 @@ require_relative "../knife"
require_relative "data_bag_secret_options"
require "chef-utils/dist" unless defined?(ChefUtils::Dist)
require "license_acceptance/cli_flags/mixlib_cli"
+require "chef/json_compat" unless defined?(Chef::JSONCompat) # can't be lazy loaded since it's used in options
module LicenseAcceptance
autoload :Acceptor, "license_acceptance/acceptor"
@@ -416,9 +417,6 @@ class Chef
attr_reader :connection
deps do
- require "erubis" unless defined?(Erubis)
- require "net/ssh" unless defined?(Net::SSH)
- require "chef/json_compat" unless defined?(Chef::JSONCompat)
require "chef-config/path_helper" unless defined?(ChefConfig::PathHelper)
require_relative "bootstrap/chef_vault_handler"
require_relative "bootstrap/client_builder"
@@ -544,6 +542,7 @@ class Chef
end
def render_template
+ require "erubis" unless defined?(Erubis)
@config[:first_boot_attributes] = first_boot_attributes
template_file = find_template
template = IO.read(template_file).chomp
diff --git a/knife/lib/chef/knife/core/gem_glob_loader.rb b/knife/lib/chef/knife/core/gem_glob_loader.rb
index d365602cb4..afc1575f5e 100644
--- a/knife/lib/chef/knife/core/gem_glob_loader.rb
+++ b/knife/lib/chef/knife/core/gem_glob_loader.rb
@@ -62,7 +62,7 @@ class Chef
# Exclude knife/chef/version. It's not a knife command, and force-loading
# when we load all of these files will emit constant-already-defined warnings
- next if rel_path =~ version_file_match
+ next if rel_path&.match?(version_file_match)
subcommand_files[rel_path] = file
end
diff --git a/knife/lib/chef/knife/core/generic_presenter.rb b/knife/lib/chef/knife/core/generic_presenter.rb
index 850bfa8b3d..214ffd340b 100644
--- a/knife/lib/chef/knife/core/generic_presenter.rb
+++ b/knife/lib/chef/knife/core/generic_presenter.rb
@@ -140,7 +140,7 @@ class Chef
end
def format_list_for_display(list)
- config[:with_uri] ? list : list.keys.sort { |a, b| a <=> b }
+ config[:with_uri] ? list : list.keys.sort
end
def format_for_display(data)
diff --git a/knife/lib/chef/knife/core/subcommand_loader.rb b/knife/lib/chef/knife/core/subcommand_loader.rb
index ca7bfcd008..ddcaeffd0c 100644
--- a/knife/lib/chef/knife/core/subcommand_loader.rb
+++ b/knife/lib/chef/knife/core/subcommand_loader.rb
@@ -151,7 +151,7 @@ class Chef
rel_path = knife_file[/#{KNIFE_ROOT}#{Regexp.escape(File::SEPARATOR)}(.*)\.rb/, 1]
# Exclude version.rb file for the gem. It's not a knife command, and force-loading it later
# because loaded via in subcommand files generates CLI warnings about its consts already having been defined
- next if knife_file =~ version_file_match
+ next if knife_file&.match?(version_file_match)
subcommand_files[rel_path] = knife_file
end
@@ -184,7 +184,7 @@ class Chef
# @return [Array<String>]
#
def positional_arguments(args)
- args.select { |arg| arg =~ /^(([[:alnum:]])[[:alnum:]\_\-]+)$/ }
+ args.grep(/^(([[:alnum:]])[[:alnum:]\_\-]+)$/)
end
# Returns an Array of paths to knife commands located in
diff --git a/knife/lib/chef/knife/version.rb b/knife/lib/chef/knife/version.rb
index 12504241cd..b293723960 100644
--- a/knife/lib/chef/knife/version.rb
+++ b/knife/lib/chef/knife/version.rb
@@ -17,7 +17,7 @@
class Chef
class Knife
KNIFE_ROOT = File.expand_path("../..", __dir__)
- VERSION = "17.9.18".freeze
+ VERSION = "17.9.30".freeze
end
end
diff --git a/knife/spec/knife_spec_helper.rb b/knife/spec/knife_spec_helper.rb
index 7395d2759b..5a3c0761d5 100644
--- a/knife/spec/knife_spec_helper.rb
+++ b/knife/spec/knife_spec_helper.rb
@@ -78,8 +78,8 @@ require "spec/support/shared/matchers/match_environment_variable"
# Excludes support/platforms by default
# Do not change the gsub.
Dir["spec/support/**/*.rb"]
- .reject { |f| f =~ %r{^spec/support/platforms} }
- .reject { |f| f =~ %r{^spec/support/pedant} }
+ .grep_v(%r{^spec/support/platforms})
+ .grep_v(%r{^spec/support/pedant})
.map { |f| f.gsub(/.rb$/, "") }
.map { |f| f.gsub(%r{spec/}, "") }
.each { |f| require f }
diff --git a/knife/spec/support/platform_helpers.rb b/knife/spec/support/platform_helpers.rb
index a3fb95e069..4d3acbcb33 100644
--- a/knife/spec/support/platform_helpers.rb
+++ b/knife/spec/support/platform_helpers.rb
@@ -168,7 +168,7 @@ def wpar?
end
def supports_cloexec?
- Fcntl.const_defined?("F_SETFD") && Fcntl.const_defined?("FD_CLOEXEC")
+ Fcntl.const_defined?(:F_SETFD) && Fcntl.const_defined?(:FD_CLOEXEC)
end
def selinux_enabled?
diff --git a/knife/spec/unit/knife/environment_list_spec.rb b/knife/spec/unit/knife/environment_list_spec.rb
index 4f44a93f60..5090596815 100644
--- a/knife/spec/unit/knife/environment_list_spec.rb
+++ b/knife/spec/unit/knife/environment_list_spec.rb
@@ -39,7 +39,7 @@ describe Chef::Knife::EnvironmentList do
end
it "should print the environment names in a sorted list" do
- names = @environments.keys.sort { |a, b| a <=> b }
+ names = @environments.keys.sort
expect(@knife).to receive(:output).with(names)
@knife.run
end
diff --git a/lib/chef/application/exit_code.rb b/lib/chef/application/exit_code.rb
index 26c181fa3d..4cc579e83a 100644
--- a/lib/chef/application/exit_code.rb
+++ b/lib/chef/application/exit_code.rb
@@ -90,45 +90,31 @@ class Chef
end
def reboot_scheduled?(exception)
- resolve_exception_array(exception).any? do |e|
- e.is_a? Chef::Exceptions::Reboot
- end
+ resolve_exception_array(exception).any?(Chef::Exceptions::Reboot)
end
def reboot_needed?(exception)
- resolve_exception_array(exception).any? do |e|
- e.is_a? Chef::Exceptions::RebootPending
- end
+ resolve_exception_array(exception).any?(Chef::Exceptions::RebootPending)
end
def reboot_failed?(exception)
- resolve_exception_array(exception).any? do |e|
- e.is_a? Chef::Exceptions::RebootFailed
- end
+ resolve_exception_array(exception).any?(Chef::Exceptions::RebootFailed)
end
def configuration_failure?(exception)
- resolve_exception_array(exception).any? do |e|
- e.is_a? Chef::Exceptions::ConfigurationError
- end
+ resolve_exception_array(exception).any?(Chef::Exceptions::ConfigurationError)
end
def client_upgraded?(exception)
- resolve_exception_array(exception).any? do |e|
- e.is_a? Chef::Exceptions::ClientUpgraded
- end
+ resolve_exception_array(exception).any?(Chef::Exceptions::ClientUpgraded)
end
def sigint_received?(exception)
- resolve_exception_array(exception).any? do |e|
- e.is_a? Chef::Exceptions::SigInt
- end
+ resolve_exception_array(exception).any?(Chef::Exceptions::SigInt)
end
def sigterm_received?(exception)
- resolve_exception_array(exception).any? do |e|
- e.is_a? Chef::Exceptions::SigTerm
- end
+ resolve_exception_array(exception).any?(Chef::Exceptions::SigTerm)
end
def resolve_exception_array(exception)
diff --git a/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb b/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb
index c49ed51d81..35e412bd37 100644
--- a/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb
@@ -38,7 +38,7 @@ class Chef
def read
tmpfile = rest.streaming_request(file[:url])
- File.open(tmpfile, "rb", &:read)
+ File.binread(tmpfile)
rescue Timeout::Error => e
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:read, self, e, "Timeout reading #{file[:url]}: #{e}")
rescue Net::HTTPClientException => e
diff --git a/lib/chef/chef_fs/file_system/repository/base_file.rb b/lib/chef/chef_fs/file_system/repository/base_file.rb
index 94b52b9201..46c6494bb7 100644
--- a/lib/chef/chef_fs/file_system/repository/base_file.rb
+++ b/lib/chef/chef_fs/file_system/repository/base_file.rb
@@ -123,7 +123,7 @@ class Chef
if is_ruby_file?
data_handler.from_ruby(file_path).to_json
else
- File.open(file_path, "rb", &:read)
+ File.binread(file_path)
end
rescue Errno::ENOENT
raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
diff --git a/lib/chef/chef_fs/file_system/repository/file_system_entry.rb b/lib/chef/chef_fs/file_system/repository/file_system_entry.rb
index 902bc63038..289ec26058 100644
--- a/lib/chef/chef_fs/file_system/repository/file_system_entry.rb
+++ b/lib/chef/chef_fs/file_system/repository/file_system_entry.rb
@@ -126,7 +126,7 @@ class Chef
end
def read
- File.open(file_path, "rb", &:read)
+ File.binread(file_path)
rescue Errno::ENOENT
raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
end
diff --git a/lib/chef/cookbook/syntax_check.rb b/lib/chef/cookbook/syntax_check.rb
index 8b593eea81..555d2f6715 100644
--- a/lib/chef/cookbook/syntax_check.rb
+++ b/lib/chef/cookbook/syntax_check.rb
@@ -113,7 +113,7 @@ class Chef
end
def remove_uninteresting_ruby_files(file_list)
- file_list.reject { |f| f =~ %r{#{Regexp.quote(cookbook_path)}/(files|templates)/} }
+ file_list.grep_v(%r{#{Regexp.quote(cookbook_path)}/(files|templates)/})
end
def ruby_files
diff --git a/lib/chef/cookbook_uploader.rb b/lib/chef/cookbook_uploader.rb
index 21a15f706c..6b71b26d0c 100644
--- a/lib/chef/cookbook_uploader.rb
+++ b/lib/chef/cookbook_uploader.rb
@@ -119,7 +119,7 @@ class Chef
# but we need the base64 encoding for the content-md5
# header
checksum64 = Base64.encode64([checksum].pack("H*")).strip
- file_contents = File.open(file, "rb", &:read)
+ file_contents = File.binread(file)
# Custom headers. 'content-type' disables JSON serialization of the request body.
headers = { "content-type" => "application/x-binary", "content-md5" => checksum64, "accept" => "application/json" }
diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb
index 6e4f13c291..8a616e5e07 100644
--- a/lib/chef/cookbook_version.rb
+++ b/lib/chef/cookbook_version.rb
@@ -598,7 +598,7 @@ class Chef
filename = record[:name]
base_dup_name = File.join(File.dirname(filename), File.basename(filename, File.extname(filename)))
yml_files.each do |other|
- if other[:name] =~ /#{(File.extname(filename) == ".yml") ? "#{base_dup_name}.yaml" : "#{base_dup_name}.yml"}$/
+ if /#{(File.extname(filename) == ".yml") ? "#{base_dup_name}.yaml" : "#{base_dup_name}.yml"}$/.match?(other[:name])
raise Chef::Exceptions::AmbiguousYAMLFile.new("Cookbook #{name}@#{version} contains ambiguous files: #{filename} and #{other[:name]}. Please update the cookbook to remove the incorrect file.")
end
end
diff --git a/lib/chef/provider/ifconfig.rb b/lib/chef/provider/ifconfig.rb
index 63aa126c2e..30fe4c2545 100644
--- a/lib/chef/provider/ifconfig.rb
+++ b/lib/chef/provider/ifconfig.rb
@@ -120,7 +120,7 @@ class Chef
@status = shell_out("ifconfig")
@status.stdout.each_line do |line|
addr_regex = /^((\w|-)+):?(\d*):?\ .+$/
- if line =~ addr_regex
+ if line&.match?(addr_regex)
if line.match(addr_regex).nil?
@int_name = "nil"
elsif line.match(addr_regex)[3] == ""
diff --git a/lib/chef/provider/package.rb b/lib/chef/provider/package.rb
index daf46c502e..a49a97ea7e 100644
--- a/lib/chef/provider/package.rb
+++ b/lib/chef/provider/package.rb
@@ -658,7 +658,7 @@ class Chef
end
def allow_downgrade
- if new_resource.respond_to?("allow_downgrade")
+ if new_resource.respond_to?(:allow_downgrade)
new_resource.allow_downgrade
else
true
diff --git a/lib/chef/provider/user/mac.rb b/lib/chef/provider/user/mac.rb
index e0e120aa0b..8e5b3d1cf3 100644
--- a/lib/chef/provider/user/mac.rb
+++ b/lib/chef/provider/user/mac.rb
@@ -339,7 +339,7 @@ class Chef
end
def locked?
- user_plist[:auth_authority].any? { |tag| tag == ";DisabledUser;" }
+ user_plist[:auth_authority].any?(";DisabledUser;")
rescue
false
end
@@ -411,7 +411,7 @@ class Chef
end
def secure_token_enabled?
- user_plist[:auth_authority].any? { |tag| tag == ";SecureToken;" }
+ user_plist[:auth_authority].any?(";SecureToken;")
rescue
false
end
@@ -505,7 +505,7 @@ class Chef
end
def admin_user?
- admin_group_plist[:group_members].any? { |mem| mem == user_plist[:guid][0] }
+ admin_group_plist[:group_members].any?(user_plist[:guid][0])
rescue
false
end
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index 746efb5fd4..681927f1d0 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -311,7 +311,7 @@ class Chef
# file '/foo.txt' do
# content 'hi'
# action :nothing
- # subscribes :create, '/bar.txt'
+ # subscribes :create, bar
# end
# @example Multiple resources by string
# file '/foo.txt' do
@@ -1096,7 +1096,7 @@ class Chef
rescue NameError => e
# This can happen when attempting to load a provider in a platform-specific
# environment where we have not required the necessary files yet
- raise unless e.message =~ /uninitialized constant/
+ raise unless /uninitialized constant/.match?(e.message)
end
# Define a method to load up this resource's properties with the current
diff --git a/lib/chef/resource/habitat/habitat_sup.rb b/lib/chef/resource/habitat/habitat_sup.rb
index 2fdfcd270f..b1cbe6cbed 100644
--- a/lib/chef/resource/habitat/habitat_sup.rb
+++ b/lib/chef/resource/habitat/habitat_sup.rb
@@ -284,7 +284,7 @@ class Chef
if new_resource.peer
peer_list = []
new_resource.peer.each do |p|
- peer_list << if p !~ /.*:.*/
+ peer_list << if !/.*:.*/.match?(p)
p + ":9632"
else
p
diff --git a/lib/chef/resource/habitat/habitat_sup_windows.rb b/lib/chef/resource/habitat/habitat_sup_windows.rb
index c73e648f3c..1c574025d2 100644
--- a/lib/chef/resource/habitat/habitat_sup_windows.rb
+++ b/lib/chef/resource/habitat/habitat_sup_windows.rb
@@ -15,7 +15,7 @@
# limitations under the License.
#
-require "win32/service" if RUBY_PLATFORM =~ /mswin|mingw32|windows/
+require "win32/service" if RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
require_relative "habitat_sup"
class Chef
diff --git a/lib/chef/resource/homebrew_tap.rb b/lib/chef/resource/homebrew_tap.rb
index b728d447c8..a150210951 100644
--- a/lib/chef/resource/homebrew_tap.rb
+++ b/lib/chef/resource/homebrew_tap.rb
@@ -53,7 +53,7 @@ class Chef
action :tap, description: "Add a Homebrew tap." do
unless tapped?(new_resource.tap_name)
converge_by("tap #{new_resource.tap_name}") do
- shell_out!("#{new_resource.homebrew_path} tap #{new_resource.full ? "--full" : ""} #{new_resource.tap_name} #{new_resource.url || ""}",
+ shell_out!("#{new_resource.homebrew_path} tap #{new_resource.tap_name} #{new_resource.url || ""}",
user: new_resource.owner,
env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
cwd: ::Dir.home(new_resource.owner))
diff --git a/lib/chef/resource/inspec_waiver_file_entry.rb b/lib/chef/resource/inspec_waiver_file_entry.rb
index 8b8a0b9415..2f3c806266 100644
--- a/lib/chef/resource/inspec_waiver_file_entry.rb
+++ b/lib/chef/resource/inspec_waiver_file_entry.rb
@@ -135,7 +135,7 @@ class Chef
action_class do
def load_waiver_file_to_hash(file_name)
- if file_name =~ %r{(/|C:\\).*(.yaml|.yml)}i
+ if %r{(/|C:\\).*(.yaml|.yml)}i.match?(file_name)
if ::File.exist?(file_name)
hash = ::YAML.load_file(file_name)
if hash == false || hash.nil? || hash == ""
diff --git a/lib/chef/resource/launchd.rb b/lib/chef/resource/launchd.rb
index 9729b29085..6a80ada7fa 100644
--- a/lib/chef/resource/launchd.rb
+++ b/lib/chef/resource/launchd.rb
@@ -84,7 +84,7 @@ class Chef
end
# Check to make sure that our array only has hashes
- unless array.all? { |obj| obj.is_a?(Hash) }
+ unless array.all?(Hash)
error_msg = "start_calendar_interval must be a single hash or an array of hashes!"
raise Chef::Exceptions::ValidationFailed, error_msg
end
@@ -98,7 +98,7 @@ class Chef
raise Chef::Exceptions::ValidationFailed, error_msg
end
- unless entry.values.all? { |val| val.is_a?(Integer) }
+ unless entry.values.all?(Integer)
failed_values = entry.values.reject { |val| val.is_a?(Integer) }.join(", ")
error_msg = "Invalid value(s) (#{failed_values}) for start_calendar_interval item. Values must be integers!"
raise Chef::Exceptions::ValidationFailed, error_msg
diff --git a/lib/chef/resource/remote_file.rb b/lib/chef/resource/remote_file.rb
index bd81b78f73..d91cb86a30 100644
--- a/lib/chef/resource/remote_file.rb
+++ b/lib/chef/resource/remote_file.rb
@@ -138,7 +138,7 @@ class Chef
nil
elsif args[0].is_a?(Chef::DelayedEvaluator) && args.count == 1
args[0]
- elsif args.any? { |a| a.is_a?(Chef::DelayedEvaluator) } && args.count > 1
+ elsif args.any?(Chef::DelayedEvaluator) && args.count > 1
raise Exceptions::InvalidRemoteFileURI, "Only 1 source argument allowed when using a lazy evaluator"
else
Array(args).flatten
diff --git a/lib/chef/resource_reporter.rb b/lib/chef/resource_reporter.rb
index 242a6e9f0f..16d90baf4f 100644
--- a/lib/chef/resource_reporter.rb
+++ b/lib/chef/resource_reporter.rb
@@ -34,7 +34,7 @@ class Chef
as_hash["after"] = new_resource.state_for_resource_reporter
as_hash["before"] = current_resource ? current_resource.state_for_resource_reporter : {}
as_hash["duration"] = ( action_record.elapsed_time * 1000 ).to_i.to_s
- as_hash["delta"] = new_resource.diff if new_resource.respond_to?("diff")
+ as_hash["delta"] = new_resource.diff if new_resource.respond_to?(:diff)
as_hash["delta"] = "" if as_hash["delta"].nil?
# TODO: rename as "action"
diff --git a/lib/chef/run_lock.rb b/lib/chef/run_lock.rb
index 8382983ca0..b70a936aab 100644
--- a/lib/chef/run_lock.rb
+++ b/lib/chef/run_lock.rb
@@ -144,7 +144,7 @@ class Chef
# If we support FD_CLOEXEC, then use it.
# NB: ruby-2.0.0-p195 sets FD_CLOEXEC by default, but not
# ruby-1.8.7/1.9.3
- if Fcntl.const_defined?("F_SETFD") && Fcntl.const_defined?("FD_CLOEXEC")
+ if Fcntl.const_defined?(:F_SETFD) && Fcntl.const_defined?(:FD_CLOEXEC)
runlock.fcntl(Fcntl::F_SETFD, runlock.fcntl(Fcntl::F_GETFD, 0) | Fcntl::FD_CLOEXEC)
end
# Flock will return 0 if it can acquire the lock otherwise it
diff --git a/lib/chef/secret_fetcher/azure_key_vault.rb b/lib/chef/secret_fetcher/azure_key_vault.rb
index d9acc7c3d0..da7f0d2da5 100644
--- a/lib/chef/secret_fetcher/azure_key_vault.rb
+++ b/lib/chef/secret_fetcher/azure_key_vault.rb
@@ -59,7 +59,7 @@ class Chef
end
def validate!
- raise Chef::Exceptions::Secret::ConfigurationInvalid, "You may only specify one (these are mutually exclusive): :object_id, :client_id, or :mi_res_id" if [object_id, client_id, mi_res_id].select { |x| !x.nil? }.length > 1
+ raise Chef::Exceptions::Secret::ConfigurationInvalid, "You may only specify one (these are mutually exclusive): :object_id, :client_id, or :mi_res_id" if [object_id, client_id, mi_res_id].count { |x| !x.nil? } > 1
end
private
@@ -123,7 +123,7 @@ class Chef
body["access_token"]
when Net::HTTPBadRequest
body = JSON.parse(response.body)
- raise Chef::Exceptions::Secret::Azure::IdentityNotFound if body["error_description"] =~ /identity not found/i
+ raise Chef::Exceptions::Secret::Azure::IdentityNotFound if /identity not found/i.match?(body["error_description"])
else
body = JSON.parse(response.body)
body["access_token"]
diff --git a/lib/chef/util/dsc/configuration_generator.rb b/lib/chef/util/dsc/configuration_generator.rb
index 8ca6249a9d..ae3c5c951d 100644
--- a/lib/chef/util/dsc/configuration_generator.rb
+++ b/lib/chef/util/dsc/configuration_generator.rb
@@ -175,7 +175,7 @@ class Chef::Util::DSC
end
def get_configuration_document(document_path)
- ::File.open(document_path, "rb", &:read)
+ ::File.binread(document_path)
end
end
end
diff --git a/lib/chef/version.rb b/lib/chef/version.rb
index a3b3300291..bb09b9a9ee 100644
--- a/lib/chef/version.rb
+++ b/lib/chef/version.rb
@@ -23,7 +23,7 @@ require_relative "version_string"
class Chef
CHEF_ROOT = File.expand_path("..", __dir__)
- VERSION = Chef::VersionString.new("17.9.18")
+ VERSION = Chef::VersionString.new("17.9.30")
end
#
diff --git a/omnibus/Gemfile.lock b/omnibus/Gemfile.lock
index b3dca6cab1..bc892b1569 100644
--- a/omnibus/Gemfile.lock
+++ b/omnibus/Gemfile.lock
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/chef/omnibus-software.git
- revision: 4707275bb5cac7643938972738e83723e8fd5621
+ revision: b6dd27a6456aa6a19bb81e2dd65c8438067b46e9
branch: main
specs:
omnibus-software (4.0.0)
@@ -33,7 +33,7 @@ GEM
artifactory (3.0.15)
awesome_print (1.9.2)
aws-eventstream (1.2.0)
- aws-partitions (1.543.0)
+ aws-partitions (1.544.0)
aws-sdk-core (3.125.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.525.0)
diff --git a/spec/functional/resource/cookbook_file_spec.rb b/spec/functional/resource/cookbook_file_spec.rb
index 8dbf22d611..c013366da2 100644
--- a/spec/functional/resource/cookbook_file_spec.rb
+++ b/spec/functional/resource/cookbook_file_spec.rb
@@ -25,7 +25,7 @@ describe Chef::Resource::CookbookFile do
let(:source) { "java.response" }
let(:cookbook_name) { "java" }
let(:expected_content) do
- content = File.open(File.join(CHEF_SPEC_DATA, "cookbooks", "java", "files", "default", "java.response"), "rb", &:read)
+ content = File.binread(File.join(CHEF_SPEC_DATA, "cookbooks", "java", "files", "default", "java.response"))
content.force_encoding(Encoding::BINARY) if content.respond_to?(:force_encoding)
content
end
diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb
index cd88200e1a..6aee29133f 100644
--- a/spec/functional/resource/dsc_script_spec.rb
+++ b/spec/functional/resource/dsc_script_spec.rb
@@ -345,7 +345,7 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only, :ruby64_only d
let(:config_param_section) { config_params }
let(:config_flags) { { "#{dsc_user_prefix_param_name}": (dsc_user_prefix).to_s, "#{dsc_user_suffix_param_name}": (dsc_user_suffix).to_s } }
it "does not directly contain the user name" do
- configuration_script_content = ::File.open(dsc_test_resource.command, &:read)
+ configuration_script_content = ::File.read(dsc_test_resource.command)
expect(configuration_script_content.include?(dsc_user)).to be(false)
end
it_behaves_like "a dsc_script with configuration data"
@@ -355,7 +355,7 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only, :ruby64_only d
let(:dsc_user_code) { dsc_user_env_code }
it "does not directly contain the user name" do
- configuration_script_content = ::File.open(dsc_test_resource.command, &:read)
+ configuration_script_content = ::File.read(dsc_test_resource.command)
expect(configuration_script_content.include?(dsc_user)).to be(false)
end
it_behaves_like "a dsc_script with configuration data"
diff --git a/spec/functional/resource/template_spec.rb b/spec/functional/resource/template_spec.rb
index 4707fa8ee0..ab2a7dc712 100644
--- a/spec/functional/resource/template_spec.rb
+++ b/spec/functional/resource/template_spec.rb
@@ -21,7 +21,7 @@ require "spec_helper"
describe Chef::Resource::Template do
def binread(file)
- File.open(file, "rb", &:read)
+ File.binread(file)
end
include_context Chef::Resource::File
diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb
index adcffec715..af35eadb74 100644
--- a/spec/integration/client/client_spec.rb
+++ b/spec/integration/client/client_spec.rb
@@ -22,7 +22,7 @@ describe "chef-client" do
# just a normal file
# (expected_content should be uncompressed)
@api.get("/recipes.tgz", 200) do
- File.open(recipes_filename, "rb", &:read)
+ File.binread(recipes_filename)
end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 60b608e4ff..5cd04437be 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -78,9 +78,9 @@ require "spec/support/recipe_dsl_helper"
# Excludes support/platforms by default
# Do not change the gsub.
Dir["spec/support/**/*.rb"]
- .reject { |f| f =~ %r{^spec/support/platforms} }
- .reject { |f| f =~ %r{^spec/support/pedant} }
- .reject { |f| f =~ %r{^spec/support/shared/integration/knife_support} }
+ .grep_v(%r{^spec/support/platforms})
+ .grep_v(%r{^spec/support/pedant})
+ .grep_v(%r{^spec/support/shared/integration/knife_support})
.map { |f| f.gsub(/.rb$/, "") }
.map { |f| f.gsub(%r{spec/}, "") }
.each { |f| require f }
diff --git a/spec/support/platform_helpers.rb b/spec/support/platform_helpers.rb
index 1538a4eb34..430d9b055f 100644
--- a/spec/support/platform_helpers.rb
+++ b/spec/support/platform_helpers.rb
@@ -172,7 +172,7 @@ def wpar?
end
def supports_cloexec?
- Fcntl.const_defined?("F_SETFD") && Fcntl.const_defined?("FD_CLOEXEC")
+ Fcntl.const_defined?(:F_SETFD) && Fcntl.const_defined?(:FD_CLOEXEC)
end
def selinux_enabled?
diff --git a/spec/support/ruby_installer.rb b/spec/support/ruby_installer.rb
index ae282d3b2d..d03525268f 100644
--- a/spec/support/ruby_installer.rb
+++ b/spec/support/ruby_installer.rb
@@ -48,4 +48,4 @@ rescue LoadError
$stderr.puts "Failed to load ruby_installer. Assuming Ruby Installer is not being used."
end
-add_libarchive_dll_directory if RUBY_PLATFORM =~ /mswin|mingw32|windows/
+add_libarchive_dll_directory if RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
diff --git a/spec/support/shared/functional/file_resource.rb b/spec/support/shared/functional/file_resource.rb
index 1385d3dc30..65077adc0d 100644
--- a/spec/support/shared/functional/file_resource.rb
+++ b/spec/support/shared/functional/file_resource.rb
@@ -157,7 +157,7 @@ shared_examples_for "a file with the wrong content" do
context "when running :create action" do
let(:provider) { resource.provider_for_action(:create) }
- let(:reporter_messages) { provider.instance_variable_get("@converge_actions").actions[0][0] }
+ let(:reporter_messages) { provider.instance_variable_get(:@converge_actions).actions[0][0] }
before do
provider.run_action
@@ -391,7 +391,7 @@ shared_examples_for "a configured file resource" do
end
def binread(file)
- content = File.open(file, "rb", &:read)
+ content = File.binread(file)
content.force_encoding(Encoding::BINARY) if "".respond_to?(:force_encoding)
content
end
diff --git a/spec/support/shared/functional/http.rb b/spec/support/shared/functional/http.rb
index ffe52e2148..d3d4531371 100644
--- a/spec/support/shared/functional/http.rb
+++ b/spec/support/shared/functional/http.rb
@@ -30,7 +30,7 @@ module ChefHTTPShared
end
def binread(file)
- content = File.open(file, "rb", &:read)
+ content = File.binread(file)
content.force_encoding(Encoding::BINARY) if "".respond_to?(:force_encoding)
content
end
@@ -51,19 +51,19 @@ module ChefHTTPShared
# just a normal file
# (expected_content should be uncompressed)
@api.get("/nyan_cat.png", 200) do
- File.open(nyan_uncompressed_filename, "rb", &:read)
+ File.binread(nyan_uncompressed_filename)
end
# this ends in .gz, we do not uncompress it and drop it on the filesystem as a .gz file (the internet often lies)
# (expected_content should be compressed)
@api.get("/nyan_cat.png.gz", 200, nil, { "Content-Type" => "application/gzip", "Content-Encoding" => "gzip" } ) do
- File.open(nyan_compressed_filename, "rb", &:read)
+ File.binread(nyan_compressed_filename)
end
# this is an uncompressed file that was compressed by some mod_gzip-ish webserver thingy, so we will expand it
# (expected_content should be uncompressed)
@api.get("/nyan_cat_compressed.png", 200, nil, { "Content-Type" => "application/gzip", "Content-Encoding" => "gzip" } ) do
- File.open(nyan_compressed_filename, "rb", &:read)
+ File.binread(nyan_compressed_filename)
end
#
@@ -75,7 +75,7 @@ module ChefHTTPShared
{
"Content-Length" => nyan_uncompressed_size.to_s,
}) do
- File.open(nyan_uncompressed_filename, "rb", &:read)
+ File.binread(nyan_uncompressed_filename)
end
# (expected_content should be uncompressed)
@@ -85,7 +85,7 @@ module ChefHTTPShared
"Content-Type" => "application/gzip",
"Content-Encoding" => "gzip",
}) do
- File.open(nyan_compressed_filename, "rb", &:read)
+ File.binread(nyan_compressed_filename)
end
#
@@ -97,7 +97,7 @@ module ChefHTTPShared
{
"Content-Length" => (nyan_uncompressed_size + 1).to_s,
}) do
- File.open(nyan_uncompressed_filename, "rb", &:read)
+ File.binread(nyan_uncompressed_filename)
end
# (expected_content should be uncompressed)
@@ -107,7 +107,7 @@ module ChefHTTPShared
"Content-Type" => "application/gzip",
"Content-Encoding" => "gzip",
}) do
- File.open(nyan_compressed_filename, "rb", &:read)
+ File.binread(nyan_compressed_filename)
end
#
@@ -120,7 +120,7 @@ module ChefHTTPShared
"Content-Length" => (nyan_uncompressed_size + 1).to_s,
"Transfer-Encoding" => "anything",
}) do
- File.open(nyan_uncompressed_filename, "rb", &:read)
+ File.binread(nyan_uncompressed_filename)
end
#
diff --git a/spec/support/shared/unit/provider/useradd_based_user_provider.rb b/spec/support/shared/unit/provider/useradd_based_user_provider.rb
index 1f9f87866c..7e7a8ae857 100644
--- a/spec/support/shared/unit/provider/useradd_based_user_provider.rb
+++ b/spec/support/shared/unit/provider/useradd_based_user_provider.rb
@@ -169,7 +169,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
before do
provider.new_resource.system true
# there is no public API to set attribute's value to nil
- provider.new_resource.instance_variable_set("@home", nil)
+ provider.new_resource.instance_variable_set(:@home, nil)
end
it "should not include -m or -d in the command options" do
diff --git a/spec/unit/dsl/registry_helper_spec.rb b/spec/unit/dsl/registry_helper_spec.rb
index 5ef8caa053..09dfe24226 100644
--- a/spec/unit/dsl/registry_helper_spec.rb
+++ b/spec/unit/dsl/registry_helper_spec.rb
@@ -31,22 +31,22 @@ describe Chef::Resource::RegistryKey do
context "tests registry dsl" do
it "resource can access registry_helper method registry_key_exists" do
- expect(@resource.respond_to?("registry_key_exists?")).to eq(true)
+ expect(@resource.respond_to?(:registry_key_exists?)).to eq(true)
end
it "resource can access registry_helper method registry_get_values" do
- expect(@resource.respond_to?("registry_get_values")).to eq(true)
+ expect(@resource.respond_to?(:registry_get_values)).to eq(true)
end
it "resource can access registry_helper method registry_has_subkey" do
- expect(@resource.respond_to?("registry_has_subkeys?")).to eq(true)
+ expect(@resource.respond_to?(:registry_has_subkeys?)).to eq(true)
end
it "resource can access registry_helper method registry_get_subkeys" do
- expect(@resource.respond_to?("registry_get_subkeys")).to eq(true)
+ expect(@resource.respond_to?(:registry_get_subkeys)).to eq(true)
end
it "resource can access registry_helper method registry_value_exists" do
- expect(@resource.respond_to?("registry_value_exists?")).to eq(true)
+ expect(@resource.respond_to?(:registry_value_exists?)).to eq(true)
end
it "resource can access registry_helper method data_value_exists" do
- expect(@resource.respond_to?("registry_data_exists?")).to eq(true)
+ expect(@resource.respond_to?(:registry_data_exists?)).to eq(true)
end
end
end
diff --git a/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb b/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb
index 0760bcee1d..a5ec146fc1 100644
--- a/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb
+++ b/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb
@@ -94,7 +94,7 @@ describe Chef::GuardInterpreter::ResourceGuardInterpreter do
describe "script command opts switch" do
let(:guard_interpreter) { Chef::GuardInterpreter::ResourceGuardInterpreter.new(parent_resource, "exit 0", {}) }
- let(:resource) { guard_interpreter.instance_variable_get("@resource") }
+ let(:resource) { guard_interpreter.instance_variable_get(:@resource) }
context "resource is a Script" do
context "and guard_interpreter is a :script" do
diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb
index 5767e3987b..e93640ab86 100644
--- a/spec/unit/lwrp_spec.rb
+++ b/spec/unit/lwrp_spec.rb
@@ -54,7 +54,7 @@ describe "LWRP" do
end
it "should not skip loading a resource when there's a top level symbol of the same name" do
- Object.const_set("LwrpFoo", Class.new)
+ Object.const_set(:LwrpFoo, Class.new)
file = File.expand_path( "lwrp/resources/foo.rb", CHEF_SPEC_DATA)
expect(Chef::Log).not_to receive(:info).with(/Skipping/)
expect(Chef::Log).not_to receive(:trace).with(/anymore/)
@@ -63,7 +63,7 @@ describe "LWRP" do
end
it "should not skip loading a provider when there's a top level symbol of the same name" do
- Object.const_set("LwrpBuckPasser", Class.new)
+ Object.const_set(:LwrpBuckPasser, Class.new)
file = File.expand_path( "lwrp/providers/buck_passer.rb", CHEF_SPEC_DATA)
expect(Chef::Log).not_to receive(:info).with(/Skipping/)
expect(Chef::Log).not_to receive(:trace).with(/anymore/)
diff --git a/spec/unit/provider/dsc_script_spec.rb b/spec/unit/provider/dsc_script_spec.rb
index d59b6f2480..41544a32a2 100644
--- a/spec/unit/provider/dsc_script_spec.rb
+++ b/spec/unit/provider/dsc_script_spec.rb
@@ -39,21 +39,21 @@ describe Chef::Provider::DscScript do
it "describes the resource as converged if there were 0 DSC resources" do
allow(provider).to receive(:run_configuration).with(:test).and_return([])
provider.load_current_resource
- expect(provider.instance_variable_get("@resource_converged")).to be_truthy
+ expect(provider.instance_variable_get(:@resource_converged)).to be_truthy
end
it "describes the resource as not converged if there is 1 DSC resources that is converged" do
dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resource", false, ["nothing will change something"])
allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info])
provider.load_current_resource
- expect(provider.instance_variable_get("@resource_converged")).to be_truthy
+ expect(provider.instance_variable_get(:@resource_converged)).to be_truthy
end
it "describes the resource as not converged if there is 1 DSC resources that is not converged" do
dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resource", true, ["will change something"])
allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info])
provider.load_current_resource
- expect(provider.instance_variable_get("@resource_converged")).to be_falsey
+ expect(provider.instance_variable_get(:@resource_converged)).to be_falsey
end
it "describes the resource as not converged if there are any DSC resources that are not converged" do
@@ -62,7 +62,7 @@ describe Chef::Provider::DscScript do
allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info1, dsc_resource_info2])
provider.load_current_resource
- expect(provider.instance_variable_get("@resource_converged")).to be_falsey
+ expect(provider.instance_variable_get(:@resource_converged)).to be_falsey
end
it "describes the resource as converged if all DSC resources that are converged" do
@@ -71,7 +71,7 @@ describe Chef::Provider::DscScript do
allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info1, dsc_resource_info2])
provider.load_current_resource
- expect(provider.instance_variable_get("@resource_converged")).to be_truthy
+ expect(provider.instance_variable_get(:@resource_converged)).to be_truthy
end
end
@@ -126,19 +126,19 @@ describe Chef::Provider::DscScript do
describe "#generate_description" do
it "removes the resource name from the beginning of any log line from the LCM" do
dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resourcename", true, ["resourcename doing something", "lastline"])
- provider.instance_variable_set("@dsc_resources_info", [dsc_resource_info])
+ provider.instance_variable_set(:@dsc_resources_info, [dsc_resource_info])
expect(provider.send(:generate_description)[1]).to match(/converge DSC resource resourcename by doing something/)
end
it "ignores the last line" do
dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resourcename", true, ["resourcename doing something", "lastline"])
- provider.instance_variable_set("@dsc_resources_info", [dsc_resource_info])
+ provider.instance_variable_set(:@dsc_resources_info, [dsc_resource_info])
expect(provider.send(:generate_description)[1]).not_to match(/lastline/)
end
it "reports a dsc resource has not been changed if the LCM reported no change was required" do
dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resourcename", false, ["resourcename does nothing", "lastline"])
- provider.instance_variable_set("@dsc_resources_info", [dsc_resource_info])
+ provider.instance_variable_set(:@dsc_resources_info, [dsc_resource_info])
expect(provider.send(:generate_description)[1]).to match(/converge DSC resource resourcename by doing nothing/)
end
end
diff --git a/spec/unit/provider/group/usermod_spec.rb b/spec/unit/provider/group/usermod_spec.rb
index caac1857cf..4071797720 100644
--- a/spec/unit/provider/group/usermod_spec.rb
+++ b/spec/unit/provider/group/usermod_spec.rb
@@ -61,7 +61,7 @@ describe Chef::Provider::Group::Usermod do
@provider.action = :modify
@provider.define_resource_requirements
@provider.load_current_resource
- @provider.instance_variable_set("@group_exists", true)
+ @provider.instance_variable_set(:@group_exists, true)
expect { @provider.run_action(@provider.process_resource_requirements) }.to raise_error(Chef::Exceptions::Group, "setting group members directly is not supported by #{@provider}, must set append true in group")
end
@@ -69,7 +69,7 @@ describe Chef::Provider::Group::Usermod do
@provider.action = :modify
@provider.define_resource_requirements
@provider.load_current_resource
- @provider.instance_variable_set("@group_exists", true)
+ @provider.instance_variable_set(:@group_exists, true)
@new_resource.append(true)
@new_resource.excluded_members(["someone"])
expect { @provider.run_action(@provider.process_resource_requirements) }.to raise_error(Chef::Exceptions::Group, "excluded_members is not supported by #{@provider}")
diff --git a/spec/unit/provider/ifconfig/aix_spec.rb b/spec/unit/provider/ifconfig/aix_spec.rb
index 613291aabb..39edf25fcd 100644
--- a/spec/unit/provider/ifconfig/aix_spec.rb
+++ b/spec/unit/provider/ifconfig/aix_spec.rb
@@ -68,8 +68,8 @@ describe Chef::Provider::Ifconfig::Aix do
it "should add an interface if it does not exist" do
@new_resource.device "en10"
allow(@provider).to receive(:load_current_resource) do
- @provider.instance_variable_set("@status", double("Status", exitstatus: 0))
- @provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
+ @provider.instance_variable_set(:@status, double("Status", exitstatus: 0))
+ @provider.instance_variable_set(:@current_resource, Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
end
command = "chdev -l #{@new_resource.device} -a netaddr=#{@new_resource.name}"
expect(@provider).to receive(:shell_out_compacted!).with(*command.split(" "))
@@ -82,8 +82,8 @@ describe Chef::Provider::Ifconfig::Aix do
@new_resource.device "en0"
@new_resource.metric "1"
allow(@provider).to receive(:load_current_resource) do
- @provider.instance_variable_set("@status", double("Status", exitstatus: 0))
- @provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
+ @provider.instance_variable_set(:@status, double("Status", exitstatus: 0))
+ @provider.instance_variable_set(:@current_resource, Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
end
expect { @provider.run_action(:add) }.to raise_error(Chef::Exceptions::Ifconfig, "interface metric property cannot be set for :add action")
@@ -94,8 +94,8 @@ describe Chef::Provider::Ifconfig::Aix do
it "should enable an interface if it does not exist" do
@new_resource.device "en10"
allow(@provider).to receive(:load_current_resource) do
- @provider.instance_variable_set("@status", double("Status", exitstatus: 0))
- @provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
+ @provider.instance_variable_set(:@status, double("Status", exitstatus: 0))
+ @provider.instance_variable_set(:@current_resource, Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
end
command = "ifconfig #{@new_resource.device} #{@new_resource.name}"
expect(@provider).to receive(:shell_out_compacted!).with(*command.split(" "))
@@ -110,8 +110,8 @@ describe Chef::Provider::Ifconfig::Aix do
it "should not disable an interface if it does not exist" do
@new_resource.device "en10"
allow(@provider).to receive(:load_current_resource) do
- @provider.instance_variable_set("@status", double("Status", exitstatus: 0))
- @provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
+ @provider.instance_variable_set(:@status, double("Status", exitstatus: 0))
+ @provider.instance_variable_set(:@current_resource, Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
end
expect(@provider).not_to receive(:shell_out_compacted!)
@@ -124,10 +124,10 @@ describe Chef::Provider::Ifconfig::Aix do
before do
@new_resource.device "en10"
allow(@provider).to receive(:load_current_resource) do
- @provider.instance_variable_set("@status", double("Status", exitstatus: 0))
+ @provider.instance_variable_set(:@status, double("Status", exitstatus: 0))
current_resource = Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)
current_resource.device @new_resource.device
- @provider.instance_variable_set("@current_resource", current_resource)
+ @provider.instance_variable_set(:@current_resource, current_resource)
end
end
@@ -147,8 +147,8 @@ describe Chef::Provider::Ifconfig::Aix do
it "should not delete an interface if it does not exist" do
@new_resource.device "en10"
allow(@provider).to receive(:load_current_resource) do
- @provider.instance_variable_set("@status", double("Status", exitstatus: 0))
- @provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
+ @provider.instance_variable_set(:@status, double("Status", exitstatus: 0))
+ @provider.instance_variable_set(:@current_resource, Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
end
expect(@provider).not_to receive(:shell_out_compacted!)
@@ -161,10 +161,10 @@ describe Chef::Provider::Ifconfig::Aix do
before do
@new_resource.device "en10"
allow(@provider).to receive(:load_current_resource) do
- @provider.instance_variable_set("@status", double("Status", exitstatus: 0))
+ @provider.instance_variable_set(:@status, double("Status", exitstatus: 0))
current_resource = Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)
current_resource.device @new_resource.device
- @provider.instance_variable_set("@current_resource", current_resource)
+ @provider.instance_variable_set(:@current_resource, current_resource)
end
end
diff --git a/spec/unit/provider/ifconfig/debian_spec.rb b/spec/unit/provider/ifconfig/debian_spec.rb
index 308435dea2..7cf951498d 100644
--- a/spec/unit/provider/ifconfig/debian_spec.rb
+++ b/spec/unit/provider/ifconfig/debian_spec.rb
@@ -42,7 +42,7 @@ describe Chef::Provider::Ifconfig::Debian do
let(:provider) do
status = double("Status", exitstatus: 0)
provider = Chef::Provider::Ifconfig::Debian.new(new_resource, run_context)
- provider.instance_variable_set("@status", status)
+ provider.instance_variable_set(:@status, status)
provider.current_resource = current_resource
allow(provider).to receive(:load_current_resource)
allow(provider).to receive(:shell_out!)
diff --git a/spec/unit/provider/ifconfig/redhat_spec.rb b/spec/unit/provider/ifconfig/redhat_spec.rb
index 75291d3bf9..361363451a 100644
--- a/spec/unit/provider/ifconfig/redhat_spec.rb
+++ b/spec/unit/provider/ifconfig/redhat_spec.rb
@@ -40,7 +40,7 @@ describe Chef::Provider::Ifconfig::Redhat do
@current_resource = Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)
status = double("Status", exitstatus: 0)
- @provider.instance_variable_set("@status", status)
+ @provider.instance_variable_set(:@status, status)
@provider.current_resource = @current_resource
config_filename = "/etc/sysconfig/network-scripts/ifcfg-#{@new_resource.device}"
diff --git a/spec/unit/provider/ifconfig_spec.rb b/spec/unit/provider/ifconfig_spec.rb
index 166fe24304..120e63c809 100644
--- a/spec/unit/provider/ifconfig_spec.rb
+++ b/spec/unit/provider/ifconfig_spec.rb
@@ -35,7 +35,7 @@ describe Chef::Provider::Ifconfig do
@current_resource = Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)
status = double("Status", exitstatus: 0)
- @provider.instance_variable_set("@status", status)
+ @provider.instance_variable_set(:@status, status)
@provider.current_resource = @current_resource
end
@@ -58,7 +58,7 @@ describe Chef::Provider::Ifconfig do
@provider.load_current_resource
end
it "should track state of ifconfig failure" do
- expect(@provider.instance_variable_get("@status").exitstatus).not_to eq(0)
+ expect(@provider.instance_variable_get(:@status).exitstatus).not_to eq(0)
end
it "should thrown an exception when ifconfig fails" do
@provider.action = :add
@@ -79,7 +79,7 @@ describe Chef::Provider::Ifconfig do
@provider.load_current_resource
end
it "should track state of ifconfig failure" do
- expect(@provider.instance_variable_get("@status").exitstatus).not_to eq(0)
+ expect(@provider.instance_variable_get(:@status).exitstatus).not_to eq(0)
end
it "should thrown an exception when ifconfig fails" do
@provider.action = :add
diff --git a/spec/unit/provider/remote_file/cache_control_data_spec.rb b/spec/unit/provider/remote_file/cache_control_data_spec.rb
index 19848e4456..3252a08e6c 100644
--- a/spec/unit/provider/remote_file/cache_control_data_spec.rb
+++ b/spec/unit/provider/remote_file/cache_control_data_spec.rb
@@ -219,11 +219,11 @@ describe Chef::Provider::RemoteFile::CacheControlData do
let(:truncated_remote_uri) { URI.parse(long_remote_path[0...CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH]) }
let(:truncated_file_cache_path) do
cache_control_data_truncated = Chef::Provider::RemoteFile::CacheControlData.load_and_validate(truncated_remote_uri, current_file_checksum)
- cache_control_data_truncated.send("sanitized_cache_file_basename")[0...CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH]
+ cache_control_data_truncated.send(:sanitized_cache_file_basename)[0...CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH]
end
it "truncates the file cache path to 102 characters" do
- normalized_cache_path = cache_control_data.send("sanitized_cache_file_basename")
+ normalized_cache_path = cache_control_data.send(:sanitized_cache_file_basename)
expect(Chef::FileCache).to receive(:store).with("remote_file/" + normalized_cache_path, cache_control_data.json_data)
@@ -233,7 +233,7 @@ describe Chef::Provider::RemoteFile::CacheControlData do
end
it "uses a file cache path that starts with the first #{CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH} characters of the URI" do
- normalized_cache_path = cache_control_data.send("sanitized_cache_file_basename")
+ normalized_cache_path = cache_control_data.send(:sanitized_cache_file_basename)
expect(truncated_file_cache_path.length).to eq(CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH)
expect(normalized_cache_path.start_with?(truncated_file_cache_path)).to eq(true)
diff --git a/spec/unit/provider/service/gentoo_service_spec.rb b/spec/unit/provider/service/gentoo_service_spec.rb
index efab722ac8..25726684ae 100644
--- a/spec/unit/provider/service/gentoo_service_spec.rb
+++ b/spec/unit/provider/service/gentoo_service_spec.rb
@@ -49,13 +49,13 @@ describe Chef::Provider::Service::Gentoo do
it "should track when service file is not found in /etc/runlevels" do
@provider.load_current_resource
- expect(@provider.instance_variable_get("@found_script")).to be_falsey
+ expect(@provider.instance_variable_get(:@found_script)).to be_falsey
end
it "should track when service file is found in /etc/runlevels/**/" do
allow(Dir).to receive(:glob).with("/etc/runlevels/**/chef").and_return(["/etc/runlevels/default/chef"])
@provider.load_current_resource
- expect(@provider.instance_variable_get("@found_script")).to be_truthy
+ expect(@provider.instance_variable_get(:@found_script)).to be_truthy
end
describe "when detecting the service enable state" do
diff --git a/spec/unit/provider/service/upstart_service_spec.rb b/spec/unit/provider/service/upstart_service_spec.rb
index 924ac58551..5f41319c89 100644
--- a/spec/unit/provider/service/upstart_service_spec.rb
+++ b/spec/unit/provider/service/upstart_service_spec.rb
@@ -160,7 +160,7 @@ describe Chef::Provider::Service::Upstart do
it "should track state when the upstart configuration file fails to load" do
expect(File).to receive(:exist?).and_return false
@provider.load_current_resource
- expect(@provider.instance_variable_get("@config_file_found")).to eq(false)
+ expect(@provider.instance_variable_get(:@config_file_found)).to eq(false)
end
describe "when a status command has been specified" do
@@ -177,7 +177,7 @@ describe Chef::Provider::Service::Upstart do
it "should track state when the user-provided status command fails" do
allow(@provider).to receive(:shell_out!).and_raise(Errno::ENOENT)
@provider.load_current_resource
- expect(@provider.instance_variable_get("@command_success")).to eq(false)
+ expect(@provider.instance_variable_get(:@command_success)).to eq(false)
end
it "should set running to false if it catches a Chef::Exceptions::Exec when using a status command" do
@@ -190,7 +190,7 @@ describe Chef::Provider::Service::Upstart do
it "should track state when we fail to obtain service status via upstart_goal_state" do
expect(@provider).to receive(:upstart_goal_state).and_raise Chef::Exceptions::Exec
@provider.load_current_resource
- expect(@provider.instance_variable_get("@command_success")).to eq(false)
+ expect(@provider.instance_variable_get(:@command_success)).to eq(false)
end
it "should return the current resource" do
diff --git a/spec/unit/provider/user/solaris_spec.rb b/spec/unit/provider/user/solaris_spec.rb
index 4c6768cda5..58c3c0bd68 100644
--- a/spec/unit/provider/user/solaris_spec.rb
+++ b/spec/unit/provider/user/solaris_spec.rb
@@ -74,7 +74,7 @@ describe Chef::Provider::User::Solaris do
allow(Tempfile).to receive(:new).with("shadow", "/etc").and_return(temp_file)
new_resource.password "verysecurepassword"
provider.manage_user
- expect(::File.open(password_file.path, "r").read).to match(/adam:verysecurepassword:/)
+ expect(::File.read(password_file.path)).to match(/adam:verysecurepassword:/)
password_file.unlink
end
end
diff --git a/spec/unit/resource/conditional_spec.rb b/spec/unit/resource/conditional_spec.rb
index 5f99238919..5374157336 100644
--- a/spec/unit/resource/conditional_spec.rb
+++ b/spec/unit/resource/conditional_spec.rb
@@ -59,7 +59,7 @@ describe Chef::Resource::Conditional do
describe "after running a negative/false command given as a string" do
before do
- @status.send("success?=", false)
+ @status.send(:"success?=", false)
@conditional = Chef::Resource::Conditional.only_if(@parent_resource, "false")
end
@@ -80,7 +80,7 @@ describe Chef::Resource::Conditional do
describe "after running a negative/false command given as an array" do
before do
- @status.send("success?=", false)
+ @status.send(:"success?=", false)
@conditional = Chef::Resource::Conditional.only_if(@parent_resource, ["false"])
end
@@ -162,7 +162,7 @@ describe Chef::Resource::Conditional do
describe "after running a failed/false command given as a string" do
before do
- @status.send("success?=", false)
+ @status.send(:"success?=", false)
@conditional = Chef::Resource::Conditional.not_if(@parent_resource, "false")
end
@@ -183,7 +183,7 @@ describe Chef::Resource::Conditional do
describe "after running a failed/false command given as an array" do
before do
- @status.send("success?=", false)
+ @status.send(:"success?=", false)
@conditional = Chef::Resource::Conditional.not_if(@parent_resource, ["false"])
end
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index faf87076fd..f20a6d3bc6 100644
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -955,7 +955,7 @@ describe Chef::Resource do
node.name("bumblebee")
node.automatic[:platform] = "autobots"
node.automatic[:platform_version] = "6.1"
- Object.const_set("Soundwave", klz1)
+ Object.const_set(:Soundwave, klz1)
klz1.provides :soundwave
end
@@ -978,7 +978,7 @@ describe Chef::Resource do
node.automatic[:platform] = "autobots"
node.automatic[:platform_version] = "6.1"
klz2.provides :dinobot, platform: ["autobots"]
- Object.const_set("Grimlock", klz2)
+ Object.const_set(:Grimlock, klz2)
klz2.provides :grimlock
end
diff --git a/tasks/docs.rb b/tasks/docs.rb
index 2fd92cc40e..a7743ff219 100755
--- a/tasks/docs.rb
+++ b/tasks/docs.rb
@@ -133,7 +133,7 @@ namespace :docs_site do
# @return [Hash]
#
def action_list(actions, default_action)
- actions = actions.map { |k, v| [k.to_sym, { "markdown" => k == default_action.first ? "#{v} (default)" : v } ] }.to_h
+ actions = actions.to_h { |k, v| [k.to_sym, { "markdown" => k == default_action.first ? "#{v} (default)" : v } ] }
actions[:nothing] = { "shortcode" => "resources_common_actions_nothing.md" }
actions
end