diff options
author | Tim Smith <tsmith@chef.io> | 2020-08-14 10:15:40 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-14 10:15:40 -0700 |
commit | c0c8c32e41a4496d3b78acc942f26f667045b3f8 (patch) | |
tree | e1ba9028cb89f0fc83fcbecb5ed778ac4ad6f630 /spec/functional | |
parent | b9df6856a1eb4688f013ba0449a362f951ab40e5 (diff) | |
parent | 4848c89b7cc5e4a4d4fac7c8bff962f7df69f719 (diff) | |
download | chef-c0c8c32e41a4496d3b78acc942f26f667045b3f8.tar.gz |
Merge pull request #10284 from chef/exist
Fix File.exist throughout the codebase
Diffstat (limited to 'spec/functional')
-rwxr-xr-x | spec/functional/resource/aixinit_service_spec.rb | 14 | ||||
-rw-r--r-- | spec/functional/resource/bff_spec.rb | 4 | ||||
-rw-r--r-- | spec/functional/resource/cookbook_file_spec.rb | 2 | ||||
-rw-r--r-- | spec/functional/resource/dsc_resource_spec.rb | 2 | ||||
-rw-r--r-- | spec/functional/resource/insserv_spec.rb | 8 | ||||
-rw-r--r-- | spec/functional/resource/link_spec.rb | 24 | ||||
-rw-r--r-- | spec/functional/resource/rpm_spec.rb | 4 | ||||
-rw-r--r-- | spec/functional/resource/windows_certificate_spec.rb | 6 | ||||
-rw-r--r-- | spec/functional/win32/service_manager_spec.rb | 2 |
9 files changed, 33 insertions, 33 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 |