summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Gemfile8
-rw-r--r--chef-bin/chef-bin.gemspec2
-rw-r--r--chef-bin/lib/chef-bin/version.rb2
-rw-r--r--chef-config/Gemfile2
-rw-r--r--chef-config/chef-config.gemspec2
-rw-r--r--chef-config/lib/chef-config/version.rb2
-rw-r--r--chef-universal-mingw32.gemspec2
-rw-r--r--chef-utils/chef-utils.gemspec2
-rw-r--r--chef-utils/lib/chef-utils/version.rb2
-rw-r--r--chef-utils/spec/unit/dsl/introspection_spec.rb1
-rw-r--r--chef-utils/spec/unit/dsl/platform_spec.rb3
-rw-r--r--lib/chef/chef_fs/file_system/repository/base_file.rb1
-rw-r--r--lib/chef/exceptions.rb3
-rw-r--r--lib/chef/knife/bootstrap/train_connector.rb1
-rw-r--r--lib/chef/knife/core/gem_glob_loader.rb2
-rw-r--r--lib/chef/knife/core/hashed_command_loader.rb1
-rw-r--r--lib/chef/knife/core/subcommand_loader.rb2
-rw-r--r--lib/chef/log.rb2
-rw-r--r--lib/chef/mixin/template.rb1
-rw-r--r--lib/chef/provider/yum_repository.rb2
-rw-r--r--lib/chef/provider/zypper_repository.rb2
-rw-r--r--lib/chef/resource.rb2
-rw-r--r--lib/chef/resource/cron_access.rb4
-rw-r--r--lib/chef/resource/cron_d.rb2
-rw-r--r--lib/chef/resource/lwrp_base.rb1
-rw-r--r--lib/chef/resource/ssh_known_hosts_entry.rb2
-rw-r--r--lib/chef/resource/sudo.rb2
-rw-r--r--lib/chef/shell/shell_session.rb2
-rw-r--r--lib/chef/version.rb2
-rw-r--r--omnibus/config/projects/angrychef.rb2
-rw-r--r--spec/functional/run_lock_spec.rb3
-rw-r--r--spec/functional/util/powershell/cmdlet_spec.rb2
-rw-r--r--spec/functional/version_spec.rb2
-rw-r--r--spec/integration/recipes/accumulator_spec.rb2
-rw-r--r--spec/integration/recipes/lwrp_inline_resources_spec.rb2
-rw-r--r--spec/integration/recipes/lwrp_spec.rb2
-rw-r--r--spec/integration/recipes/notifies_spec.rb2
-rw-r--r--spec/integration/recipes/notifying_block_spec.rb2
-rw-r--r--spec/integration/recipes/recipe_dsl_spec.rb2
-rw-r--r--spec/integration/recipes/resource_converge_if_changed_spec.rb2
-rw-r--r--spec/integration/recipes/resource_load_spec.rb1
-rw-r--r--spec/integration/recipes/unified_mode_spec.rb2
-rw-r--r--spec/scripts/ssl-serve.rb2
-rw-r--r--spec/spec_helper.rb8
-rw-r--r--spec/unit/dsl/platform_introspection_spec.rb1
-rw-r--r--spec/unit/event_dispatch/dispatcher_spec.rb3
-rw-r--r--spec/unit/lwrp_spec.rb8
-rw-r--r--spec/unit/property_spec.rb10
-rw-r--r--spec/unit/provider_spec.rb1
-rw-r--r--spec/unit/run_context/cookbook_compiler_spec.rb2
50 files changed, 74 insertions, 49 deletions
diff --git a/Gemfile b/Gemfile
index 2832a9b426..3b06e9a59a 100644
--- a/Gemfile
+++ b/Gemfile
@@ -9,12 +9,12 @@ gem "chef", path: "."
gem "ohai", git: "https://github.com/chef/ohai.git", branch: "15-stable"
-gem "chef-utils", path: File.expand_path("../chef-utils", __FILE__) if File.exist?(File.expand_path("../chef-utils", __FILE__))
-gem "chef-config", path: File.expand_path("../chef-config", __FILE__) if File.exist?(File.expand_path("../chef-config", __FILE__))
+gem "chef-utils", path: File.expand_path("chef-utils", __dir__) if File.exist?(File.expand_path("chef-utils", __dir__))
+gem "chef-config", path: File.expand_path("chef-config", __dir__) if File.exist?(File.expand_path("chef-config", __dir__))
-if File.exist?(File.expand_path("../chef-bin", __FILE__))
+if File.exist?(File.expand_path("chef-bin", __dir__))
# bundling in a git checkout
- gem "chef-bin", path: File.expand_path("../chef-bin", __FILE__)
+ gem "chef-bin", path: File.expand_path("chef-bin", __dir__)
else
# bundling in omnibus
gem "chef-bin" # rubocop:disable Bundler/DuplicatedGem
diff --git a/chef-bin/chef-bin.gemspec b/chef-bin/chef-bin.gemspec
index 4ca7da4f6b..bbf57f3d21 100644
--- a/chef-bin/chef-bin.gemspec
+++ b/chef-bin/chef-bin.gemspec
@@ -1,4 +1,4 @@
-lib = File.expand_path("../lib", __FILE__)
+lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "chef-bin/version"
diff --git a/chef-bin/lib/chef-bin/version.rb b/chef-bin/lib/chef-bin/version.rb
index 0ba338018f..13af48d8c0 100644
--- a/chef-bin/lib/chef-bin/version.rb
+++ b/chef-bin/lib/chef-bin/version.rb
@@ -20,7 +20,7 @@
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
module ChefBin
- CHEFBIN_ROOT = File.expand_path("../..", __FILE__)
+ CHEFBIN_ROOT = File.expand_path("..", __dir__)
VERSION = "15.13.2".freeze
end
diff --git a/chef-config/Gemfile b/chef-config/Gemfile
index 1652c89ad6..c3d90e5e6c 100644
--- a/chef-config/Gemfile
+++ b/chef-config/Gemfile
@@ -1,6 +1,6 @@
source "https://rubygems.org"
-gem "chef-utils", path: File.expand_path("../../chef-utils", __FILE__) if File.exist?(File.expand_path("../../chef-utils", __FILE__))
+gem "chef-utils", path: File.expand_path("../chef-utils", __dir__) if File.exist?(File.expand_path("../chef-utils", __dir__))
# Specify your gem's dependencies in chef-config.gemspec
gemspec
diff --git a/chef-config/chef-config.gemspec b/chef-config/chef-config.gemspec
index a273b70d44..6b4312c13d 100644
--- a/chef-config/chef-config.gemspec
+++ b/chef-config/chef-config.gemspec
@@ -1,4 +1,4 @@
-lib = File.expand_path("../lib", __FILE__)
+lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "chef-config/version"
diff --git a/chef-config/lib/chef-config/version.rb b/chef-config/lib/chef-config/version.rb
index de1ee8c0f3..36262655be 100644
--- a/chef-config/lib/chef-config/version.rb
+++ b/chef-config/lib/chef-config/version.rb
@@ -14,6 +14,6 @@
# limitations under the License.
module ChefConfig
- CHEFCONFIG_ROOT = File.expand_path("../..", __FILE__)
+ CHEFCONFIG_ROOT = File.expand_path("..", __dir__)
VERSION = "15.13.2".freeze
end
diff --git a/chef-universal-mingw32.gemspec b/chef-universal-mingw32.gemspec
index 49228f6c9e..21429b38ab 100644
--- a/chef-universal-mingw32.gemspec
+++ b/chef-universal-mingw32.gemspec
@@ -1,4 +1,4 @@
-gemspec = eval(IO.read(File.expand_path("../chef.gemspec", __FILE__)))
+gemspec = eval(IO.read(File.expand_path("chef.gemspec", __dir__)))
gemspec.platform = Gem::Platform.new(%w{universal mingw32})
diff --git a/chef-utils/chef-utils.gemspec b/chef-utils/chef-utils.gemspec
index 3f135de6ba..0fd6ad668d 100644
--- a/chef-utils/chef-utils.gemspec
+++ b/chef-utils/chef-utils.gemspec
@@ -1,4 +1,4 @@
-lib = File.expand_path("../lib", __FILE__)
+lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "chef-utils/version"
diff --git a/chef-utils/lib/chef-utils/version.rb b/chef-utils/lib/chef-utils/version.rb
index a760c45a04..c422fe13b3 100644
--- a/chef-utils/lib/chef-utils/version.rb
+++ b/chef-utils/lib/chef-utils/version.rb
@@ -14,6 +14,6 @@
# limitations under the License.
module ChefUtils
- CHEFUTILS_ROOT = File.expand_path("../..", __FILE__)
+ CHEFUTILS_ROOT = File.expand_path("..", __dir__)
VERSION = "15.13.2".freeze
end
diff --git a/chef-utils/spec/unit/dsl/introspection_spec.rb b/chef-utils/spec/unit/dsl/introspection_spec.rb
index 44a228061d..9275a9fc79 100644
--- a/chef-utils/spec/unit/dsl/introspection_spec.rb
+++ b/chef-utils/spec/unit/dsl/introspection_spec.rb
@@ -21,6 +21,7 @@ RSpec.describe ChefUtils::DSL::Introspection do
class IntrospectionTestClass
include ChefUtils::DSL::Introspection
attr_accessor :node
+
def initialize(node)
@node = node
end
diff --git a/chef-utils/spec/unit/dsl/platform_spec.rb b/chef-utils/spec/unit/dsl/platform_spec.rb
index 69efae877c..93b61f0532 100644
--- a/chef-utils/spec/unit/dsl/platform_spec.rb
+++ b/chef-utils/spec/unit/dsl/platform_spec.rb
@@ -58,6 +58,7 @@ RSpec.describe ChefUtils::DSL::Platform do
class ThingWithANode
include ChefUtils::DSL::Platform
attr_accessor :node
+
def initialize(node)
@node = node
end
@@ -69,6 +70,7 @@ RSpec.describe ChefUtils::DSL::Platform do
attr_accessor :node
end
attr_accessor :run_context
+
def initialize(node)
@run_context = RunContext.new
run_context.node = node
@@ -78,6 +80,7 @@ RSpec.describe ChefUtils::DSL::Platform do
class ThingWithTheDSL
include ChefUtils
attr_accessor :node
+
def initialize(node)
@node = node
end
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 582f4130a8..94b52b9201 100644
--- a/lib/chef/chef_fs/file_system/repository/base_file.rb
+++ b/lib/chef/chef_fs/file_system/repository/base_file.rb
@@ -92,6 +92,7 @@ class Chef
end
attr_writer :write_pretty_json
+
def write_pretty_json
@write_pretty_json.nil? ? root.write_pretty_json : @write_pretty_json
end
diff --git a/lib/chef/exceptions.rb b/lib/chef/exceptions.rb
index 645193389e..444fe82df1 100644
--- a/lib/chef/exceptions.rb
+++ b/lib/chef/exceptions.rb
@@ -198,6 +198,7 @@ class Chef
class MetadataNotFound < StandardError
attr_reader :install_path
attr_reader :cookbook_name
+
def initialize(install_path, cookbook_name)
@install_path = install_path
@cookbook_name = cookbook_name
@@ -448,6 +449,7 @@ class Chef
# to correctly populate the backtrace with the wrapped backtraces.
class RunFailedWrappingError < RuntimeError
attr_reader :wrapped_errors
+
def initialize(*errors)
errors = errors.select { |e| !e.nil? }
output = "Found #{errors.size} errors, they are stored in the backtrace"
@@ -488,6 +490,7 @@ class Chef
class MultipleDscResourcesFound < RuntimeError
attr_reader :resources_found
+
def initialize(resources_found)
@resources_found = resources_found
matches_info = @resources_found.each do |r|
diff --git a/lib/chef/knife/bootstrap/train_connector.rb b/lib/chef/knife/bootstrap/train_connector.rb
index 623720c0ad..8a1e5863bb 100644
--- a/lib/chef/knife/bootstrap/train_connector.rb
+++ b/lib/chef/knife/bootstrap/train_connector.rb
@@ -322,6 +322,7 @@ class Chef
class RemoteExecutionFailed < StandardError
attr_reader :exit_status, :command, :hostname, :stdout, :stderr
+
def initialize(hostname, command, result)
@hostname = hostname
@exit_status = result.exit_status
diff --git a/lib/chef/knife/core/gem_glob_loader.rb b/lib/chef/knife/core/gem_glob_loader.rb
index dc812e515f..b29df38c86 100644
--- a/lib/chef/knife/core/gem_glob_loader.rb
+++ b/lib/chef/knife/core/gem_glob_loader.rb
@@ -47,7 +47,7 @@ class Chef
def find_subcommands_via_dirglob
# The "require paths" of the core knife subcommands bundled with chef
- files = Dir[File.join(Chef::Util::PathHelper.escape_glob_dir(File.expand_path("../../../knife", __FILE__)), "*.rb")]
+ files = Dir[File.join(Chef::Util::PathHelper.escape_glob_dir(File.expand_path("../../knife", __dir__)), "*.rb")]
subcommand_files = {}
files.each do |knife_file|
rel_path = knife_file[/#{CHEF_ROOT}#{Regexp.escape(File::SEPARATOR)}(.*)\.rb/, 1]
diff --git a/lib/chef/knife/core/hashed_command_loader.rb b/lib/chef/knife/core/hashed_command_loader.rb
index c76a596dde..94a83972ae 100644
--- a/lib/chef/knife/core/hashed_command_loader.rb
+++ b/lib/chef/knife/core/hashed_command_loader.rb
@@ -27,6 +27,7 @@ class Chef
KEY = "_autogenerated_command_paths".freeze
attr_accessor :manifest
+
def initialize(chef_config_dir, plugin_manifest)
super(chef_config_dir)
@manifest = plugin_manifest
diff --git a/lib/chef/knife/core/subcommand_loader.rb b/lib/chef/knife/core/subcommand_loader.rb
index e941b10d47..651207d0cb 100644
--- a/lib/chef/knife/core/subcommand_loader.rb
+++ b/lib/chef/knife/core/subcommand_loader.rb
@@ -125,7 +125,7 @@ class Chef
#
def find_subcommands_via_dirglob
# The "require paths" of the core knife subcommands bundled with chef
- files = Dir[File.join(Chef::Util::PathHelper.escape_glob_dir(File.expand_path("../../../knife", __FILE__)), "*.rb")]
+ files = Dir[File.join(Chef::Util::PathHelper.escape_glob_dir(File.expand_path("../../knife", __dir__)), "*.rb")]
subcommand_files = {}
files.each do |knife_file|
rel_path = knife_file[/#{CHEF_ROOT}#{Regexp.escape(File::SEPARATOR)}(.*)\.rb/, 1]
diff --git a/lib/chef/log.rb b/lib/chef/log.rb
index 88d9bff939..7b8518f5fd 100644
--- a/lib/chef/log.rb
+++ b/lib/chef/log.rb
@@ -47,7 +47,7 @@ class Chef
def self.caller_location
# Pick the first caller that is *not* part of the Chef gem, that's the
# thing the user wrote. Or failing that, the most recent caller.
- chef_gem_path = File.expand_path("../..", __FILE__)
+ chef_gem_path = File.expand_path("..", __dir__)
caller(0..20).find { |c| !c.start_with?(chef_gem_path) } || caller(0..1)[0]
end
diff --git a/lib/chef/mixin/template.rb b/lib/chef/mixin/template.rb
index 06c191d63b..d72bfe9e3a 100644
--- a/lib/chef/mixin/template.rb
+++ b/lib/chef/mixin/template.rb
@@ -213,6 +213,7 @@ class Chef
class TemplateError < RuntimeError
attr_reader :original_exception, :context, :options
+
SOURCE_CONTEXT_WINDOW = 2
def initialize(original_exception, template, context, options)
diff --git a/lib/chef/provider/yum_repository.rb b/lib/chef/provider/yum_repository.rb
index d3e281775a..956d5ae64c 100644
--- a/lib/chef/provider/yum_repository.rb
+++ b/lib/chef/provider/yum_repository.rb
@@ -37,7 +37,7 @@ class Chef
if template_available?(new_resource.source)
source new_resource.source
else
- source ::File.expand_path("../support/yum_repo.erb", __FILE__)
+ source ::File.expand_path("support/yum_repo.erb", __dir__)
local true
end
sensitive new_resource.sensitive
diff --git a/lib/chef/provider/zypper_repository.rb b/lib/chef/provider/zypper_repository.rb
index 4602d804b9..d2d4d68d76 100644
--- a/lib/chef/provider/zypper_repository.rb
+++ b/lib/chef/provider/zypper_repository.rb
@@ -41,7 +41,7 @@ class Chef
if template_available?(new_resource.source)
source new_resource.source
else
- source ::File.expand_path("../support/zypper_repo.erb", __FILE__)
+ source ::File.expand_path("support/zypper_repo.erb", __dir__)
local true
end
sensitive new_resource.sensitive
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index 2c3bafd4f1..98e223491e 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -613,6 +613,7 @@ class Chef
# Do NOT use this. It may be removed. It is for internal purposes only.
# @api private
attr_reader :resource_initializing
+
def resource_initializing=(value)
if value
@resource_initializing = true
@@ -863,6 +864,7 @@ class Chef
# have.
#
attr_writer :allowed_actions
+
def allowed_actions(value = NOT_PASSED)
if value != NOT_PASSED
self.allowed_actions = value
diff --git a/lib/chef/resource/cron_access.rb b/lib/chef/resource/cron_access.rb
index 7ec5387c0c..ed7d425c8e 100644
--- a/lib/chef/resource/cron_access.rb
+++ b/lib/chef/resource/cron_access.rb
@@ -66,7 +66,7 @@ class Chef
with_run_context :root do
edit_resource(:template, allow_path) do |new_resource|
- source ::File.expand_path("../support/cron_access.erb", __FILE__)
+ source ::File.expand_path("support/cron_access.erb", __dir__)
local true
mode "0600"
variables["users"] ||= []
@@ -83,7 +83,7 @@ class Chef
with_run_context :root do
edit_resource(:template, deny_path) do |new_resource|
- source ::File.expand_path("../support/cron_access.erb", __FILE__)
+ source ::File.expand_path("support/cron_access.erb", __dir__)
local true
mode "0600"
variables["users"] ||= []
diff --git a/lib/chef/resource/cron_d.rb b/lib/chef/resource/cron_d.rb
index dd55a4b1b1..64219de5d7 100644
--- a/lib/chef/resource/cron_d.rb
+++ b/lib/chef/resource/cron_d.rb
@@ -289,7 +289,7 @@ class Chef
# @todo this is Chef 12 era cleanup. Someday we should remove it all
template "/etc/cron.d/#{sanitized_name}" do
- source ::File.expand_path("../support/cron.d.erb", __FILE__)
+ source ::File.expand_path("support/cron.d.erb", __dir__)
local true
mode new_resource.mode
variables(
diff --git a/lib/chef/resource/lwrp_base.rb b/lib/chef/resource/lwrp_base.rb
index 3c0da3f422..c3aa6beb96 100644
--- a/lib/chef/resource/lwrp_base.rb
+++ b/lib/chef/resource/lwrp_base.rb
@@ -109,6 +109,7 @@ class Chef
protected
attr_writer :loaded_lwrps
+
def loaded_lwrps
@loaded_lwrps ||= {}
end
diff --git a/lib/chef/resource/ssh_known_hosts_entry.rb b/lib/chef/resource/ssh_known_hosts_entry.rb
index 9c94fcb4b2..a0d5a4a319 100644
--- a/lib/chef/resource/ssh_known_hosts_entry.rb
+++ b/lib/chef/resource/ssh_known_hosts_entry.rb
@@ -88,7 +88,7 @@ class Chef
r = with_run_context :root do
find_resource(:template, "update ssh known hosts file #{new_resource.file_location}") do
- source ::File.expand_path("../support/ssh_known_hosts.erb", __FILE__)
+ source ::File.expand_path("support/ssh_known_hosts.erb", __dir__)
local true
path new_resource.file_location
owner new_resource.owner
diff --git a/lib/chef/resource/sudo.rb b/lib/chef/resource/sudo.rb
index 051bbd8c0e..c59d610816 100644
--- a/lib/chef/resource/sudo.rb
+++ b/lib/chef/resource/sudo.rb
@@ -172,7 +172,7 @@ class Chef
end
else
declare_resource(:template, file_path) do
- source ::File.expand_path("../support/sudoer.erb", __FILE__)
+ source ::File.expand_path("support/sudoer.erb", __dir__)
local true
mode "0440"
variables sudoer: (new_resource.groups + new_resource.users).join(","),
diff --git a/lib/chef/shell/shell_session.rb b/lib/chef/shell/shell_session.rb
index 49348d415d..a1957c6667 100644
--- a/lib/chef/shell/shell_session.rb
+++ b/lib/chef/shell/shell_session.rb
@@ -41,6 +41,7 @@ module Shell
attr_accessor :node, :compile, :recipe, :json_configuration
attr_reader :node_attributes, :client
+
def initialize
@node_built = false
formatter = Chef::Formatters.new(Chef::Config.formatter, STDOUT, STDERR)
@@ -75,6 +76,7 @@ module Shell
end
attr_writer :run_context
+
def run_context
@run_context ||= rebuild_context
end
diff --git a/lib/chef/version.rb b/lib/chef/version.rb
index 55ad93be3f..dbe937c0e2 100644
--- a/lib/chef/version.rb
+++ b/lib/chef/version.rb
@@ -22,7 +22,7 @@
require_relative "version_string"
class Chef
- CHEF_ROOT = File.expand_path("../..", __FILE__)
+ CHEF_ROOT = File.expand_path("..", __dir__)
VERSION = Chef::VersionString.new("15.13.2")
end
diff --git a/omnibus/config/projects/angrychef.rb b/omnibus/config/projects/angrychef.rb
index eb6dce476d..57f2c023fe 100644
--- a/omnibus/config/projects/angrychef.rb
+++ b/omnibus/config/projects/angrychef.rb
@@ -20,7 +20,7 @@
# `config/project/chef.rb`.
#
current_file = __FILE__
-chef_project_contents = IO.read(File.expand_path("../chef.rb", __FILE__))
+chef_project_contents = IO.read(File.expand_path("chef.rb", __dir__))
instance_eval chef_project_contents
name "angrychef"
diff --git a/spec/functional/run_lock_spec.rb b/spec/functional/run_lock_spec.rb
index 8f4d5ad32e..da200b3b76 100644
--- a/spec/functional/run_lock_spec.rb
+++ b/spec/functional/run_lock_spec.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require File.expand_path("../../spec_helper", __FILE__)
+require File.expand_path("../spec_helper", __dir__)
require "chef/client"
describe Chef::RunLock do
@@ -435,6 +435,7 @@ describe Chef::RunLock do
class TestRunLock < Chef::RunLock
attr_accessor :client_process
+
def create_lock
super
client_process.fire_event("created lock")
diff --git a/spec/functional/util/powershell/cmdlet_spec.rb b/spec/functional/util/powershell/cmdlet_spec.rb
index 39bb9b895a..7c15b65c8a 100644
--- a/spec/functional/util/powershell/cmdlet_spec.rb
+++ b/spec/functional/util/powershell/cmdlet_spec.rb
@@ -17,7 +17,7 @@
#
require "chef/json_compat"
-require File.expand_path("../../../../spec_helper", __FILE__)
+require File.expand_path("../../../spec_helper", __dir__)
describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do
before(:all) do
diff --git a/spec/functional/version_spec.rb b/spec/functional/version_spec.rb
index 15865d4254..da2a997630 100644
--- a/spec/functional/version_spec.rb
+++ b/spec/functional/version_spec.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require File.expand_path("../../spec_helper", __FILE__)
+require File.expand_path("../spec_helper", __dir__)
require "chef/mixin/shell_out"
require "chef/version"
require "ohai/version"
diff --git a/spec/integration/recipes/accumulator_spec.rb b/spec/integration/recipes/accumulator_spec.rb
index e0ecfd340a..329137440c 100644
--- a/spec/integration/recipes/accumulator_spec.rb
+++ b/spec/integration/recipes/accumulator_spec.rb
@@ -6,7 +6,7 @@ describe "Accumulators" do
include IntegrationSupport
include Chef::Mixin::ShellOut
- let(:chef_dir) { File.expand_path("../../../../bin", __FILE__) }
+ let(:chef_dir) { File.expand_path("../../../bin", __dir__) }
# Invoke `chef-client` as `ruby PATH/TO/chef-client`. This ensures the
# following constraints are satisfied:
diff --git a/spec/integration/recipes/lwrp_inline_resources_spec.rb b/spec/integration/recipes/lwrp_inline_resources_spec.rb
index 364725277b..65d7429a9c 100644
--- a/spec/integration/recipes/lwrp_inline_resources_spec.rb
+++ b/spec/integration/recipes/lwrp_inline_resources_spec.rb
@@ -6,7 +6,7 @@ describe "LWRPs with inline resources" do
include IntegrationSupport
include Chef::Mixin::ShellOut
- let(:chef_dir) { File.expand_path("../../../../bin", __FILE__) }
+ let(:chef_dir) { File.expand_path("../../../bin", __dir__) }
# Invoke `chef-client` as `ruby PATH/TO/chef-client`. This ensures the
# following constraints are satisfied:
diff --git a/spec/integration/recipes/lwrp_spec.rb b/spec/integration/recipes/lwrp_spec.rb
index 1c772a378f..b7a0589675 100644
--- a/spec/integration/recipes/lwrp_spec.rb
+++ b/spec/integration/recipes/lwrp_spec.rb
@@ -6,7 +6,7 @@ describe "LWRPs" do
include IntegrationSupport
include Chef::Mixin::ShellOut
- let(:chef_dir) { File.expand_path("../../../../bin", __FILE__) }
+ let(:chef_dir) { File.expand_path("../../../bin", __dir__) }
# Invoke `chef-client` as `ruby PATH/TO/chef-client`. This ensures the
# following constraints are satisfied:
diff --git a/spec/integration/recipes/notifies_spec.rb b/spec/integration/recipes/notifies_spec.rb
index 9990e81fe5..9af3f32c6d 100644
--- a/spec/integration/recipes/notifies_spec.rb
+++ b/spec/integration/recipes/notifies_spec.rb
@@ -6,7 +6,7 @@ describe "notifications" do
include IntegrationSupport
include Chef::Mixin::ShellOut
- let(:chef_dir) { File.expand_path("../../../../bin", __FILE__) }
+ let(:chef_dir) { File.expand_path("../../../bin", __dir__) }
let(:chef_client) { "bundle exec chef-client --minimal-ohai" }
when_the_repository "notifies a nameless resource" do
diff --git a/spec/integration/recipes/notifying_block_spec.rb b/spec/integration/recipes/notifying_block_spec.rb
index 5f42f9d2a4..1b7f357313 100644
--- a/spec/integration/recipes/notifying_block_spec.rb
+++ b/spec/integration/recipes/notifying_block_spec.rb
@@ -23,7 +23,7 @@ describe "notifying_block" do
include IntegrationSupport
include Chef::Mixin::ShellOut
- let(:chef_dir) { File.expand_path("../../../../bin", __FILE__) }
+ let(:chef_dir) { File.expand_path("../../../bin", __dir__) }
let(:chef_client) { "bundle exec chef-client --minimal-ohai" }
when_the_repository "notifying_block test one" do
diff --git a/spec/integration/recipes/recipe_dsl_spec.rb b/spec/integration/recipes/recipe_dsl_spec.rb
index 1a8a5aa4b0..e85a7136a5 100644
--- a/spec/integration/recipes/recipe_dsl_spec.rb
+++ b/spec/integration/recipes/recipe_dsl_spec.rb
@@ -1319,7 +1319,7 @@ describe "Recipe DSL methods" do
it "utf-8 dsl names work" do
recipe = converge do
- Straße("blah") {}
+ Straße("blah") {} # rubocop: disable Naming/AsciiIdentifiers
end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_resource).to eq(UTF8Thingy)
diff --git a/spec/integration/recipes/resource_converge_if_changed_spec.rb b/spec/integration/recipes/resource_converge_if_changed_spec.rb
index 97314646d9..e1bb571479 100644
--- a/spec/integration/recipes/resource_converge_if_changed_spec.rb
+++ b/spec/integration/recipes/resource_converge_if_changed_spec.rb
@@ -6,6 +6,7 @@ describe "Resource::ActionClass#converge_if_changed" do
module Namer
extend self
attr_accessor :current_index
+
def incrementing_value
@incrementing_value += 1
@incrementing_value
@@ -30,6 +31,7 @@ describe "Resource::ActionClass#converge_if_changed" do
property :state2, default: "default_state2"
property :sensitive1, default: "default_dontprintme", sensitive: true
attr_accessor :converged
+
def initialize(*args)
super
@converged = 0
diff --git a/spec/integration/recipes/resource_load_spec.rb b/spec/integration/recipes/resource_load_spec.rb
index 79df1d6478..ec17cfbe84 100644
--- a/spec/integration/recipes/resource_load_spec.rb
+++ b/spec/integration/recipes/resource_load_spec.rb
@@ -6,6 +6,7 @@ describe "Resource.load_current_value" do
module Namer
extend self
attr_accessor :current_index
+
def incrementing_value
@incrementing_value += 1
@incrementing_value
diff --git a/spec/integration/recipes/unified_mode_spec.rb b/spec/integration/recipes/unified_mode_spec.rb
index bb8cffae3f..b2c3620fdb 100644
--- a/spec/integration/recipes/unified_mode_spec.rb
+++ b/spec/integration/recipes/unified_mode_spec.rb
@@ -6,7 +6,7 @@ describe "Unified Mode" do
include IntegrationSupport
include Chef::Mixin::ShellOut
- let(:chef_dir) { File.expand_path("../../../../bin", __FILE__) }
+ let(:chef_dir) { File.expand_path("../../../bin", __dir__) }
let(:chef_client) { "bundle exec chef-client --minimal-ohai" }
diff --git a/spec/scripts/ssl-serve.rb b/spec/scripts/ssl-serve.rb
index e9f645416c..b03fe4af42 100644
--- a/spec/scripts/ssl-serve.rb
+++ b/spec/scripts/ssl-serve.rb
@@ -12,7 +12,7 @@ require "webrick/https"
$ssl = true
-CHEF_SPEC_DATA = File.expand_path("../../data", __FILE__)
+CHEF_SPEC_DATA = File.expand_path("../data", __dir__)
cert_text = File.read(File.expand_path("ssl/chef-rspec.cert", CHEF_SPEC_DATA))
cert = OpenSSL::X509::Certificate.new(cert_text)
key_text = File.read(File.expand_path("ssl/chef-rspec.key", CHEF_SPEC_DATA))
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index e85a417578..4055b19d85 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -24,10 +24,10 @@ module Shell
IRB = nil unless defined? IRB
end
-$LOAD_PATH.unshift File.expand_path("../..", __FILE__)
-$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
-$LOAD_PATH.unshift File.expand_path("../../chef-config/lib", __FILE__)
-$LOAD_PATH.unshift File.expand_path("../../chef-utils/lib", __FILE__)
+$LOAD_PATH.unshift File.expand_path("..", __dir__)
+$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
+$LOAD_PATH.unshift File.expand_path("../chef-config/lib", __dir__)
+$LOAD_PATH.unshift File.expand_path("../chef-utils/lib", __dir__)
$LOAD_PATH.unshift File.dirname(__FILE__)
require "rubygems"
diff --git a/spec/unit/dsl/platform_introspection_spec.rb b/spec/unit/dsl/platform_introspection_spec.rb
index 4ac6c420fa..875de03f8e 100644
--- a/spec/unit/dsl/platform_introspection_spec.rb
+++ b/spec/unit/dsl/platform_introspection_spec.rb
@@ -21,6 +21,7 @@ require "chef/dsl/platform_introspection"
class LanguageTester
attr_reader :node
+
def initialize(node)
@node = node
end
diff --git a/spec/unit/event_dispatch/dispatcher_spec.rb b/spec/unit/event_dispatch/dispatcher_spec.rb
index 8499ba13b9..7942e8eb6b 100644
--- a/spec/unit/event_dispatch/dispatcher_spec.rb
+++ b/spec/unit/event_dispatch/dispatcher_spec.rb
@@ -61,6 +61,7 @@ describe Chef::EventDispatch::Dispatcher do
let(:event_sink) do
Class.new(Chef::EventDispatch::Base) do
attr_reader :synchronized_cookbook_args
+
def synchronized_cookbook(cookbook_name)
@synchronized_cookbook_args = [cookbook_name]
end
@@ -79,6 +80,7 @@ describe Chef::EventDispatch::Dispatcher do
let(:event_sink_1) do
Class.new(Chef::EventDispatch::Base) do
attr_reader :synchronized_cookbook_args
+
def synchronized_cookbook(cookbook_name)
@synchronized_cookbook_args = [cookbook_name]
end
@@ -87,6 +89,7 @@ describe Chef::EventDispatch::Dispatcher do
let(:event_sink_2) do
Class.new(Chef::EventDispatch::Base) do
attr_reader :synchronized_cookbook_args
+
def synchronized_cookbook(cookbook_name, cookbook)
@synchronized_cookbook_args = [cookbook_name, cookbook]
end
diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb
index 29a9945d8f..dba7aab4c0 100644
--- a/spec/unit/lwrp_spec.rb
+++ b/spec/unit/lwrp_spec.rb
@@ -140,7 +140,7 @@ describe "LWRP" do
before do
@tmpdir = Dir.mktmpdir("lwrp_test")
@lwrp_path = File.join(@tmpdir, "foo.rb")
- content = IO.read(File.expand_path("../../data/lwrp/resources/foo.rb", __FILE__))
+ content = IO.read(File.expand_path("../data/lwrp/resources/foo.rb", __dir__))
IO.write(@lwrp_path, content)
Chef::Resource::LWRPBase.build_from_file("lwrp", @lwrp_path, nil)
@original_resource = Chef::ResourceResolver.resolve(:lwrp_foo)
@@ -152,7 +152,7 @@ describe "LWRP" do
context "And the LWRP is asked to load again, this time with different code" do
before do
- content = IO.read(File.expand_path("../../data/lwrp_override/resources/foo.rb", __FILE__))
+ content = IO.read(File.expand_path("../data/lwrp_override/resources/foo.rb", __dir__))
IO.write(@lwrp_path, content)
Chef::Resource::LWRPBase.build_from_file("lwrp", @lwrp_path, nil)
end
@@ -390,11 +390,11 @@ describe "LWRP" do
end
before(:each) do
- Dir[File.expand_path(File.expand_path("../../data/lwrp/resources/*", __FILE__))].each do |file|
+ Dir[File.expand_path(File.expand_path("../data/lwrp/resources/*", __dir__))].each do |file|
Chef::Resource::LWRPBase.build_from_file(lwrp_cookbook_name, file, run_context)
end
- Dir[File.expand_path(File.expand_path("../../data/lwrp/providers/*", __FILE__))].each do |file|
+ Dir[File.expand_path(File.expand_path("../data/lwrp/providers/*", __dir__))].each do |file|
Chef::Provider::LWRPBase.build_from_file(lwrp_cookbook_name, file, run_context)
end
end
diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb
index cf2b98198a..529fe7d0ca 100644
--- a/spec/unit/property_spec.rb
+++ b/spec/unit/property_spec.rb
@@ -111,11 +111,11 @@ describe "Chef::Resource.property" do
with_property ":Straße" do
it "properties with UTF-8 in their name work" do
- expect(resource.Straße).to eql(nil)
- expect(resource.Straße "foo").to eql("foo")
- expect(resource.Straße).to eql("foo")
- expect(resource.Straße = "bar").to eql("bar")
- expect(resource.Straße).to eql("bar")
+ expect(resource.Straße).to eql(nil) # rubocop: disable Naming/AsciiIdentifiers
+ expect(resource.Straße "foo").to eql("foo") # rubocop: disable Naming/AsciiIdentifiers
+ expect(resource.Straße).to eql("foo") # rubocop: disable Naming/AsciiIdentifiers
+ expect(resource.Straße = "bar").to eql("bar") # rubocop: disable Naming/AsciiIdentifiers
+ expect(resource.Straße).to eql("bar") # rubocop: disable Naming/AsciiIdentifiers
end
end
diff --git a/spec/unit/provider_spec.rb b/spec/unit/provider_spec.rb
index ddee406e31..a8f0ede94e 100644
--- a/spec/unit/provider_spec.rb
+++ b/spec/unit/provider_spec.rb
@@ -20,6 +20,7 @@ require "spec_helper"
class NoWhyrunDemonstrator < Chef::Provider
attr_reader :system_state_altered
+
def whyrun_supported?
false
end
diff --git a/spec/unit/run_context/cookbook_compiler_spec.rb b/spec/unit/run_context/cookbook_compiler_spec.rb
index 3c6f8aa581..4d744edc3a 100644
--- a/spec/unit/run_context/cookbook_compiler_spec.rb
+++ b/spec/unit/run_context/cookbook_compiler_spec.rb
@@ -175,7 +175,7 @@ describe Chef::RunContext::CookbookCompiler do
describe "event dispatch" do
let(:recipe) { "dependency1::default" }
let(:recipe_path) do
- File.expand_path("../../../data/run_context/cookbooks/dependency1/recipes/default.rb", __FILE__)
+ File.expand_path("../../data/run_context/cookbooks/dependency1/recipes/default.rb", __dir__)
end
before do
node.run_list(recipe)