summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/knife2
-rwxr-xr-xchef-bin/bin/chef-apply2
-rwxr-xr-xchef-bin/bin/chef-client2
-rwxr-xr-xchef-bin/bin/chef-resource-inspector2
-rwxr-xr-xchef-bin/bin/chef-service-manager2
-rwxr-xr-xchef-bin/bin/chef-shell2
-rwxr-xr-xchef-bin/bin/chef-solo2
-rwxr-xr-xchef-bin/bin/chef-windows-service2
-rw-r--r--chef.gemspec2
-rw-r--r--lib/chef/knife/bootstrap.rb2
-rw-r--r--omnibus/files/openssl-customization/windows/ssl_env_hack.rb2
-rw-r--r--omnibus_overrides.rb2
-rw-r--r--spec/data/shef-config.rb2
-rwxr-xr-xspec/functional/resource/aix_service_spec.rb4
-rwxr-xr-xspec/functional/resource/aixinit_service_spec.rb2
-rw-r--r--spec/functional/resource/insserv_spec.rb2
-rw-r--r--spec/functional/version_spec.rb2
-rw-r--r--spec/integration/client/client_spec.rb2
-rw-r--r--spec/integration/client/exit_code_spec.rb2
-rw-r--r--spec/integration/client/ipv6_spec.rb2
-rw-r--r--spec/integration/knife/cookbook_api_ipv6_spec.rb2
-rw-r--r--spec/integration/recipes/remote_directory.rb2
-rw-r--r--spec/integration/solo/solo_spec.rb4
-rw-r--r--spec/stress/win32/file_spec.rb2
-rw-r--r--spec/support/chef_helpers.rb4
-rw-r--r--spec/support/matchers/leak.rb4
-rw-r--r--spec/support/shared/functional/win32_service.rb2
-rw-r--r--spec/support/shared/unit/application_dot_d.rb6
-rw-r--r--spec/unit/chef_fs/path_util_spec.rb2
-rw-r--r--spec/unit/cookbook_spec.rb4
-rw-r--r--spec/unit/dsl/declare_resource_spec.rb2
-rw-r--r--spec/unit/file_access_control_spec.rb2
-rw-r--r--spec/unit/knife/bootstrap_spec.rb12
-rw-r--r--spec/unit/lwrp_spec.rb6
-rw-r--r--spec/unit/mixin/securable_spec.rb4
-rw-r--r--spec/unit/recipe_spec.rb2
-rwxr-xr-xtasks/bin/run_external_test2
-rwxr-xr-xtasks/docs.rb2
-rw-r--r--tasks/rspec.rb2
39 files changed, 54 insertions, 54 deletions
diff --git a/bin/knife b/bin/knife
index e93e47d1d4..85ac3b91e9 100755
--- a/bin/knife
+++ b/bin/knife
@@ -18,7 +18,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
+$:.unshift(File.expand_path(File.join(__dir__, "..", "lib")))
require "chef/application/knife"
Chef::Application::Knife.new.run
diff --git a/chef-bin/bin/chef-apply b/chef-bin/bin/chef-apply
index 05b975a118..92c350b85b 100755
--- a/chef-bin/bin/chef-apply
+++ b/chef-bin/bin/chef-apply
@@ -18,7 +18,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
+$:.unshift(File.join(__dir__, "..", "lib"))
require "chef/application/apply"
Chef::Application::Apply.new.run(enforce_license: true)
diff --git a/chef-bin/bin/chef-client b/chef-bin/bin/chef-client
index 45a6af546a..69436d4182 100755
--- a/chef-bin/bin/chef-client
+++ b/chef-bin/bin/chef-client
@@ -18,7 +18,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
+$:.unshift(File.join(__dir__, "..", "lib"))
require "chef"
require "chef/application/client"
diff --git a/chef-bin/bin/chef-resource-inspector b/chef-bin/bin/chef-resource-inspector
index 6a7eac0c32..90bd94e05d 100755
--- a/chef-bin/bin/chef-resource-inspector
+++ b/chef-bin/bin/chef-resource-inspector
@@ -19,7 +19,7 @@
Encoding.default_external = Encoding::UTF_8
-$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
+$:.unshift(File.expand_path(File.join(__dir__, "..", "lib")))
require "chef/resource_inspector"
diff --git a/chef-bin/bin/chef-service-manager b/chef-bin/bin/chef-service-manager
index 64cc043a54..2575e23dc0 100755
--- a/chef-bin/bin/chef-service-manager
+++ b/chef-bin/bin/chef-service-manager
@@ -18,7 +18,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
+$:.unshift(File.join(__dir__, "..", "lib"))
require "chef"
require "chef/application/windows_service_manager"
require "chef/dist"
diff --git a/chef-bin/bin/chef-shell b/chef-bin/bin/chef-shell
index 666ce1944c..48263dd7ea 100755
--- a/chef-bin/bin/chef-shell
+++ b/chef-bin/bin/chef-shell
@@ -24,7 +24,7 @@ require "irb"
require "irb/completion"
require "irb/ext/save-history"
-$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
+$:.unshift(File.expand_path(File.join(__dir__, "..", "lib")))
require "chef/shell"
diff --git a/chef-bin/bin/chef-solo b/chef-bin/bin/chef-solo
index 7a2168230d..379aa89485 100755
--- a/chef-bin/bin/chef-solo
+++ b/chef-bin/bin/chef-solo
@@ -18,7 +18,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
+$:.unshift(File.join(__dir__, "..", "lib"))
require "chef/application/solo"
Chef::Application::Solo.new.run(enforce_license: true)
diff --git a/chef-bin/bin/chef-windows-service b/chef-bin/bin/chef-windows-service
index 646e3b4a93..ce1a30baae 100755
--- a/chef-bin/bin/chef-windows-service
+++ b/chef-bin/bin/chef-windows-service
@@ -23,7 +23,7 @@
# generate will call that file, and will be registered as
# a windows service.
-$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
+$:.unshift(File.join(__dir__, "..", "lib"))
require "chef"
require "chef/application/windows_service"
diff --git a/chef.gemspec b/chef.gemspec
index 77140a6b15..1ff409c8d3 100644
--- a/chef.gemspec
+++ b/chef.gemspec
@@ -1,4 +1,4 @@
-$:.unshift(File.dirname(__FILE__) + "/lib")
+$:.unshift(__dir__ + "/lib")
require "chef/version"
Gem::Specification.new do |s|
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb
index d2e327f5fe..b78911e071 100644
--- a/lib/chef/knife/bootstrap.rb
+++ b/lib/chef/knife/bootstrap.rb
@@ -489,7 +489,7 @@ class Chef
# Otherwise search the template directories until we find the right one
bootstrap_files = []
- bootstrap_files << File.join(File.dirname(__FILE__), "bootstrap/templates", "#{template}.erb")
+ bootstrap_files << File.join(__dir__, "bootstrap/templates", "#{template}.erb")
bootstrap_files << File.join(Knife.chef_config_dir, "bootstrap", "#{template}.erb") if Chef::Knife.chef_config_dir
Chef::Util::PathHelper.home(".chef", "bootstrap", "#{template}.erb") { |p| bootstrap_files << p }
bootstrap_files << Gem.find_files(File.join("chef", "knife", "bootstrap", "#{template}.erb"))
diff --git a/omnibus/files/openssl-customization/windows/ssl_env_hack.rb b/omnibus/files/openssl-customization/windows/ssl_env_hack.rb
index b86c17db82..27ba267e36 100644
--- a/omnibus/files/openssl-customization/windows/ssl_env_hack.rb
+++ b/omnibus/files/openssl-customization/windows/ssl_env_hack.rb
@@ -22,7 +22,7 @@
# This is required to make Chef tools use https URLs out of the box.
unless ENV.key?("SSL_CERT_FILE")
- base_dirs = File.dirname(__FILE__).split(File::SEPARATOR)
+ base_dirs = __dir__.split(File::SEPARATOR)
(base_dirs.length - 1).downto(0) do |i|
candidate_ca_bundle = File.join(base_dirs[0..i] + [ "ssl/certs/cacert.pem" ])
diff --git a/omnibus_overrides.rb b/omnibus_overrides.rb
index 49009c8778..572f2a84e9 100644
--- a/omnibus_overrides.rb
+++ b/omnibus_overrides.rb
@@ -29,5 +29,5 @@ override "zlib", version: "1.2.11"
# is in master, which won't match what's in the Gemfile.lock and used by the chef
# definition. This pin will ensure that ohai and chef-client commands use the
# same (released) version of ohai.
-gemfile_lock = File.join(File.expand_path(File.dirname(__FILE__)), "Gemfile.lock")
+gemfile_lock = File.join(File.expand_path(__dir__), "Gemfile.lock")
override "ohai", version: "#{::File.readlines(gemfile_lock).find { |l| l =~ /^\s+ohai \((\d+\.\d+\.\d+)\)/ }; "v" + $1}" # rubocop: disable Layout/SpaceInsideStringInterpolation
diff --git a/spec/data/shef-config.rb b/spec/data/shef-config.rb
index 0e2521c5b4..1ace5efd21 100644
--- a/spec/data/shef-config.rb
+++ b/spec/data/shef-config.rb
@@ -7,5 +7,5 @@ ohai[:disabled_plugins] << "solaris2::cpu" << "solaris2::dmi" << "solaris2::file
ohai[:disabled_plugins] << "solaris2::virtualization" << "solaris2::zpools"
ohai[:disabled_plugins] << "c" << "php" << "mono" << "groovy" << "lua" << "erlang"
ohai[:disabled_plugins] << "kernel" << "linux::filesystem" << "ruby"
-chef_repo_path File.dirname(__FILE__)
+chef_repo_path __dir__
cookbook_path "#{chef_repo_path}/cookbooks"
diff --git a/spec/functional/resource/aix_service_spec.rb b/spec/functional/resource/aix_service_spec.rb
index ae29d54f2a..16d830b88a 100755
--- a/spec/functional/resource/aix_service_spec.rb
+++ b/spec/functional/resource/aix_service_spec.rb
@@ -89,7 +89,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
describe "When service is a subsystem" do
before(:all) do
- script_dir = File.join(File.dirname(__FILE__), "/../assets/")
+ script_dir = File.join(__dir__, "/../assets/")
shell_out!("mkssys -s ctestsys -p #{script_dir}/testchefsubsys -u #{get_user_id} -S -n 15 -f 9 -R -Q")
end
@@ -117,7 +117,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
# Cannot run this test on a WPAR
describe "When service is a group", :not_wpar do
before(:all) do
- script_dir = File.join(File.dirname(__FILE__), "/../assets/")
+ script_dir = File.join(__dir__, "/../assets/")
shell_out!("mkssys -s ctestsys -p #{script_dir}/testchefsubsys -u #{get_user_id} -S -n 15 -f 9 -R -Q -G ctestgrp")
end
diff --git a/spec/functional/resource/aixinit_service_spec.rb b/spec/functional/resource/aixinit_service_spec.rb
index ecbe0c23fa..c568d40a8d 100755
--- a/spec/functional/resource/aixinit_service_spec.rb
+++ b/spec/functional/resource/aixinit_service_spec.rb
@@ -69,7 +69,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
before(:all) do
File.delete("/etc/rc.d/init.d/chefinittest") if File.exist?("/etc/rc.d/init.d/chefinittest")
- FileUtils.cp((File.join(File.dirname(__FILE__), "/../assets/chefinittest")).to_s, "/etc/rc.d/init.d/chefinittest")
+ FileUtils.cp((File.join(__dir__, "/../assets/chefinittest")).to_s, "/etc/rc.d/init.d/chefinittest")
end
after(:all) do
diff --git a/spec/functional/resource/insserv_spec.rb b/spec/functional/resource/insserv_spec.rb
index 92275fffba..e5c74c68ac 100644
--- a/spec/functional/resource/insserv_spec.rb
+++ b/spec/functional/resource/insserv_spec.rb
@@ -74,7 +74,7 @@ describe Chef::Resource::Service, :requires_root, :opensuse do
before(:all) do
File.delete("/etc/init.d/inittest") if File.exist?("/etc/init.d/inittest")
- FileUtils.cp((File.join(File.dirname(__FILE__), "/../assets/inittest")).to_s, "/etc/init.d/inittest")
+ FileUtils.cp((File.join(__dir__, "/../assets/inittest")).to_s, "/etc/init.d/inittest")
FileUtils.chmod(0755, "/etc/init.d/inittest")
end
diff --git a/spec/functional/version_spec.rb b/spec/functional/version_spec.rb
index 935dabb205..294df7542c 100644
--- a/spec/functional/version_spec.rb
+++ b/spec/functional/version_spec.rb
@@ -23,7 +23,7 @@ require "chef/dist"
describe "Chef Versions", :executables do
include Chef::Mixin::ShellOut
- let(:chef_dir) { File.join(File.dirname(__FILE__), "..", "..") }
+ let(:chef_dir) { File.join(__dir__, "..", "..") }
binaries = [ Chef::Dist::CLIENT, "chef-shell", "chef-apply", "knife", Chef::Dist::SOLOEXEC ]
diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb
index 0b206623b1..a33f84610d 100644
--- a/spec/integration/client/client_spec.rb
+++ b/spec/integration/client/client_spec.rb
@@ -34,7 +34,7 @@ describe "chef-client" do
include IntegrationSupport
include Chef::Mixin::ShellOut
- let(:chef_dir) { File.join(File.dirname(__FILE__), "..", "..", "..", "bin") }
+ let(:chef_dir) { File.join(__dir__, "..", "..", "..", "bin") }
# Invoke `chef-client` as `ruby PATH/TO/chef-client`. This ensures the
# following constraints are satisfied:
diff --git a/spec/integration/client/exit_code_spec.rb b/spec/integration/client/exit_code_spec.rb
index a2f7e87b7e..c2f0c2fb45 100644
--- a/spec/integration/client/exit_code_spec.rb
+++ b/spec/integration/client/exit_code_spec.rb
@@ -11,7 +11,7 @@ describe "chef-client" do
include IntegrationSupport
include Chef::Mixin::ShellOut
- let(:chef_dir) { File.join(File.dirname(__FILE__), "..", "..", "..", "bin") }
+ let(:chef_dir) { File.join(__dir__, "..", "..", "..", "bin") }
# Invoke `chef-client` as `ruby PATH/TO/chef-client`. This ensures the
# following constraints are satisfied:
diff --git a/spec/integration/client/ipv6_spec.rb b/spec/integration/client/ipv6_spec.rb
index 30fd991c70..816e1c40e6 100644
--- a/spec/integration/client/ipv6_spec.rb
+++ b/spec/integration/client/ipv6_spec.rb
@@ -74,7 +74,7 @@ describe "chef-client" do
basic_config_file
end
- let(:chef_dir) { File.join(File.dirname(__FILE__), "..", "..", "..", "bin") }
+ let(:chef_dir) { File.join(__dir__, "..", "..", "..", "bin") }
let(:chef_client_cmd) { %Q{bundle exec chef-client --minimal-ohai -c "#{path_to("config/client.rb")}" -lwarn} }
diff --git a/spec/integration/knife/cookbook_api_ipv6_spec.rb b/spec/integration/knife/cookbook_api_ipv6_spec.rb
index 38aedb59db..b65cdc697b 100644
--- a/spec/integration/knife/cookbook_api_ipv6_spec.rb
+++ b/spec/integration/knife/cookbook_api_ipv6_spec.rb
@@ -62,7 +62,7 @@ describe "Knife cookbook API integration with IPv6", :workstation, :not_supporte
Dir.mktmpdir
end
- let(:chef_dir) { File.join(File.dirname(__FILE__), "..", "..", "..", "bin") }
+ let(:chef_dir) { File.join(__dir__, "..", "..", "..", "bin") }
let(:knife) { "ruby '#{chef_dir}/knife'" }
let(:knife_config_flag) { "-c '#{path_to("config/knife.rb")}'" }
diff --git a/spec/integration/recipes/remote_directory.rb b/spec/integration/recipes/remote_directory.rb
index 8332fb1b56..4d0bcd3514 100644
--- a/spec/integration/recipes/remote_directory.rb
+++ b/spec/integration/recipes/remote_directory.rb
@@ -5,7 +5,7 @@ describe Chef::Resource::RemoteDirectory do
include Chef::Mixin::ShellOut
# Until Cheffish::RSpec has cookbook support, we have to run the whole client
- let(:chef_dir) { File.join(File.dirname(__FILE__), "..", "..", "..", "bin") }
+ let(:chef_dir) { File.join(__dir__, "..", "..", "..", "bin") }
# Invoke `chef-client` as `ruby PATH/TO/chef-client`. This ensures the
# following constraints are satisfied:
diff --git a/spec/integration/solo/solo_spec.rb b/spec/integration/solo/solo_spec.rb
index 3029a1b529..75a13b57e4 100644
--- a/spec/integration/solo/solo_spec.rb
+++ b/spec/integration/solo/solo_spec.rb
@@ -12,7 +12,7 @@ describe Chef::Dist::SOLOEXEC do
include IntegrationSupport
include Chef::Mixin::ShellOut
- let(:chef_dir) { File.join(File.dirname(__FILE__), "..", "..", "..") }
+ let(:chef_dir) { File.join(__dir__, "..", "..", "..") }
let(:cookbook_x_100_metadata_rb) { cb_metadata("x", "1.0.0") }
@@ -183,7 +183,7 @@ describe Chef::Dist::SOLOEXEC do
# run_lock gets stuck we can discover it.
expect do
Timeout.timeout(120) do
- chef_dir = File.join(File.dirname(__FILE__), "..", "..", "..")
+ chef_dir = File.join(__dir__, "..", "..", "..")
threads = []
diff --git a/spec/stress/win32/file_spec.rb b/spec/stress/win32/file_spec.rb
index c911698029..274d574919 100644
--- a/spec/stress/win32/file_spec.rb
+++ b/spec/stress/win32/file_spec.rb
@@ -21,7 +21,7 @@ require "chef/win32/file" if windows?
describe "Chef::ReservedNames::Win32::File", :windows_only do
before(:each) do
- @path = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "data", "old_home_dir", "my-dot-emacs"))
+ @path = File.expand_path(File.join(__dir__, "..", "..", "data", "old_home_dir", "my-dot-emacs"))
end
it "should not leak significant memory", :volatile do
diff --git a/spec/support/chef_helpers.rb b/spec/support/chef_helpers.rb
index 810ebe56d7..6a0ca878cd 100644
--- a/spec/support/chef_helpers.rb
+++ b/spec/support/chef_helpers.rb
@@ -14,8 +14,8 @@
# limitations under the License.
#
-CHEF_SPEC_DATA = File.expand_path(File.dirname(__FILE__) + "/../data/")
-CHEF_SPEC_ASSETS = File.expand_path(File.dirname(__FILE__) + "/../functional/assets/")
+CHEF_SPEC_DATA = File.expand_path(__dir__ + "/../data/")
+CHEF_SPEC_ASSETS = File.expand_path(__dir__ + "/../functional/assets/")
CHEF_SPEC_BACKUP_PATH = File.join(Dir.tmpdir, "test-backup-path")
def sha256_checksum(path)
diff --git a/spec/support/matchers/leak.rb b/spec/support/matchers/leak.rb
index fd75039b4e..bd59a2755c 100644
--- a/spec/support/matchers/leak.rb
+++ b/spec/support/matchers/leak.rb
@@ -61,10 +61,10 @@ module Matchers
def profiler
@profiler ||= begin
if ChefUtils.windows?
- require File.join(File.dirname(__FILE__), "..", "platforms", "prof", "win32")
+ require File.join(__dir__, "..", "platforms", "prof", "win32")
RSpec::Prof::Win32::Profiler.new
else
- require File.join(File.dirname(__FILE__), "..", "prof", "gc")
+ require File.join(__dir__, "..", "prof", "gc")
RSpec::Prof::GC::Profiler.new
end
end
diff --git a/spec/support/shared/functional/win32_service.rb b/spec/support/shared/functional/win32_service.rb
index dfd66f74ad..890c28de2c 100644
--- a/spec/support/shared/functional/win32_service.rb
+++ b/spec/support/shared/functional/win32_service.rb
@@ -42,7 +42,7 @@ shared_context "using Win32::Service" do
service_name: "spec-service",
service_display_name: "Spec Test Service",
service_description: "Service for testing Chef::Application::WindowsServiceManager.",
- service_file_path: File.expand_path(File.join(File.dirname(__FILE__), "../../platforms/win32/spec_service.rb")),
+ service_file_path: File.expand_path(File.join(__dir__, "../../platforms/win32/spec_service.rb")),
delayed_start: true,
}
end
diff --git a/spec/support/shared/unit/application_dot_d.rb b/spec/support/shared/unit/application_dot_d.rb
index a9e6d46ad9..6d722e3734 100644
--- a/spec/support/shared/unit/application_dot_d.rb
+++ b/spec/support/shared/unit/application_dot_d.rb
@@ -33,7 +33,7 @@ shared_examples_for "an application that loads a dot d" do
# make sure that we are correctly globbing.
let(:client_d_dir) do
Chef::Util::PathHelper.cleanpath(
- File.join(File.dirname(__FILE__), "../../../data/client.d_00")
+ File.join(__dir__, "../../../data/client.d_00")
)
end
@@ -53,7 +53,7 @@ shared_examples_for "an application that loads a dot d" do
context "when client_d_dir is set to a directory without configuration" do
let(:client_d_dir) do
Chef::Util::PathHelper.cleanpath(
- File.join(File.dirname(__FILE__), "../../data/client.d_01")
+ File.join(__dir__, "../../data/client.d_01")
)
end
@@ -71,7 +71,7 @@ shared_examples_for "an application that loads a dot d" do
# foo.rb as a directory should be ignored
let(:client_d_dir) do
Chef::Util::PathHelper.cleanpath(
- File.join(File.dirname(__FILE__), "../../data/client.d_02")
+ File.join(__dir__, "../../data/client.d_02")
)
end
diff --git a/spec/unit/chef_fs/path_util_spec.rb b/spec/unit/chef_fs/path_util_spec.rb
index 694dabf5d7..4056c240cc 100644
--- a/spec/unit/chef_fs/path_util_spec.rb
+++ b/spec/unit/chef_fs/path_util_spec.rb
@@ -61,7 +61,7 @@ describe Chef::ChefFS::PathUtils do
end
context "invoking realest_path" do
- let(:good_path) { File.dirname(__FILE__) }
+ let(:good_path) { __dir__ }
let(:parent_path) { File.dirname(good_path) }
it "handles paths with no wildcards or globs" do
diff --git a/spec/unit/cookbook_spec.rb b/spec/unit/cookbook_spec.rb
index 85c31ab42b..04b729c127 100644
--- a/spec/unit/cookbook_spec.rb
+++ b/spec/unit/cookbook_spec.rb
@@ -19,10 +19,10 @@
require "spec_helper"
describe Chef::CookbookVersion do
- COOKBOOK_PATH = File.expand_path(File.join(File.dirname(__FILE__), "..", "data", "cookbooks", "openldap"))
+ COOKBOOK_PATH = File.expand_path(File.join(__dir__, "..", "data", "cookbooks", "openldap"))
before(:each) do
- @cookbook_repo = File.expand_path(File.join(File.dirname(__FILE__), "..", "data", "cookbooks"))
+ @cookbook_repo = File.expand_path(File.join(__dir__, "..", "data", "cookbooks"))
cl = Chef::CookbookLoader.new(@cookbook_repo)
cl.load_cookbooks
@cookbook_collection = Chef::CookbookCollection.new(cl)
diff --git a/spec/unit/dsl/declare_resource_spec.rb b/spec/unit/dsl/declare_resource_spec.rb
index 4fcdd4d048..53b0713c42 100644
--- a/spec/unit/dsl/declare_resource_spec.rb
+++ b/spec/unit/dsl/declare_resource_spec.rb
@@ -19,7 +19,7 @@ require "spec_helper"
describe Chef::ResourceCollection do
let(:run_context) do
- cookbook_repo = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "data", "cookbooks"))
+ cookbook_repo = File.expand_path(File.join(__dir__, "..", "..", "data", "cookbooks"))
cookbook_loader = Chef::CookbookLoader.new(cookbook_repo)
cookbook_loader.load_cookbooks
node = Chef::Node.new
diff --git a/spec/unit/file_access_control_spec.rb b/spec/unit/file_access_control_spec.rb
index 18983e6ff5..dfa0bcf673 100644
--- a/spec/unit/file_access_control_spec.rb
+++ b/spec/unit/file_access_control_spec.rb
@@ -26,7 +26,7 @@ describe Chef::FileAccessControl do
# we have to re-load the file so the proper
# platform specific module is mixed in
@node = Chef::Node.new
- load File.join(File.dirname(__FILE__), "..", "..", "lib", "chef", "file_access_control.rb")
+ load File.join(__dir__, "..", "..", "lib", "chef", "file_access_control.rb")
@resource = Chef::Resource::File.new("/tmp/a_file.txt")
@resource.owner("toor")
@resource.group("wheel")
diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb
index 130a097da2..15a51b7f92 100644
--- a/spec/unit/knife/bootstrap_spec.rb
+++ b/spec/unit/knife/bootstrap_spec.rb
@@ -185,7 +185,7 @@ describe Chef::Knife::Bootstrap do
context "when :bootstrap_template config is set to a template name" do
let(:bootstrap_template) { "example" }
- let(:builtin_template_path) { File.expand_path(File.join(File.dirname(__FILE__), "../../../lib/chef/knife/bootstrap/templates", "example.erb")) }
+ let(:builtin_template_path) { File.expand_path(File.join(__dir__, "../../../lib/chef/knife/bootstrap/templates", "example.erb")) }
let(:chef_config_dir_template_path) { "/knife/chef/config/bootstrap/example.erb" }
@@ -472,7 +472,7 @@ describe Chef::Knife::Bootstrap do
end
describe "when transferring trusted certificates" do
- let(:trusted_certs_dir) { Chef::Util::PathHelper.cleanpath(File.join(File.dirname(__FILE__), "../../data/trusted_certs")) }
+ let(:trusted_certs_dir) { Chef::Util::PathHelper.cleanpath(File.join(__dir__, "../../data/trusted_certs")) }
let(:rendered_template) do
knife.merge_configs
@@ -504,7 +504,7 @@ describe Chef::Knife::Bootstrap do
end
context "when :trusted_cets_dir is empty" do
- let(:trusted_certs_dir) { Chef::Util::PathHelper.cleanpath(File.join(File.dirname(__FILE__), "../../data/trusted_certs_empty")) }
+ let(:trusted_certs_dir) { Chef::Util::PathHelper.cleanpath(File.join(__dir__, "../../data/trusted_certs_empty")) }
it "doesn't create /etc/chef/trusted_certs if :trusted_certs_dir is empty" do
expect(rendered_template).not_to match(%r{mkdir -p /etc/chef/trusted_certs})
end
@@ -514,7 +514,7 @@ describe Chef::Knife::Bootstrap do
context "when doing fips things" do
let(:template_file) { File.expand_path(File.join(CHEF_SPEC_DATA, "bootstrap", "no_proxy.erb")) }
- let(:trusted_certs_dir) { Chef::Util::PathHelper.cleanpath(File.join(File.dirname(__FILE__), "../../data/trusted_certs")) }
+ let(:trusted_certs_dir) { Chef::Util::PathHelper.cleanpath(File.join(__dir__, "../../data/trusted_certs")) }
before do
Chef::Config[:knife][:bootstrap_template] = template_file
@@ -570,7 +570,7 @@ describe Chef::Knife::Bootstrap do
context "when client_d_dir is set" do
let(:client_d_dir) do
Chef::Util::PathHelper.cleanpath(
- File.join(File.dirname(__FILE__), "../../data/client.d_00")
+ File.join(__dir__, "../../data/client.d_00")
)
end
@@ -597,7 +597,7 @@ describe Chef::Knife::Bootstrap do
context "a nested directory structure" do
let(:client_d_dir) do
Chef::Util::PathHelper.cleanpath(
- File.join(File.dirname(__FILE__), "../../data/client.d_01")
+ File.join(__dir__, "../../data/client.d_01")
)
end
it "creates a file foo/bar.rb" do
diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb
index a933d23afe..ac2c95d7e7 100644
--- a/spec/unit/lwrp_spec.rb
+++ b/spec/unit/lwrp_spec.rb
@@ -169,7 +169,7 @@ describe "LWRP" do
describe "Lightweight Chef::Resource" do
before do
- Dir[File.expand_path(File.join(File.dirname(__FILE__), "..", "data", "lwrp", "resources", "*"))].each do |file|
+ Dir[File.expand_path(File.join(__dir__, "..", "data", "lwrp", "resources", "*"))].each do |file|
Chef::Resource::LWRPBase.build_from_file("lwrp", file, nil)
end
end
@@ -211,7 +211,7 @@ describe "LWRP" do
node.normal[:penguin_name] = "jackass"
run_context = Chef::RunContext.new(node, Chef::CookbookCollection.new, @events)
- Dir[File.expand_path(File.join(File.dirname(__FILE__), "..", "data", "lwrp", "resources_with_default_attributes", "*"))].each do |file|
+ Dir[File.expand_path(File.join(__dir__, "..", "data", "lwrp", "resources_with_default_attributes", "*"))].each do |file|
Chef::Resource::LWRPBase.build_from_file("lwrp", file, run_context)
end
@@ -654,7 +654,7 @@ describe "LWRP" do
end
let(:run_context) do
- cookbook_repo = File.expand_path(File.join(File.dirname(__FILE__), "..", "data", "cookbooks"))
+ cookbook_repo = File.expand_path(File.join(__dir__, "..", "data", "cookbooks"))
cookbook_loader = Chef::CookbookLoader.new(cookbook_repo)
cookbook_loader.load_cookbooks
cookbook_collection = Chef::CookbookCollection.new(cookbook_loader)
diff --git a/spec/unit/mixin/securable_spec.rb b/spec/unit/mixin/securable_spec.rb
index 4863693dba..bbbd6bab84 100644
--- a/spec/unit/mixin/securable_spec.rb
+++ b/spec/unit/mixin/securable_spec.rb
@@ -45,7 +45,7 @@ describe Chef::Mixin::Securable do
describe "unix-specific behavior" do
before(:each) do
platform_mock :unix do
- load File.join(File.dirname(__FILE__), "..", "..", "..", "lib", "chef", "mixin", "securable.rb")
+ load File.join(__dir__, "..", "..", "..", "lib", "chef", "mixin", "securable.rb")
@securable = Object.new
@securable.send(:extend, Chef::Mixin::Securable)
@securable.send(:extend, Chef::Mixin::ParamsValidate)
@@ -176,7 +176,7 @@ describe Chef::Mixin::Securable do
describe "windows-specific behavior" do
before(:each) do
platform_mock :windows do
- load File.join(File.dirname(__FILE__), "..", "..", "..", "lib", "chef", "mixin", "securable.rb")
+ load File.join(__dir__, "..", "..", "..", "lib", "chef", "mixin", "securable.rb")
securable_class = Class.new do
include Chef::Mixin::Securable
include Chef::Mixin::ParamsValidate
diff --git a/spec/unit/recipe_spec.rb b/spec/unit/recipe_spec.rb
index 9df46b46e2..ffa7025e3f 100644
--- a/spec/unit/recipe_spec.rb
+++ b/spec/unit/recipe_spec.rb
@@ -25,7 +25,7 @@ require "chef/platform/resource_priority_map"
describe Chef::Recipe do
let(:cookbook_collection) do
- cookbook_repo = File.expand_path(File.join(File.dirname(__FILE__), "..", "data", "cookbooks"))
+ cookbook_repo = File.expand_path(File.join(__dir__, "..", "data", "cookbooks"))
cookbook_loader = Chef::CookbookLoader.new(cookbook_repo)
cookbook_loader.load_cookbooks
Chef::CookbookCollection.new(cookbook_loader)
diff --git a/tasks/bin/run_external_test b/tasks/bin/run_external_test
index 16f21d8e37..e4d984e9ee 100755
--- a/tasks/bin/run_external_test
+++ b/tasks/bin/run_external_test
@@ -6,7 +6,7 @@
# of the chef / ohai repos. It let's us know if we need to update downstream
# gems or fix regressions in chef *before* we release.
-$:.unshift(File.expand_path("../../lib", File.dirname(__FILE__)))
+$:.unshift(File.expand_path("../../lib", __dir__))
require "tmpdir"
require "bundler"
diff --git a/tasks/docs.rb b/tasks/docs.rb
index 2327a928c7..586115f2f9 100755
--- a/tasks/docs.rb
+++ b/tasks/docs.rb
@@ -5,7 +5,7 @@ namespace :docs_site do
task :resources do
Encoding.default_external = Encoding::UTF_8
- $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "lib")))
+ $:.unshift(File.expand_path(File.join(__dir__, "lib")))
require "chef/resource_inspector"
require "fileutils"
diff --git a/tasks/rspec.rb b/tasks/rspec.rb
index 647efd647a..a10479f3ed 100644
--- a/tasks/rspec.rb
+++ b/tasks/rspec.rb
@@ -20,7 +20,7 @@
require "rubygems"
require "rake"
-CHEF_ROOT = File.join(File.dirname(__FILE__), "..")
+CHEF_ROOT = File.join(__dir__, "..")
begin
require "rspec/core/rake_task"