summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2020-08-14 10:15:40 -0700
committerGitHub <noreply@github.com>2020-08-14 10:15:40 -0700
commitc0c8c32e41a4496d3b78acc942f26f667045b3f8 (patch)
treee1ba9028cb89f0fc83fcbecb5ed778ac4ad6f630 /spec
parentb9df6856a1eb4688f013ba0449a362f951ab40e5 (diff)
parent4848c89b7cc5e4a4d4fac7c8bff962f7df69f719 (diff)
downloadchef-c0c8c32e41a4496d3b78acc942f26f667045b3f8.tar.gz
Merge pull request #10284 from chef/exist
Fix File.exist throughout the codebase
Diffstat (limited to 'spec')
-rwxr-xr-xspec/functional/resource/aixinit_service_spec.rb14
-rw-r--r--spec/functional/resource/bff_spec.rb4
-rw-r--r--spec/functional/resource/cookbook_file_spec.rb2
-rw-r--r--spec/functional/resource/dsc_resource_spec.rb2
-rw-r--r--spec/functional/resource/insserv_spec.rb8
-rw-r--r--spec/functional/resource/link_spec.rb24
-rw-r--r--spec/functional/resource/rpm_spec.rb4
-rw-r--r--spec/functional/resource/windows_certificate_spec.rb6
-rw-r--r--spec/functional/win32/service_manager_spec.rb2
-rw-r--r--spec/integration/recipes/lwrp_inline_resources_spec.rb2
-rw-r--r--spec/spec_helper.rb2
-rw-r--r--spec/support/platform_helpers.rb6
-rw-r--r--spec/support/platforms/win32/spec_service.rb2
-rw-r--r--spec/support/shared/functional/directory_resource.rb2
-rw-r--r--spec/support/shared/functional/execute_resource.rb2
-rw-r--r--spec/support/shared/functional/file_resource.rb4
-rw-r--r--spec/support/shared/functional/win32_service.rb2
-rw-r--r--spec/support/shared/functional/windows_script.rb6
-rw-r--r--spec/unit/environment_spec.rb14
-rw-r--r--spec/unit/knife/bootstrap_spec.rb28
-rw-r--r--spec/unit/knife/cookbook_download_spec.rb8
-rw-r--r--spec/unit/knife/cookbook_metadata_from_file_spec.rb2
-rw-r--r--spec/unit/knife/core/hashed_command_loader_spec.rb6
-rw-r--r--spec/unit/knife/supermarket_share_spec.rb2
-rw-r--r--spec/unit/provider/service/arch_service_spec.rb5
-rw-r--r--spec/unit/provider/service/debian_service_spec.rb2
-rw-r--r--spec/unit/provider/service/gentoo_service_spec.rb14
-rw-r--r--spec/unit/provider/service/macosx_spec.rb6
-rw-r--r--spec/unit/provider/service/redhat_spec.rb4
-rw-r--r--spec/unit/provider/service/upstart_service_spec.rb6
-rw-r--r--spec/unit/role_spec.rb22
31 files changed, 107 insertions, 106 deletions
diff --git a/spec/functional/resource/aixinit_service_spec.rb b/spec/functional/resource/aixinit_service_spec.rb
index 6d1df895bf..ecbe0c23fa 100755
--- a/spec/functional/resource/aixinit_service_spec.rb
+++ b/spec/functional/resource/aixinit_service_spec.rb
@@ -27,11 +27,11 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
# Platform specific validation routines.
def service_should_be_started(file_name)
# The existence of this file indicates that the service was started.
- expect(File.exists?("#{Dir.tmpdir}/#{file_name}")).to be_truthy
+ expect(File.exist?("#{Dir.tmpdir}/#{file_name}")).to be_truthy
end
def service_should_be_stopped(file_name)
- expect(File.exists?("#{Dir.tmpdir}/#{file_name}")).to be_falsey
+ expect(File.exist?("#{Dir.tmpdir}/#{file_name}")).to be_falsey
end
def valide_symlinks(expected_output, run_level = nil, status = nil, priority = nil)
@@ -68,12 +68,12 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
end
before(:all) do
- File.delete("/etc/rc.d/init.d/chefinittest") if File.exists?("/etc/rc.d/init.d/chefinittest")
+ 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")
end
after(:all) do
- File.delete("/etc/rc.d/init.d/chefinittest") if File.exists?("/etc/rc.d/init.d/chefinittest")
+ File.delete("/etc/rc.d/init.d/chefinittest") if File.exist?("/etc/rc.d/init.d/chefinittest")
end
before(:each) do
@@ -165,7 +165,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
end
after do
- File.delete("/etc/rc.d/rc2.d/Schefinittest") if File.exists?("/etc/rc.d/rc2.d/chefinittest")
+ File.delete("/etc/rc.d/rc2.d/Schefinittest") if File.exist?("/etc/rc.d/rc2.d/chefinittest")
end
it "creates symlink with status K" do
@@ -181,7 +181,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
end
after do
- File.delete("/etc/rc.d/rc2.d/Schefinittest") if File.exists?("/etc/rc.d/rc2.d/chefinittest")
+ File.delete("/etc/rc.d/rc2.d/Schefinittest") if File.exist?("/etc/rc.d/rc2.d/chefinittest")
end
it "creates a symlink with status K and a priority" do
@@ -198,7 +198,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
end
after do
- File.delete("/etc/rc.d/rc2.d/Schefinittest") if File.exists?("/etc/rc.d/rc2.d/chefinittest")
+ File.delete("/etc/rc.d/rc2.d/Schefinittest") if File.exist?("/etc/rc.d/rc2.d/chefinittest")
end
it "create symlink with status stop (K) and a priority " do
diff --git a/spec/functional/resource/bff_spec.rb b/spec/functional/resource/bff_spec.rb
index ad45552c16..cdcc086180 100644
--- a/spec/functional/resource/bff_spec.rb
+++ b/spec/functional/resource/bff_spec.rb
@@ -31,12 +31,12 @@ describe Chef::Resource::BffPackage, :requires_root, external: ohai[:platform] !
def bff_pkg_should_be_installed(resource)
expect(shell_out("lslpp -L #{resource.name}").exitstatus).to eq(0)
- ::File.exists?("/usr/PkgA/bin/acommand")
+ ::File.exist?("/usr/PkgA/bin/acommand")
end
def bff_pkg_should_be_removed(resource)
expect(shell_out("lslpp -L #{resource.name}").exitstatus).to eq(1)
- !::File.exists?("/usr/PkgA/bin/acommand")
+ !::File.exist?("/usr/PkgA/bin/acommand")
end
before(:all) do
diff --git a/spec/functional/resource/cookbook_file_spec.rb b/spec/functional/resource/cookbook_file_spec.rb
index 9d6600d554..8dbf22d611 100644
--- a/spec/functional/resource/cookbook_file_spec.rb
+++ b/spec/functional/resource/cookbook_file_spec.rb
@@ -72,7 +72,7 @@ describe Chef::Resource::CookbookFile do
end
after do
- FileUtils.rm_r(windows_non_temp_dir) if ChefUtils.windows? && File.exists?(windows_non_temp_dir)
+ FileUtils.rm_r(windows_non_temp_dir) if ChefUtils.windows? && File.exist?(windows_non_temp_dir)
end
end
diff --git a/spec/functional/resource/dsc_resource_spec.rb b/spec/functional/resource/dsc_resource_spec.rb
index 1c7a73693b..227811a5ef 100644
--- a/spec/functional/resource/dsc_resource_spec.rb
+++ b/spec/functional/resource/dsc_resource_spec.rb
@@ -62,7 +62,7 @@ describe Chef::Resource::DscResource, :windows_powershell_dsc_only do
end
after do
- File.delete(tmp_file_name) if File.exists? tmp_file_name
+ File.delete(tmp_file_name) if File.exist? tmp_file_name
end
it "converges the resource if it is not converged" do
diff --git a/spec/functional/resource/insserv_spec.rb b/spec/functional/resource/insserv_spec.rb
index bd3b98a1e2..92275fffba 100644
--- a/spec/functional/resource/insserv_spec.rb
+++ b/spec/functional/resource/insserv_spec.rb
@@ -38,11 +38,11 @@ describe Chef::Resource::Service, :requires_root, :opensuse do
# Platform specific validation routines.
def service_should_be_started(file_name)
# The existence of this file indicates that the service was started.
- expect(File.exists?("#{Dir.tmpdir}/#{file_name}")).to be_truthy
+ expect(File.exist?("#{Dir.tmpdir}/#{file_name}")).to be_truthy
end
def service_should_be_stopped(file_name)
- expect(File.exists?("#{Dir.tmpdir}/#{file_name}")).to be_falsey
+ expect(File.exist?("#{Dir.tmpdir}/#{file_name}")).to be_falsey
end
def delete_test_files
@@ -73,13 +73,13 @@ describe Chef::Resource::Service, :requires_root, :opensuse do
end
before(:all) do
- File.delete("/etc/init.d/inittest") if File.exists?("/etc/init.d/inittest")
+ 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.chmod(0755, "/etc/init.d/inittest")
end
after(:all) do
- File.delete("/etc/init.d/inittest") if File.exists?("/etc/init.d/inittest")
+ File.delete("/etc/init.d/inittest") if File.exist?("/etc/init.d/inittest")
end
before(:each) do
diff --git a/spec/functional/resource/link_spec.rb b/spec/functional/resource/link_spec.rb
index 22bc6e6121..3c8e90a6b2 100644
--- a/spec/functional/resource/link_spec.rb
+++ b/spec/functional/resource/link_spec.rb
@@ -56,9 +56,9 @@ describe Chef::Resource::Link do
after(:each) do
- cleanup_link(to) if File.exists?(to)
- cleanup_link(target_file) if File.exists?(target_file)
- cleanup_link(CHEF_SPEC_BACKUP_PATH) if File.exists?(CHEF_SPEC_BACKUP_PATH)
+ cleanup_link(to) if File.exist?(to)
+ cleanup_link(target_file) if File.exist?(target_file)
+ cleanup_link(CHEF_SPEC_BACKUP_PATH) if File.exist?(CHEF_SPEC_BACKUP_PATH)
rescue
puts "Could not remove a file: #{$!}"
@@ -273,7 +273,7 @@ describe Chef::Resource::Link do
resource.run_action(:create)
end
it "preserves the hard link" do
- expect(File.exists?(target_file)).to be_truthy
+ expect(File.exist?(target_file)).to be_truthy
expect(symlink?(target_file)).to be_falsey
# Writing to one hardlinked file should cause both
# to have the new value.
@@ -298,7 +298,7 @@ describe Chef::Resource::Link do
resource.run_action(:create)
end
it "links to the target file" do
- expect(File.exists?(target_file)).to be_truthy
+ expect(File.exist?(target_file)).to be_truthy
expect(symlink?(target_file)).to be_falsey
# Writing to one hardlinked file should cause both
# to have the new value.
@@ -338,7 +338,7 @@ describe Chef::Resource::Link do
include_context "delete succeeds"
it "the :delete action does not delete the target file" do
resource.run_action(:delete)
- expect(File.exists?(to)).to be_truthy
+ expect(File.exist?(to)).to be_truthy
end
end
context "pointing somewhere else", :requires_root_or_running_windows do
@@ -366,7 +366,7 @@ describe Chef::Resource::Link do
include_context "delete succeeds"
it "the :delete action does not delete the target file" do
resource.run_action(:delete)
- expect(File.exists?(to)).to be_truthy
+ expect(File.exist?(to)).to be_truthy
end
end
context "pointing nowhere" do
@@ -383,7 +383,7 @@ describe Chef::Resource::Link do
context "and the link already exists and is a hard link to the file" do
before(:each) do
link(to, target_file)
- expect(File.exists?(target_file)).to be_truthy
+ expect(File.exist?(target_file)).to be_truthy
expect(symlink?(target_file)).to be_falsey
end
include_context "create symbolic link succeeds"
@@ -582,14 +582,14 @@ describe Chef::Resource::Link do
context "and the link already exists and is a hard link to the file" do
before(:each) do
link(to, target_file)
- expect(File.exists?(target_file)).to be_truthy
+ expect(File.exist?(target_file)).to be_truthy
expect(symlink?(target_file)).to be_falsey
end
include_context "create hard link is noop"
include_context "delete succeeds"
it "the :delete action does not delete the target file" do
resource.run_action(:delete)
- expect(File.exists?(to)).to be_truthy
+ expect(File.exist?(to)).to be_truthy
end
end
context "and the link already exists and is a file" do
@@ -655,7 +655,7 @@ describe Chef::Resource::Link do
it "links to the target file" do
skip("macOS/FreeBSD/AIX/Solaris symlink? and readlink working on hard links to symlinks") if os_x? || freebsd? || aix? || solaris?
resource.run_action(:create)
- expect(File.exists?(target_file)).to be_truthy
+ expect(File.exist?(target_file)).to be_truthy
# macOS gets angry about this sort of link. Bug in macOS, IMO.
expect(symlink?(target_file)).to be_truthy
expect(readlink(target_file)).to eq(canonicalize(@other_target))
@@ -674,7 +674,7 @@ describe Chef::Resource::Link do
it "links to the target file" do
skip("macOS/FreeBSD/AIX/Solaris fails to create hardlinks to broken symlinks") if os_x? || freebsd? || aix? || solaris?
resource.run_action(:create)
- expect(File.exists?(target_file) || File.symlink?(target_file)).to be_truthy
+ expect(File.exist?(target_file) || File.symlink?(target_file)).to be_truthy
expect(symlink?(target_file)).to be_truthy
expect(readlink(target_file)).to eq(canonicalize(@other_target))
end
diff --git a/spec/functional/resource/rpm_spec.rb b/spec/functional/resource/rpm_spec.rb
index 8a6cf32882..15b6731357 100644
--- a/spec/functional/resource/rpm_spec.rb
+++ b/spec/functional/resource/rpm_spec.rb
@@ -39,7 +39,7 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
# mytest rpm package works in centos, redhat and in suse without any dependency issues.
else
expect(shell_out("rpm -qa | grep mytest").exitstatus).to eq(0)
- ::File.exists?("/opt/mytest/mytest.sh") # The mytest rpm package contains the mytest.sh file
+ ::File.exist?("/opt/mytest/mytest.sh") # The mytest rpm package contains the mytest.sh file
end
end
@@ -48,7 +48,7 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
expect(shell_out("rpm -qa | grep dummy").exitstatus).to eq(1)
else
expect(shell_out("rpm -qa | grep mytest").exitstatus).to eq(1)
- !::File.exists?("/opt/mytest/mytest.sh")
+ !::File.exist?("/opt/mytest/mytest.sh")
end
end
diff --git a/spec/functional/resource/windows_certificate_spec.rb b/spec/functional/resource/windows_certificate_spec.rb
index f64d9e1b62..9c996fe1f8 100644
--- a/spec/functional/resource/windows_certificate_spec.rb
+++ b/spec/functional/resource/windows_certificate_spec.rb
@@ -390,7 +390,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
end
after do
- if File.exists?(out_path)
+ if File.exist?(out_path)
File.delete(out_path)
end
end
@@ -405,7 +405,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
expect(no_of_certificates).to eq(1)
end
it "Stores Certificate content at given path" do
- expect(File.exists?(out_path)).to be_truthy
+ expect(File.exist?(out_path)).to be_truthy
end
it "Does not converge while fetching" do
expect(win_certificate).not_to be_updated_by_last_action
@@ -425,7 +425,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
expect(stdout.string.strip).to be_empty
end
it "Does not store certificate content at given path" do
- expect(File.exists?(out_path)).to be_falsy
+ expect(File.exist?(out_path)).to be_falsy
end
it "Does not converge while fetching" do
expect(win_certificate).not_to be_updated_by_last_action
diff --git a/spec/functional/win32/service_manager_spec.rb b/spec/functional/win32/service_manager_spec.rb
index 4847ce0482..5746283b78 100644
--- a/spec/functional/win32/service_manager_spec.rb
+++ b/spec/functional/win32/service_manager_spec.rb
@@ -125,7 +125,7 @@ describe "Chef::Application::WindowsServiceManager", :windows_only, :system_wind
it "start should start the service", :volatile do
service_manager.run(["-a", "start"])
expect(test_service_state).to eq("running")
- expect(File.exists?(test_service_file)).to be_truthy
+ expect(File.exist?(test_service_file)).to be_truthy
end
it "stop should not affect the service" do
diff --git a/spec/integration/recipes/lwrp_inline_resources_spec.rb b/spec/integration/recipes/lwrp_inline_resources_spec.rb
index dff2c886be..48f7952af0 100644
--- a/spec/integration/recipes/lwrp_inline_resources_spec.rb
+++ b/spec/integration/recipes/lwrp_inline_resources_spec.rb
@@ -59,7 +59,7 @@ describe "LWRPs with inline resources" do
end
end
- after { File.delete(LwrpShadowedPropertyTest::PATH) if File.exists?(LwrpShadowedPropertyTest::PATH) }
+ after { File.delete(LwrpShadowedPropertyTest::PATH) if File.exist?(LwrpShadowedPropertyTest::PATH) }
# https://github.com/chef/chef/issues/4334
it "does not warn spuriously" do
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 6dcd4b0551..165f87327c 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -68,7 +68,7 @@ end
# If you want to load anything into the testing environment
# without versioning it, add it to spec/support/local_gems.rb
-require "spec/support/local_gems.rb" if File.exists?(File.join(File.dirname(__FILE__), "support", "local_gems.rb"))
+require "spec/support/local_gems.rb" if File.exist?(File.join(File.dirname(__FILE__), "support", "local_gems.rb"))
# Explicitly require spec helpers that need to load first
require "spec/support/platform_helpers"
diff --git a/spec/support/platform_helpers.rb b/spec/support/platform_helpers.rb
index 05839d40ea..8d21c5cbd2 100644
--- a/spec/support/platform_helpers.rb
+++ b/spec/support/platform_helpers.rb
@@ -105,7 +105,7 @@ def mac_osx_1014?
end
def mac_osx?
- if File.exists? "/usr/bin/sw_vers"
+ if File.exist? "/usr/bin/sw_vers"
result = ShellHelpers.shell_out("/usr/bin/sw_vers")
result.stdout.each_line do |line|
if /^ProductName:\sMac OS X.*$/.match?(line)
@@ -216,8 +216,8 @@ def selinux_enabled?
end
def suse?
- ::File.exists?("/etc/SuSE-release") ||
- ( ::File.exists?("/etc/os-release") && /sles|suse/.match?(File.read("/etc/os-release")) )
+ ::File.exist?("/etc/SuSE-release") ||
+ ( ::File.exist?("/etc/os-release") && /sles|suse/.match?(File.read("/etc/os-release")) )
end
def root?
diff --git a/spec/support/platforms/win32/spec_service.rb b/spec/support/platforms/win32/spec_service.rb
index 34bb1fe3db..27f71a8bf0 100644
--- a/spec/support/platforms/win32/spec_service.rb
+++ b/spec/support/platforms/win32/spec_service.rb
@@ -26,7 +26,7 @@ if RUBY_PLATFORM.match?(/mswin|mingw|windows/)
def service_main(*startup_parameters)
while running?
- unless File.exists?(@test_service_file)
+ unless File.exist?(@test_service_file)
File.open(@test_service_file, "wb") do |f|
f.write("This file is created by SpecService")
end
diff --git a/spec/support/shared/functional/directory_resource.rb b/spec/support/shared/functional/directory_resource.rb
index 62055ca07d..cd05280aa8 100644
--- a/spec/support/shared/functional/directory_resource.rb
+++ b/spec/support/shared/functional/directory_resource.rb
@@ -173,6 +173,6 @@ shared_context Chef::Resource::Directory do
end
after(:each) do
- FileUtils.rm_r(path) if File.exists?(path)
+ FileUtils.rm_r(path) if File.exist?(path)
end
end
diff --git a/spec/support/shared/functional/execute_resource.rb b/spec/support/shared/functional/execute_resource.rb
index 5e0c9e4e28..9d1c29dfac 100644
--- a/spec/support/shared/functional/execute_resource.rb
+++ b/spec/support/shared/functional/execute_resource.rb
@@ -62,7 +62,7 @@ shared_context "a command that can be executed as an alternate user" do
end
after do
- File.delete(script_output_path) if File.exists?(script_output_path)
+ File.delete(script_output_path) if File.exist?(script_output_path)
Dir.rmdir(script_output_dir) if Dir.exist?(script_output_dir)
end
end
diff --git a/spec/support/shared/functional/file_resource.rb b/spec/support/shared/functional/file_resource.rb
index 77e823a682..1385d3dc30 100644
--- a/spec/support/shared/functional/file_resource.rb
+++ b/spec/support/shared/functional/file_resource.rb
@@ -1037,8 +1037,8 @@ shared_context Chef::Resource::File do
end
after(:each) do
- FileUtils.rm_r(path) if File.exists?(path)
- FileUtils.rm_r(CHEF_SPEC_BACKUP_PATH) if File.exists?(CHEF_SPEC_BACKUP_PATH)
+ FileUtils.rm_r(path) if File.exist?(path)
+ FileUtils.rm_r(CHEF_SPEC_BACKUP_PATH) if File.exist?(CHEF_SPEC_BACKUP_PATH)
end
after do
diff --git a/spec/support/shared/functional/win32_service.rb b/spec/support/shared/functional/win32_service.rb
index 2d14c6cf86..dfd66f74ad 100644
--- a/spec/support/shared/functional/win32_service.rb
+++ b/spec/support/shared/functional/win32_service.rb
@@ -30,7 +30,7 @@ shared_context "using Win32::Service" do
end
# Delete the test_service_file if it exists
- if File.exists?(test_service_file)
+ if File.exist?(test_service_file)
File.delete(test_service_file)
end
end
diff --git a/spec/support/shared/functional/windows_script.rb b/spec/support/shared/functional/windows_script.rb
index 3ccb7b6e37..151ad2387c 100644
--- a/spec/support/shared/functional/windows_script.rb
+++ b/spec/support/shared/functional/windows_script.rb
@@ -39,11 +39,11 @@ shared_context Chef::Resource::WindowsScript do
end
before(:each) do
- File.delete(script_output_path) if File.exists?(script_output_path)
+ File.delete(script_output_path) if File.exist?(script_output_path)
end
after(:each) do
- File.delete(script_output_path) if File.exists?(script_output_path)
+ File.delete(script_output_path) if File.exist?(script_output_path)
end
shared_examples_for "a script resource with architecture attribute" do
@@ -138,7 +138,7 @@ shared_context Chef::Resource::WindowsScript do
after do
script_file.close! if script_file
- ::File.delete(script_file.to_path) if script_file && ::File.exists?(script_file.to_path)
+ ::File.delete(script_file.to_path) if script_file && ::File.exist?(script_file.to_path)
end
include_context "alternate user identity"
diff --git a/spec/unit/environment_spec.rb b/spec/unit/environment_spec.rb
index 93b4a5011c..33553aed35 100644
--- a/spec/unit/environment_spec.rb
+++ b/spec/unit/environment_spec.rb
@@ -402,8 +402,8 @@ describe Chef::Environment do
it "should get the environment from the environment_path" do
expect(File).to receive(:directory?).with(Chef::Config[:environment_path]).and_return(true)
- expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(false)
- expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], "foo.rb")).exactly(1).times.and_return(true)
+ expect(File).to receive(:exist?).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(false)
+ expect(File).to receive(:exist?).with(File.join(Chef::Config[:environment_path], "foo.rb")).exactly(1).times.and_return(true)
expect(File).to receive(:readable?).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(true)
expect(File).to receive(:file?).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(true)
role_dsl = "name \"foo\"\ndescription \"desc\"\n"
@@ -413,7 +413,7 @@ describe Chef::Environment do
it "should return a Chef::Environment object from JSON" do
expect(File).to receive(:directory?).with(Chef::Config[:environment_path]).and_return(true)
- expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(true)
+ expect(File).to receive(:exist?).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(true)
environment_hash = {
"name" => "foo",
"default_attributes" => {
@@ -436,8 +436,8 @@ describe Chef::Environment do
it "should return a Chef::Environment object from Ruby DSL" do
expect(File).to receive(:directory?).with(Chef::Config[:environment_path]).and_return(true)
- expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(false)
- expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], "foo.rb")).exactly(1).times.and_return(true)
+ expect(File).to receive(:exist?).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(false)
+ expect(File).to receive(:exist?).with(File.join(Chef::Config[:environment_path], "foo.rb")).exactly(1).times.and_return(true)
expect(File).to receive(:readable?).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(true)
expect(File).to receive(:file?).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(true)
role_dsl = "name \"foo\"\ndescription \"desc\"\n"
@@ -463,8 +463,8 @@ describe Chef::Environment do
it "should raise an error if the file does not exist" do
expect(File).to receive(:directory?).with(Chef::Config[:environment_path]).and_return(true)
- expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(false)
- expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(false)
+ expect(File).to receive(:exist?).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(false)
+ expect(File).to receive(:exist?).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(false)
expect do
Chef::Environment.load("foo")
diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb
index e0694f047b..130a097da2 100644
--- a/spec/unit/knife/bootstrap_spec.rb
+++ b/spec/unit/knife/bootstrap_spec.rb
@@ -206,7 +206,7 @@ describe Chef::Knife::Bootstrap do
end
before(:each) do
- expect(File).to receive(:exists?).with(bootstrap_template).and_return(false)
+ expect(File).to receive(:exist?).with(bootstrap_template).and_return(false)
end
context "when file is available everywhere" do
@@ -215,7 +215,7 @@ describe Chef::Knife::Bootstrap do
configure_env_home
configure_gem_files
- expect(File).to receive(:exists?).with(builtin_template_path).and_return(true)
+ expect(File).to receive(:exist?).with(builtin_template_path).and_return(true)
end
it "should load the template from built-in templates" do
@@ -229,8 +229,8 @@ describe Chef::Knife::Bootstrap do
configure_env_home
configure_gem_files
- expect(File).to receive(:exists?).with(builtin_template_path).and_return(false)
- expect(File).to receive(:exists?).with(chef_config_dir_template_path).and_return(true)
+ expect(File).to receive(:exist?).with(builtin_template_path).and_return(false)
+ expect(File).to receive(:exist?).with(chef_config_dir_template_path).and_return(true)
it "should load the template from chef_config_dir" do
knife.find_template.should eq(chef_config_dir_template_path)
@@ -244,9 +244,9 @@ describe Chef::Knife::Bootstrap do
configure_env_home
configure_gem_files
- expect(File).to receive(:exists?).with(builtin_template_path).and_return(false)
- expect(File).to receive(:exists?).with(chef_config_dir_template_path).and_return(false)
- expect(File).to receive(:exists?).with(env_home_template_path).and_return(true)
+ expect(File).to receive(:exist?).with(builtin_template_path).and_return(false)
+ expect(File).to receive(:exist?).with(chef_config_dir_template_path).and_return(false)
+ expect(File).to receive(:exist?).with(env_home_template_path).and_return(true)
end
it "should load the template from chef_config_dir" do
@@ -260,10 +260,10 @@ describe Chef::Knife::Bootstrap do
configure_env_home
configure_gem_files
- expect(File).to receive(:exists?).with(builtin_template_path).and_return(false)
- expect(File).to receive(:exists?).with(chef_config_dir_template_path).and_return(false)
- expect(File).to receive(:exists?).with(env_home_template_path).and_return(false)
- expect(File).to receive(:exists?).with(gem_files_template_path).and_return(true)
+ expect(File).to receive(:exist?).with(builtin_template_path).and_return(false)
+ expect(File).to receive(:exist?).with(chef_config_dir_template_path).and_return(false)
+ expect(File).to receive(:exist?).with(env_home_template_path).and_return(false)
+ expect(File).to receive(:exist?).with(gem_files_template_path).and_return(true)
end
it "should load the template from Gem files" do
@@ -277,9 +277,9 @@ describe Chef::Knife::Bootstrap do
configure_gem_files
allow(Chef::Util::PathHelper).to receive(:home).with(".chef", "bootstrap", "example.erb").and_return(nil)
- expect(File).to receive(:exists?).with(builtin_template_path).and_return(false)
- expect(File).to receive(:exists?).with(chef_config_dir_template_path).and_return(false)
- expect(File).to receive(:exists?).with(gem_files_template_path).and_return(true)
+ expect(File).to receive(:exist?).with(builtin_template_path).and_return(false)
+ expect(File).to receive(:exist?).with(chef_config_dir_template_path).and_return(false)
+ expect(File).to receive(:exist?).with(gem_files_template_path).and_return(true)
end
it "should load the template from Gem files" do
diff --git a/spec/unit/knife/cookbook_download_spec.rb b/spec/unit/knife/cookbook_download_spec.rb
index 2d1d70cb51..62b6e58c75 100644
--- a/spec/unit/knife/cookbook_download_spec.rb
+++ b/spec/unit/knife/cookbook_download_spec.rb
@@ -94,7 +94,7 @@ describe Chef::Knife::CookbookDownload do
let(:manifest_data) { { all_files: [] } }
it "should determine which version to download" do
expect(@knife).to receive(:determine_version).and_return("1.0.0")
- expect(File).to receive(:exists?).with("/var/tmp/chef/foobar-1.0.0").and_return(false)
+ expect(File).to receive(:exist?).with("/var/tmp/chef/foobar-1.0.0").and_return(false)
@knife.run
end
end
@@ -111,7 +111,7 @@ describe Chef::Knife::CookbookDownload do
end
it "should print an error and exit if the cookbook download directory already exists" do
- expect(File).to receive(:exists?).with("/var/tmp/chef/foobar-1.0.0").and_return(true)
+ expect(File).to receive(:exist?).with("/var/tmp/chef/foobar-1.0.0").and_return(true)
expect(@knife.ui).to receive(:fatal).with(%r{/var/tmp/chef/foobar-1\.0\.0 exists}i)
expect { @knife.run }.to raise_error(SystemExit)
end
@@ -135,7 +135,7 @@ describe Chef::Knife::CookbookDownload do
end
it "should download the cookbook when the cookbook download directory doesn't exist" do
- expect(File).to receive(:exists?).with("/var/tmp/chef/foobar-1.0.0").and_return(false)
+ expect(File).to receive(:exist?).with("/var/tmp/chef/foobar-1.0.0").and_return(false)
@knife.run
%w{attributes recipes templates}.each do |segment|
expect(@stderr.string).to match /downloading #{segment}/im
@@ -147,7 +147,7 @@ describe Chef::Knife::CookbookDownload do
describe "with -f or --force" do
it "should remove the existing the cookbook download directory if it exists" do
@knife.config[:force] = true
- expect(File).to receive(:exists?).with("/var/tmp/chef/foobar-1.0.0").and_return(true)
+ expect(File).to receive(:exist?).with("/var/tmp/chef/foobar-1.0.0").and_return(true)
expect(FileUtils).to receive(:rm_rf).with("/var/tmp/chef/foobar-1.0.0")
@knife.run
end
diff --git a/spec/unit/knife/cookbook_metadata_from_file_spec.rb b/spec/unit/knife/cookbook_metadata_from_file_spec.rb
index e6b5e65621..f9bbffae2d 100644
--- a/spec/unit/knife/cookbook_metadata_from_file_spec.rb
+++ b/spec/unit/knife/cookbook_metadata_from_file_spec.rb
@@ -34,7 +34,7 @@ describe Chef::Knife::CookbookMetadataFromFile do
end
after do
- if File.exists?(@tgt)
+ if File.exist?(@tgt)
File.unlink(@tgt)
end
end
diff --git a/spec/unit/knife/core/hashed_command_loader_spec.rb b/spec/unit/knife/core/hashed_command_loader_spec.rb
index 1958576886..c88656945b 100644
--- a/spec/unit/knife/core/hashed_command_loader_spec.rb
+++ b/spec/unit/knife/core/hashed_command_loader_spec.rb
@@ -50,7 +50,7 @@ describe Chef::Knife::SubcommandLoader::HashedCommandLoader do
describe "#list_commands" do
before do
- allow(File).to receive(:exists?).and_return(true)
+ allow(File).to receive(:exist?).and_return(true)
end
it "lists all commands by category when no argument is given" do
@@ -63,7 +63,7 @@ describe Chef::Knife::SubcommandLoader::HashedCommandLoader do
context "when the plugin path is invalid" do
before do
- expect(File).to receive(:exists?).with("/file/for/plugin/b").and_return(false)
+ expect(File).to receive(:exist?).with("/file/for/plugin/b").and_return(false)
end
it "lists all commands by category when no argument is given" do
@@ -90,7 +90,7 @@ describe Chef::Knife::SubcommandLoader::HashedCommandLoader do
end
it "loads the correct file and returns true if the command exists" do
- allow(File).to receive(:exists?).and_return(true)
+ allow(File).to receive(:exist?).and_return(true)
expect(Kernel).to receive(:load).with("/file/for/plugin/a").and_return(true)
expect(loader.load_command(["cool_a"])).to eq(true)
end
diff --git a/spec/unit/knife/supermarket_share_spec.rb b/spec/unit/knife/supermarket_share_spec.rb
index 6ad6e5f8c7..f6c44f4cd8 100644
--- a/spec/unit/knife/supermarket_share_spec.rb
+++ b/spec/unit/knife/supermarket_share_spec.rb
@@ -108,7 +108,7 @@ describe Chef::Knife::SupermarketShare do
expect { @knife.run }.to raise_error(SystemExit)
end
- if File.exists?("/usr/bin/gnutar") || File.exists?("/bin/gnutar")
+ if File.exist?("/usr/bin/gnutar") || File.exist?("/bin/gnutar")
it "should use gnutar to make a tarball of the cookbook" do
expect(@knife).to receive(:shell_out!) do |args|
expect(args.to_s).to match(/gnutar -czf/)
diff --git a/spec/unit/provider/service/arch_service_spec.rb b/spec/unit/provider/service/arch_service_spec.rb
index cc48459c90..026db3dc75 100644
--- a/spec/unit/provider/service/arch_service_spec.rb
+++ b/spec/unit/provider/service/arch_service_spec.rb
@@ -37,7 +37,8 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
@provider = Chef::Provider::Service::Arch.new(@new_resource, @run_context)
- allow(::File).to receive(:exists?).with("/etc/rc.conf").and_return(true)
+ allow(::File).to receive(:exist?).with("/etc/rc.d/chef").and_return(false)
+ allow(::File).to receive(:exist?).with("/etc/rc.conf").and_return(true)
allow(::File).to receive(:read).with("/etc/rc.conf").and_return("DAEMONS=(network apache sshd)")
end
@@ -106,7 +107,7 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
end
it "should fail if file /etc/rc.conf does not exist" do
- allow(::File).to receive(:exists?).with("/etc/rc.conf").and_return(false)
+ allow(::File).to receive(:exist?).with("/etc/rc.conf").and_return(false)
expect { @provider.load_current_resource }.to raise_error(Chef::Exceptions::Service)
end
diff --git a/spec/unit/provider/service/debian_service_spec.rb b/spec/unit/provider/service/debian_service_spec.rb
index 8fe573de87..d0cd048c4f 100644
--- a/spec/unit/provider/service/debian_service_spec.rb
+++ b/spec/unit/provider/service/debian_service_spec.rb
@@ -47,7 +47,7 @@ describe Chef::Provider::Service::Debian do
describe "load_current_resource" do
it "ensures /usr/sbin/update-rc.d is available" do
- expect(File).to receive(:exists?).with("/usr/sbin/update-rc.d") .and_return(false)
+ expect(File).to receive(:exist?).with("/usr/sbin/update-rc.d").and_return(false)
@provider.define_resource_requirements
expect do
diff --git a/spec/unit/provider/service/gentoo_service_spec.rb b/spec/unit/provider/service/gentoo_service_spec.rb
index 99c01b595b..f195fbe40b 100644
--- a/spec/unit/provider/service/gentoo_service_spec.rb
+++ b/spec/unit/provider/service/gentoo_service_spec.rb
@@ -32,16 +32,16 @@ describe Chef::Provider::Service::Gentoo do
allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource)
@status = double("Status", exitstatus: 0, stdout: @stdout)
allow(@provider).to receive(:shell_out).and_return(@status)
- allow(File).to receive(:exists?).with("/etc/init.d/chef").and_return(true)
- allow(File).to receive(:exists?).with("/sbin/rc-update").and_return(true)
- allow(File).to receive(:exists?).with("/etc/runlevels/default/chef").and_return(false)
+ allow(File).to receive(:exist?).with("/etc/init.d/chef").and_return(true)
+ allow(File).to receive(:exist?).with("/sbin/rc-update").and_return(true)
+ allow(File).to receive(:exist?).with("/etc/runlevels/default/chef").and_return(false)
allow(File).to receive(:readable?).with("/etc/runlevels/default/chef").and_return(false)
end
# new test: found_enabled state
#
describe "load_current_resource" do
it "should raise Chef::Exceptions::Service if /sbin/rc-update does not exist" do
- expect(File).to receive(:exists?).with("/sbin/rc-update").and_return(false)
+ expect(File).to receive(:exist?).with("/sbin/rc-update").and_return(false)
@provider.define_resource_requirements
expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service)
end
@@ -65,7 +65,7 @@ describe Chef::Provider::Service::Gentoo do
describe "and the file exists and is readable" do
before do
- allow(File).to receive(:exists?).with("/etc/runlevels/default/chef").and_return(true)
+ allow(File).to receive(:exist?).with("/etc/runlevels/default/chef").and_return(true)
allow(File).to receive(:readable?).with("/etc/runlevels/default/chef").and_return(true)
end
it "should set enabled to true" do
@@ -76,7 +76,7 @@ describe Chef::Provider::Service::Gentoo do
describe "and the file exists but is not readable" do
before do
- allow(File).to receive(:exists?).with("/etc/runlevels/default/chef").and_return(true)
+ allow(File).to receive(:exist?).with("/etc/runlevels/default/chef").and_return(true)
allow(File).to receive(:readable?).with("/etc/runlevels/default/chef").and_return(false)
end
@@ -88,7 +88,7 @@ describe Chef::Provider::Service::Gentoo do
describe "and the file does not exist" do
before do
- allow(File).to receive(:exists?).with("/etc/runlevels/default/chef").and_return(false)
+ allow(File).to receive(:exist?).with("/etc/runlevels/default/chef").and_return(false)
allow(File).to receive(:readable?).with("/etc/runlevels/default/chef").and_return("foobarbaz")
end
diff --git a/spec/unit/provider/service/macosx_spec.rb b/spec/unit/provider/service/macosx_spec.rb
index 2941230160..6cc0f88725 100644
--- a/spec/unit/provider/service/macosx_spec.rb
+++ b/spec/unit/provider/service/macosx_spec.rb
@@ -83,7 +83,7 @@ describe Chef::Provider::Service::Macosx do
.with(/(#{su_cmd} '#{cmd}'|#{cmd})/, default_env: false)
.and_return(double("Status",
stdout: launchctl_stdout, exitstatus: 0))
- allow(File).to receive(:exists?).and_return([true], [])
+ allow(File).to receive(:exist?).and_return([true], [])
allow(provider).to receive(:shell_out!)
.with(/plutil -convert xml1 -o/, default_env: false)
.and_return(double("Status", stdout: plutil_stdout))
@@ -109,7 +109,7 @@ describe Chef::Provider::Service::Macosx do
before do
allow(Dir).to receive(:glob).and_return([])
- allow(File).to receive(:exists?).and_return([true], [])
+ allow(File).to receive(:exist?).and_return([true], [])
allow(provider).to receive(:shell_out!)
.with(/plutil -convert xml1 -o/)
.and_raise(Mixlib::ShellOut::ShellCommandFailed)
@@ -165,7 +165,7 @@ describe Chef::Provider::Service::Macosx do
describe "running unsupported actions" do
before do
allow(Dir).to receive(:glob).and_return([(plist).to_s], [])
- allow(File).to receive(:exists?).and_return([true], [])
+ allow(File).to receive(:exist?).and_return([true], [])
end
it "should throw an exception when reload action is attempted" do
expect { provider.run_action(:reload) }.to raise_error(Chef::Exceptions::UnsupportedAction)
diff --git a/spec/unit/provider/service/redhat_spec.rb b/spec/unit/provider/service/redhat_spec.rb
index 9795abf771..d5d2c7ddc0 100644
--- a/spec/unit/provider/service/redhat_spec.rb
+++ b/spec/unit/provider/service/redhat_spec.rb
@@ -21,7 +21,7 @@ require "ostruct"
shared_examples_for "define_resource_requirements_common" do
it "should raise an error if /sbin/chkconfig does not exist" do
- allow(File).to receive(:exists?).with("/sbin/chkconfig").and_return(false)
+ allow(File).to receive(:exist?).with("/sbin/chkconfig").and_return(false)
allow(@provider).to receive(:shell_out).with("/sbin/service chef status").and_raise(Errno::ENOENT)
allow(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_raise(Errno::ENOENT)
@provider.load_current_resource
@@ -55,7 +55,7 @@ describe "Chef::Provider::Service::Redhat" do
@provider = Chef::Provider::Service::Redhat.new(@new_resource, @run_context)
@provider.action = :start
allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource)
- allow(File).to receive(:exists?).with("/sbin/chkconfig").and_return(true)
+ allow(File).to receive(:exist?).with("/sbin/chkconfig").and_return(true)
end
describe "while not in why run mode" do
diff --git a/spec/unit/provider/service/upstart_service_spec.rb b/spec/unit/provider/service/upstart_service_spec.rb
index 572246a807..20cbef11ce 100644
--- a/spec/unit/provider/service/upstart_service_spec.rb
+++ b/spec/unit/provider/service/upstart_service_spec.rb
@@ -74,7 +74,7 @@ describe Chef::Provider::Service::Upstart do
@status = double("Status", exitstatus: 0, stdout: "", stderr: "")
allow(@provider).to receive(:shell_out).and_return(@status)
- allow(::File).to receive(:exists?).and_return(true)
+ allow(::File).to receive(:exist?).and_return(true)
allow(::File).to receive(:open).and_return(true)
end
@@ -181,13 +181,13 @@ describe Chef::Provider::Service::Upstart do
end
it "should assume disable when no job configuration file is found" do
- allow(::File).to receive(:exists?).and_return(false)
+ allow(::File).to receive(:exist?).and_return(false)
expect(@current_resource).to receive(:running).with(false)
@provider.load_current_resource
end
it "should track state when the upstart configuration file fails to load" do
- expect(File).to receive(:exists?).and_return false
+ expect(File).to receive(:exist?).and_return false
@provider.load_current_resource
expect(@provider.instance_variable_get("@config_file_found")).to eq(false)
end
diff --git a/spec/unit/role_spec.rb b/spec/unit/role_spec.rb
index aaabb397ab..86589d1883 100644
--- a/spec/unit/role_spec.rb
+++ b/spec/unit/role_spec.rb
@@ -259,7 +259,7 @@ describe Chef::Role do
it "should return a Chef::Role object from JSON" do
expect(Dir).to receive(:glob).and_return(["#{Chef::Config[:role_path]}/memes", "#{Chef::Config[:role_path]}/memes/lolcat.json"])
file_path = File.join(Chef::Config[:role_path], "memes/lolcat.json")
- expect(File).to receive(:exists?).with(file_path).exactly(1).times.and_return(true)
+ expect(File).to receive(:exist?).with(file_path).exactly(1).times.and_return(true)
expect(IO).to receive(:read).with(file_path).and_return('{"name": "ceiling_cat", "json_class": "Chef::Role" }')
expect(@role).to be_a_kind_of(Chef::Role)
@role.class.from_disk("lolcat")
@@ -268,7 +268,7 @@ describe Chef::Role do
it "should return a Chef::Role object from a Ruby DSL" do
expect(Dir).to receive(:glob).and_return(["#{Chef::Config[:role_path]}/memes", "#{Chef::Config[:role_path]}/memes/lolcat.rb"])
rb_path = File.join(Chef::Config[:role_path], "memes/lolcat.rb")
- expect(File).to receive(:exists?).with(rb_path).exactly(1).times.and_return(true)
+ expect(File).to receive(:exist?).with(rb_path).exactly(1).times.and_return(true)
expect(File).to receive(:readable?).with(rb_path).exactly(1).times.and_return(true)
expect(File).to receive(:file?).with(rb_path).exactly(1).times.and_return(true)
expect(IO).to receive(:read).with(rb_path).and_return(ROLE_DSL)
@@ -280,8 +280,8 @@ describe Chef::Role do
expect(Dir).to receive(:glob).and_return(["#{Chef::Config[:role_path]}/memes", "#{Chef::Config[:role_path]}/memes/lolcat.json", "#{Chef::Config[:role_path]}/memes/lolcat.rb"])
js_path = File.join(Chef::Config[:role_path], "memes/lolcat.json")
rb_path = File.join(Chef::Config[:role_path], "memes/lolcat.rb")
- expect(File).to receive(:exists?).with(js_path).exactly(1).times.and_return(true)
- expect(File).not_to receive(:exists?).with(rb_path)
+ expect(File).to receive(:exist?).with(js_path).exactly(1).times.and_return(true)
+ expect(File).not_to receive(:exist?).with(rb_path)
expect(IO).to receive(:read).with(js_path).and_return('{"name": "ceiling_cat", "json_class": "Chef::Role" }')
expect(@role).to be_a_kind_of(Chef::Role)
@role.class.from_disk("lolcat")
@@ -289,19 +289,19 @@ describe Chef::Role do
it "should raise an exception if the file does not exist" do
expect(Dir).to receive(:glob).and_return(["#{Chef::Config[:role_path]}/meme.rb"])
- expect(File).not_to receive(:exists?)
+ expect(File).not_to receive(:exist?)
expect { @role.class.from_disk("lolcat") }.to raise_error(Chef::Exceptions::RoleNotFound)
end
it "should raise an exception if two files exist with the same name" do
expect(Dir).to receive(:glob).and_return(["#{Chef::Config[:role_path]}/memes/lolcat.rb", "#{Chef::Config[:role_path]}/lolcat.rb"])
- expect(File).not_to receive(:exists?)
+ expect(File).not_to receive(:exist?)
expect { @role.class.from_disk("lolcat") }.to raise_error(Chef::Exceptions::DuplicateRole)
end
it "should not raise an exception if two files exist with a similar name" do
expect(Dir).to receive(:glob).and_return(["#{Chef::Config[:role_path]}/memes/lolcat.rb", "#{Chef::Config[:role_path]}/super_lolcat.rb"])
- expect(File).to receive(:exists?).with("#{Chef::Config[:role_path]}/memes/lolcat.rb").and_return(true)
+ expect(File).to receive(:exist?).with("#{Chef::Config[:role_path]}/memes/lolcat.rb").and_return(true)
allow_any_instance_of(Chef::Role).to receive(:from_file).with("#{Chef::Config[:role_path]}/memes/lolcat.rb")
expect { @role.class.from_disk("lolcat") }.not_to raise_error
end
@@ -317,7 +317,7 @@ describe Chef::Role do
it "should return a Chef::Role object from JSON" do
expect(Dir).to receive(:glob).with(File.join(root, "**", "**")).exactly(1).times.and_return(["#{root}/lolcat.json"])
- expect(File).to receive(:exists?).with("#{root}/lolcat.json").exactly(1).times.and_return(true)
+ expect(File).to receive(:exist?).with("#{root}/lolcat.json").exactly(1).times.and_return(true)
expect(IO).to receive(:read).with("#{root}/lolcat.json").and_return('{"name": "ceiling_cat", "json_class": "Chef::Role" }')
expect(@role).to be_a_kind_of(Chef::Role)
@role.class.from_disk("lolcat")
@@ -326,7 +326,7 @@ describe Chef::Role do
it "should return a Chef::Role object from JSON when role is in the second path" do
expect(Dir).to receive(:glob).with(File.join(root, "**", "**")).exactly(1).times.and_return([])
expect(Dir).to receive(:glob).with(File.join("#{root}/path2", "**", "**")).exactly(1).times.and_return(["#{root}/path2/lolcat.json"])
- expect(File).to receive(:exists?).with("#{root}/path2/lolcat.json").exactly(1).times.and_return(true)
+ expect(File).to receive(:exist?).with("#{root}/path2/lolcat.json").exactly(1).times.and_return(true)
expect(IO).to receive(:read).with("#{root}/path2/lolcat.json").and_return('{"name": "ceiling_cat", "json_class": "Chef::Role" }')
expect(@role).to be_a_kind_of(Chef::Role)
@role.class.from_disk("lolcat")
@@ -334,7 +334,7 @@ describe Chef::Role do
it "should return a Chef::Role object from a Ruby DSL" do
expect(Dir).to receive(:glob).with(File.join(root, "**", "**")).exactly(1).times.and_return(["#{root}/lolcat.rb"])
- expect(File).to receive(:exists?).with("#{root}/lolcat.rb").exactly(1).times.and_return(true)
+ expect(File).to receive(:exist?).with("#{root}/lolcat.rb").exactly(1).times.and_return(true)
expect(File).to receive(:readable?).with("#{root}/lolcat.rb").and_return(true)
expect(File).to receive(:file?).with("#{root}/lolcat.rb").and_return(true)
expect(IO).to receive(:read).with("#{root}/lolcat.rb").exactly(1).times.and_return(ROLE_DSL)
@@ -345,7 +345,7 @@ describe Chef::Role do
it "should return a Chef::Role object from a Ruby DSL when role is in the second path" do
expect(Dir).to receive(:glob).with(File.join(root, "**", "**")).exactly(1).times.and_return([])
expect(Dir).to receive(:glob).with(File.join("#{root}/path2", "**", "**")).exactly(1).times.and_return(["#{root}/path2/lolcat.rb"])
- expect(File).to receive(:exists?).with("#{root}/path2/lolcat.rb").exactly(1).times.and_return(true)
+ expect(File).to receive(:exist?).with("#{root}/path2/lolcat.rb").exactly(1).times.and_return(true)
expect(File).to receive(:readable?).with("#{root}/path2/lolcat.rb").and_return(true)
expect(File).to receive(:file?).with("#{root}/path2/lolcat.rb").and_return(true)
expect(IO).to receive(:read).with("#{root}/path2/lolcat.rb").exactly(1).times.and_return(ROLE_DSL)