diff options
30 files changed, 73 insertions, 78 deletions
diff --git a/chef-config/spec/unit/config_spec.rb b/chef-config/spec/unit/config_spec.rb index 3d7365927d..d4761ff953 100644 --- a/chef-config/spec/unit/config_spec.rb +++ b/chef-config/spec/unit/config_spec.rb @@ -516,7 +516,7 @@ RSpec.describe ChefConfig::Config do context "when /var/chef does not exist and /var is accessible" do it "defaults to /var/chef" do - allow(File).to receive(:exists?).with(ChefConfig::Config.var_chef_dir).and_return(false) + allow(File).to receive(:exist?).with(ChefConfig::Config.var_chef_dir).and_return(false) allow(ChefConfig::Config).to receive(:path_accessible?).with(ChefConfig::Config.var_root_dir).and_return(true) expect(ChefConfig::Config[:cache_path]).to eq(primary_cache_path) end @@ -524,7 +524,7 @@ RSpec.describe ChefConfig::Config do context "when /var/chef does not exist and /var is not accessible" do it "defaults to $HOME/.chef" do - allow(File).to receive(:exists?).with(ChefConfig::Config.var_chef_dir).and_return(false) + allow(File).to receive(:exist?).with(ChefConfig::Config.var_chef_dir).and_return(false) allow(ChefConfig::Config).to receive(:path_accessible?).with(ChefConfig::Config.var_root_dir).and_return(false) expect(ChefConfig::Config[:cache_path]).to eq(secondary_cache_path) end @@ -532,7 +532,7 @@ RSpec.describe ChefConfig::Config do context "when /var/chef exists and is not accessible" do before do - allow(File).to receive(:exists?).with(ChefConfig::Config.var_chef_dir).and_return(true) + allow(File).to receive(:exist?).with(ChefConfig::Config.var_chef_dir).and_return(true) allow(File).to receive(:readable?).with(ChefConfig::Config.var_chef_dir).and_return(true) allow(File).to receive(:writable?).with(ChefConfig::Config.var_chef_dir).and_return(false) end diff --git a/lib/chef/client.rb b/lib/chef/client.rb index 099c061a96..ff2f310130 100644 --- a/lib/chef/client.rb +++ b/lib/chef/client.rb @@ -638,7 +638,7 @@ class Chef if !config[:client_key] events.skipping_registration(client_name, config) logger.trace("Client key is unspecified - skipping registration") - elsif File.exists?(config[:client_key]) + elsif File.exist?(config[:client_key]) events.skipping_registration(client_name, config) logger.trace("Client key #{config[:client_key]} is present - skipping registration") else @@ -878,7 +878,7 @@ class Chef end def empty_directory?(path) - !File.exists?(path) || (Dir.entries(path).size <= 2) + !File.exist?(path) || (Dir.entries(path).size <= 2) end def is_last_element?(index, object) diff --git a/lib/chef/cookbook/cookbook_version_loader.rb b/lib/chef/cookbook/cookbook_version_loader.rb index faed509321..00cf22e6da 100644 --- a/lib/chef/cookbook/cookbook_version_loader.rb +++ b/lib/chef/cookbook/cookbook_version_loader.rb @@ -160,13 +160,13 @@ class Chef def metadata_filenames return @metadata_filenames unless @metadata_filenames.empty? - if File.exists?(File.join(cookbook_path, UPLOADED_COOKBOOK_VERSION_FILE)) + if File.exist?(File.join(cookbook_path, UPLOADED_COOKBOOK_VERSION_FILE)) @uploaded_cookbook_version_file = File.join(cookbook_path, UPLOADED_COOKBOOK_VERSION_FILE) end - if File.exists?(File.join(cookbook_path, "metadata.json")) + if File.exist?(File.join(cookbook_path, "metadata.json")) @metadata_filenames << File.join(cookbook_path, "metadata.json") - elsif File.exists?(File.join(cookbook_path, "metadata.rb")) + elsif File.exist?(File.join(cookbook_path, "metadata.rb")) @metadata_filenames << File.join(cookbook_path, "metadata.rb") elsif uploaded_cookbook_version_file @metadata_filenames << uploaded_cookbook_version_file diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb index 420532585a..f6f5c12974 100644 --- a/lib/chef/cookbook_version.rb +++ b/lib/chef/cookbook_version.rb @@ -471,7 +471,7 @@ class Chef end def reload_metadata! - if File.exists?(metadata_json_file) + if File.exist?(metadata_json_file) metadata.from_json(IO.read(metadata_json_file)) end end diff --git a/lib/chef/dsl/reboot_pending.rb b/lib/chef/dsl/reboot_pending.rb index 19d3a6b0bd..5a6f8ee219 100644 --- a/lib/chef/dsl/reboot_pending.rb +++ b/lib/chef/dsl/reboot_pending.rb @@ -47,7 +47,7 @@ class Chef registry_key_exists?('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending') elsif platform?("ubuntu") # This should work for Debian as well if update-notifier-common happens to be installed. We need an API for that. - File.exists?("/var/run/reboot-required") + File.exist?("/var/run/reboot-required") else false end diff --git a/lib/chef/file_access_control/windows.rb b/lib/chef/file_access_control/windows.rb index cc1b96a84d..744c5f7466 100644 --- a/lib/chef/file_access_control/windows.rb +++ b/lib/chef/file_access_control/windows.rb @@ -33,7 +33,7 @@ class Chef module ClassMethods # We want to mix these in as class methods def writable?(path) - ::File.exists?(path) && Chef::ReservedNames::Win32::File.file_access_check( + ::File.exist?(path) && Chef::ReservedNames::Win32::File.file_access_check( path, Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_WRITE ) end @@ -136,7 +136,7 @@ class Chef end def should_update_dacl? - return true unless ::File.exists?(file) || ::File.symlink?(file) + return true unless ::File.exist?(file) || ::File.symlink?(file) dacl = target_dacl existing_dacl = existing_descriptor.dacl @@ -170,7 +170,7 @@ class Chef end def should_update_group? - return true unless ::File.exists?(file) || ::File.symlink?(file) + return true unless ::File.exist?(file) || ::File.symlink?(file) (group = target_group) && (group != existing_descriptor.group) end @@ -190,7 +190,7 @@ class Chef end def should_update_owner? - return true unless ::File.exists?(file) || ::File.symlink?(file) + return true unless ::File.exist?(file) || ::File.symlink?(file) (owner = target_owner) && (owner != existing_descriptor.owner) end diff --git a/lib/chef/file_cache.rb b/lib/chef/file_cache.rb index 22060869da..851234596a 100644 --- a/lib/chef/file_cache.rb +++ b/lib/chef/file_cache.rb @@ -79,7 +79,7 @@ class Chef file_path_array = File.split(path) file_name = file_path_array.pop - if File.exists?(file) && File.writable?(file) + if File.exist?(file) && File.writable?(file) FileUtils.mv( file, File.join(create_cache_path(File.join(file_path_array), true), file_name) @@ -112,7 +112,7 @@ class Chef } ) cache_path = create_cache_path(path, false) - raise Chef::Exceptions::FileNotFound, "Cannot find #{cache_path} for #{path}!" unless File.exists?(cache_path) + raise Chef::Exceptions::FileNotFound, "Cannot find #{cache_path} for #{path}!" unless File.exist?(cache_path) if read File.read(cache_path) @@ -139,7 +139,7 @@ class Chef } ) cache_path = create_cache_path(path, false) - if File.exists?(cache_path) + if File.exist?(cache_path) File.unlink(cache_path) end true @@ -186,7 +186,7 @@ class Chef } ) full_path = create_cache_path(path, false) - if File.exists?(full_path) + if File.exist?(full_path) true else false diff --git a/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb b/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb index 905a438f56..8ddae24e6d 100644 --- a/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +++ b/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb @@ -66,7 +66,7 @@ class Chef @snippet ||= begin if (file = parse_source) && (line = parse_line(file)) - return nil unless ::File.exists?(file) + return nil unless ::File.exist?(file) lines = IO.readlines(file) diff --git a/lib/chef/handler/json_file.rb b/lib/chef/handler/json_file.rb index 6318c30d74..998f2b0e0e 100644 --- a/lib/chef/handler/json_file.rb +++ b/lib/chef/handler/json_file.rb @@ -51,7 +51,7 @@ class Chef end def build_report_dir - unless File.exists?(config[:path]) + unless File.exist?(config[:path]) FileUtils.mkdir_p(config[:path]) File.chmod(00700, config[:path]) end diff --git a/lib/chef/http/ssl_policies.rb b/lib/chef/http/ssl_policies.rb index d03494defe..60a763d431 100644 --- a/lib/chef/http/ssl_policies.rb +++ b/lib/chef/http/ssl_policies.rb @@ -92,10 +92,10 @@ class Chef unless config[:ssl_client_cert] && config[:ssl_client_key] raise Chef::Exceptions::ConfigurationError, "You must configure ssl_client_cert and ssl_client_key together" end - unless ::File.exists?(config[:ssl_client_cert]) + unless ::File.exist?(config[:ssl_client_cert]) raise Chef::Exceptions::ConfigurationError, "The configured ssl_client_cert #{config[:ssl_client_cert]} does not exist" end - unless ::File.exists?(config[:ssl_client_key]) + unless ::File.exist?(config[:ssl_client_key]) raise Chef::Exceptions::ConfigurationError, "The configured ssl_client_key #{config[:ssl_client_key]} does not exist" end diff --git a/lib/chef/node.rb b/lib/chef/node.rb index d569eeda38..50a861066b 100644 --- a/lib/chef/node.rb +++ b/lib/chef/node.rb @@ -761,7 +761,7 @@ class Chef path = File.expand_path(Chef::Config[:chef_guid_path]) dir = File.dirname(path) - unless File.exists?(path) + unless File.exist?(path) FileUtils.mkdir_p(dir) File.write(path, SecureRandom.uuid) end diff --git a/lib/chef/provider/directory.rb b/lib/chef/provider/directory.rb index 555340d91e..6a20556ccd 100644 --- a/lib/chef/provider/directory.rb +++ b/lib/chef/provider/directory.rb @@ -32,7 +32,7 @@ class Chef def load_current_resource @current_resource = Chef::Resource::Directory.new(new_resource.name) current_resource.path(new_resource.path) - if ::File.exists?(current_resource.path) && @action != :create_if_missing + if ::File.exist?(current_resource.path) && @action != :create_if_missing load_resource_attributes_from_file(current_resource) end current_resource @@ -73,7 +73,7 @@ class Chef # make sure we have write permissions to that directory is_parent_writable = lambda do |base_dir| base_dir = ::File.dirname(base_dir) - if ::File.exists?(base_dir) + if ::File.exist?(base_dir) if Chef::FileAccessControl.writable?(base_dir) true elsif Chef::Util::PathHelper.is_sip_path?(base_dir, node) @@ -89,7 +89,7 @@ class Chef else # in why run mode & parent directory does not exist no permissions check is required # If not in why run, permissions must be valid and we rely on prior assertion that dir exists - if !whyrun_mode? || ::File.exists?(parent_directory) + if !whyrun_mode? || ::File.exist?(parent_directory) if Chef::FileAccessControl.writable?(parent_directory) true elsif Chef::Util::PathHelper.is_sip_path?(parent_directory, node) @@ -108,7 +108,7 @@ class Chef requirements.assert(:delete) do |a| a.assertion do - if ::File.exists?(new_resource.path) + if ::File.exist?(new_resource.path) ::File.directory?(new_resource.path) && Chef::FileAccessControl.writable?(new_resource.path) else true @@ -122,7 +122,7 @@ class Chef end action :create do - unless ::File.exists?(new_resource.path) + unless ::File.exist?(new_resource.path) converge_by("create new directory #{new_resource.path}") do if new_resource.recursive == true ::FileUtils.mkdir_p(new_resource.path) @@ -138,7 +138,7 @@ class Chef end action :delete do - if ::File.exists?(new_resource.path) + if ::File.exist?(new_resource.path) converge_by("delete existing directory #{new_resource.path}") do if new_resource.recursive == true # we don't use rm_rf here because it masks all errors, including diff --git a/lib/chef/provider/file.rb b/lib/chef/provider/file.rb index e2c07ad9f7..b4d659b4e8 100644 --- a/lib/chef/provider/file.rb +++ b/lib/chef/provider/file.rb @@ -157,7 +157,7 @@ class Chef end action :delete do - if ::File.exists?(new_resource.path) + if ::File.exist?(new_resource.path) converge_by("delete file #{new_resource.path}") do do_backup unless file_class.symlink?(new_resource.path) ::File.delete(new_resource.path) @@ -393,7 +393,7 @@ class Chef # a nil tempfile is okay, means the resource has no content or no new content return if tempfile.nil? # but a tempfile that has no path or doesn't exist should not happen - if tempfile.path.nil? || !::File.exists?(tempfile.path) + if tempfile.path.nil? || !::File.exist?(tempfile.path) raise "#{ChefUtils::Dist::Infra::CLIENT} is confused, trying to deploy a file that has no path or does not exist..." end diff --git a/lib/chef/provider/launchd.rb b/lib/chef/provider/launchd.rb index b8ff9dfa4d..73380fc83b 100644 --- a/lib/chef/provider/launchd.rb +++ b/lib/chef/provider/launchd.rb @@ -52,7 +52,7 @@ class Chef end action :delete do - if ::File.exists?(path) + if ::File.exist?(path) manage_service(:disable) end manage_plist(:delete) diff --git a/lib/chef/provider/link.rb b/lib/chef/provider/link.rb index 900d0516af..63582b462a 100644 --- a/lib/chef/provider/link.rb +++ b/lib/chef/provider/link.rb @@ -43,8 +43,8 @@ class Chef ) else current_resource.link_type(:hard) - if ::File.exists?(current_resource.target_file) - if ::File.exists?(new_resource.to) && + if ::File.exist?(current_resource.target_file) + if ::File.exist?(new_resource.to) && file_class.stat(current_resource.target_file).ino == file_class.stat(new_resource.to).ino current_resource.to(canonicalize(new_resource.to)) diff --git a/lib/chef/provider/mount/linux.rb b/lib/chef/provider/mount/linux.rb index 382e37d41a..a57d16a12b 100644 --- a/lib/chef/provider/mount/linux.rb +++ b/lib/chef/provider/mount/linux.rb @@ -33,7 +33,7 @@ class Chef def mounted? mounted = false - real_mount_point = if ::File.exists? @new_resource.mount_point + real_mount_point = if ::File.exist? @new_resource.mount_point ::File.realpath(@new_resource.mount_point) else @new_resource.mount_point diff --git a/lib/chef/provider/mount/mount.rb b/lib/chef/provider/mount/mount.rb index 0bd81d5453..4fb626ca60 100644 --- a/lib/chef/provider/mount/mount.rb +++ b/lib/chef/provider/mount/mount.rb @@ -42,9 +42,9 @@ class Chef def mountable? # only check for existence of non-remote devices - if device_should_exist? && !::File.exists?(device_real) + if device_should_exist? && !::File.exist?(device_real) raise Chef::Exceptions::Mount, "Device #{@new_resource.device} does not exist" - elsif @new_resource.mount_point != "none" && !::File.exists?(@new_resource.mount_point) + elsif @new_resource.mount_point != "none" && !::File.exist?(@new_resource.mount_point) raise Chef::Exceptions::Mount, "Mount point #{@new_resource.mount_point} does not exist" end @@ -81,7 +81,7 @@ class Chef # "mount" outputs the mount points as real paths. Convert # the mount_point of the resource to a real path in case it # contains symlinks in its parents dirs. - real_mount_point = if ::File.exists? @new_resource.mount_point + real_mount_point = if ::File.exist? @new_resource.mount_point ::File.realpath(@new_resource.mount_point) else @new_resource.mount_point diff --git a/lib/chef/provider/template.rb b/lib/chef/provider/template.rb index 6662821aae..307dad7b7b 100644 --- a/lib/chef/provider/template.rb +++ b/lib/chef/provider/template.rb @@ -39,7 +39,7 @@ class Chef super requirements.assert(:create, :create_if_missing) do |a| - a.assertion { ::File.exists?(content.template_location) } + a.assertion { ::File.exist?(content.template_location) } a.failure_message "Template source #{content.template_location} could not be found." a.whyrun "Template source #{content.template_location} does not exist. Assuming it would have been created." a.block_action! diff --git a/spec/functional/resource/execute_spec.rb b/spec/functional/resource/execute_spec.rb index 3d7e185e17..c05d8da3ef 100644 --- a/spec/functional/resource/execute_spec.rb +++ b/spec/functional/resource/execute_spec.rb @@ -62,7 +62,7 @@ describe Chef::Resource::Execute do end describe "when parent resource sets :cwd" do - let(:guard) { %{ruby -e 'exit 1 unless File.exists?("./nested.json")'} } + let(:guard) { %{ruby -e 'exit 1 unless File.exist?("./nested.json")'} } it "guard inherits :cwd from resource and runs" do resource.cwd CHEF_SPEC_DATA diff --git a/spec/support/shared/unit/provider/file.rb b/spec/support/shared/unit/provider/file.rb index f624a6ae44..dbbb4583d0 100644 --- a/spec/support/shared/unit/provider/file.rb +++ b/spec/support/shared/unit/provider/file.rb @@ -43,7 +43,6 @@ end def setup_normal_file [ resource_path, normalized_path, windows_path].each do |path| allow(File).to receive(:file?).with(path).and_return(true) - allow(File).to receive(:exists?).with(path).and_return(true) allow(File).to receive(:exist?).with(path).and_return(true) allow(File).to receive(:directory?).with(path).and_return(false) allow(File).to receive(:writable?).with(path).and_return(true) @@ -57,7 +56,6 @@ def setup_missing_file [ resource_path, normalized_path, windows_path].each do |path| allow(File).to receive(:file?).with(path).and_return(false) allow(File).to receive(:realpath?).with(path).and_return(resource_path) - allow(File).to receive(:exists?).with(path).and_return(false) allow(File).to receive(:exist?).with(path).and_return(false) allow(File).to receive(:directory?).with(path).and_return(false) allow(File).to receive(:writable?).with(path).and_return(false) @@ -70,7 +68,6 @@ def setup_symlink [ resource_path, normalized_path, windows_path].each do |path| allow(File).to receive(:file?).with(path).and_return(true) allow(File).to receive(:realpath?).with(path).and_return(normalized_path) - allow(File).to receive(:exists?).with(path).and_return(true) allow(File).to receive(:exist?).with(path).and_return(true) allow(File).to receive(:directory?).with(path).and_return(false) allow(File).to receive(:writable?).with(path).and_return(true) @@ -84,7 +81,6 @@ def setup_unwritable_file [ resource_path, normalized_path, windows_path].each do |path| allow(File).to receive(:file?).with(path).and_return(false) allow(File).to receive(:realpath?).with(path).and_raise(Errno::ENOENT) - allow(File).to receive(:exists?).with(path).and_return(true) allow(File).to receive(:exist?).with(path).and_return(true) allow(File).to receive(:directory?).with(path).and_return(false) allow(File).to receive(:writable?).with(path).and_return(false) @@ -97,7 +93,6 @@ def setup_missing_enclosing_directory [ resource_path, normalized_path, windows_path].each do |path| allow(File).to receive(:file?).with(path).and_return(false) allow(File).to receive(:realpath?).with(path).and_raise(Errno::ENOENT) - allow(File).to receive(:exists?).with(path).and_return(false) allow(File).to receive(:exist?).with(path).and_return(false) allow(File).to receive(:directory?).with(path).and_return(false) allow(File).to receive(:writable?).with(path).and_return(false) @@ -138,7 +133,6 @@ shared_examples_for Chef::Provider::File do before(:each) do allow(content).to receive(:tempfile).and_return(tempfile) allow(File).to receive(:exist?).with(tempfile.path).and_call_original - allow(File).to receive(:exists?).with(tempfile.path).and_call_original end after do @@ -533,7 +527,7 @@ shared_examples_for Chef::Provider::File do provider.load_current_resource tempfile = double("Tempfile", path: "/tmp/foo-bar-baz") allow(content).to receive(:tempfile).and_return(tempfile) - expect(File).to receive(:exists?).with("/tmp/foo-bar-baz").and_return(true) + expect(File).to receive(:exist?).with("/tmp/foo-bar-baz").and_return(true) expect(tempfile).to receive(:close).once expect(tempfile).to receive(:unlink).once end @@ -616,7 +610,7 @@ shared_examples_for Chef::Provider::File do it "raises an exception when the content object returns a tempfile that does not exist" do tempfile = double("Tempfile", path: "/tmp/foo-bar-baz") expect(provider.send(:content)).to receive(:tempfile).at_least(:once).and_return(tempfile) - expect(File).to receive(:exists?).with("/tmp/foo-bar-baz").and_return(false) + expect(File).to receive(:exist?).with("/tmp/foo-bar-baz").and_return(false) expect { provider.send(:do_contents_changes) }.to raise_error(RuntimeError) end end diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb index 377a0b8f05..c19a32cecd 100644 --- a/spec/unit/client_spec.rb +++ b/spec/unit/client_spec.rb @@ -113,8 +113,8 @@ shared_context "a client run" do # --Client.register # Make sure Client#register thinks the client key doesn't # exist, so it tries to register and create one. - allow(File).to receive(:exists?).and_call_original - expect(File).to receive(:exists?) + allow(File).to receive(:exist?).and_call_original + expect(File).to receive(:exist?) .with(Chef::Config[:client_key]) .exactly(:once) .and_return(api_client_exists?) diff --git a/spec/unit/dsl/reboot_pending_spec.rb b/spec/unit/dsl/reboot_pending_spec.rb index 4fed3be442..3ad1be9e38 100644 --- a/spec/unit/dsl/reboot_pending_spec.rb +++ b/spec/unit/dsl/reboot_pending_spec.rb @@ -57,12 +57,12 @@ describe Chef::DSL::RebootPending do end it "should return true if /var/run/reboot-required exists" do - allow(File).to receive(:exists?).with("/var/run/reboot-required").and_return(true) + allow(File).to receive(:exist?).with("/var/run/reboot-required").and_return(true) expect(recipe.reboot_pending?).to be_truthy end it "should return false if /var/run/reboot-required does not exist" do - allow(File).to receive(:exists?).with("/var/run/reboot-required").and_return(false) + allow(File).to receive(:exist?).with("/var/run/reboot-required").and_return(false) expect(recipe.reboot_pending?).to be_falsey end end diff --git a/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb b/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb index 9d8fb050da..6693eded03 100644 --- a/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb +++ b/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb @@ -115,7 +115,7 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do # fake code to run through #recipe_snippet source_file = [ "if true", "var = non_existent", "end" ] allow(IO).to receive(:readlines).and_return(source_file) - allow(File).to receive(:exists?).and_return(true) + allow(File).to receive(:exist?).and_return(true) end it "parses a Windows path" do @@ -141,7 +141,7 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do context "when the recipe file does not exist" do before do - allow(File).to receive(:exists?).and_return(false) + allow(File).to receive(:exist?).and_return(false) allow(IO).to receive(:readlines).and_raise(Errno::ENOENT) end diff --git a/spec/unit/provider/launchd_spec.rb b/spec/unit/provider/launchd_spec.rb index 6a729c2cb6..b3306d2676 100644 --- a/spec/unit/provider/launchd_spec.rb +++ b/spec/unit/provider/launchd_spec.rb @@ -197,7 +197,7 @@ describe Chef::Provider::Launchd do describe "with an :delete action" do describe "and the ld file is present" do before(:each) do - allow(File).to receive(:exists?).and_return(true) + allow(File).to receive(:exist?).and_return(true) allow(provider).to receive( :manage_service ).with(:disable).and_return(true) @@ -218,7 +218,7 @@ describe Chef::Provider::Launchd do describe "and the ld file is not present" do before(:each) do - allow(File).to receive(:exists?).and_return(false) + allow(File).to receive(:exist?).and_return(false) allow(provider).to receive( :manage_plist ).with(:delete).and_return(true) diff --git a/spec/unit/provider/link_spec.rb b/spec/unit/provider/link_spec.rb index eebf0a9d07..b56d67ae77 100644 --- a/spec/unit/provider/link_spec.rb +++ b/spec/unit/provider/link_spec.rb @@ -125,7 +125,7 @@ describe Chef::Resource::Link do describe "when the target doesn't exist" do before do - allow(File).to receive(:exists?).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(false) + allow(File).to receive(:exist?).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(false) allow(provider.file_class).to receive(:symlink?).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(false) provider.load_current_resource end @@ -152,13 +152,13 @@ describe Chef::Resource::Link do allow(stat).to receive(:mode).and_return(0755) allow(provider.file_class).to receive(:stat).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(stat) - allow(File).to receive(:exists?).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(true) + allow(File).to receive(:exist?).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(true) allow(provider.file_class).to receive(:symlink?).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(false) end describe "and the source does not exist" do before do - allow(File).to receive(:exists?).with("#{CHEF_SPEC_DATA}/fofile").and_return(false) + allow(File).to receive(:exist?).with("#{CHEF_SPEC_DATA}/fofile").and_return(false) provider.load_current_resource end @@ -185,7 +185,7 @@ describe Chef::Resource::Link do allow(provider.file_class).to receive(:stat).with("#{CHEF_SPEC_DATA}/fofile").and_return(stat) - allow(File).to receive(:exists?).with("#{CHEF_SPEC_DATA}/fofile").and_return(true) + allow(File).to receive(:exist?).with("#{CHEF_SPEC_DATA}/fofile").and_return(true) provider.load_current_resource end @@ -212,7 +212,7 @@ describe Chef::Resource::Link do allow(provider.file_class).to receive(:stat).with("#{CHEF_SPEC_DATA}/fofile").and_return(stat) - allow(File).to receive(:exists?).with("#{CHEF_SPEC_DATA}/fofile").and_return(true) + allow(File).to receive(:exist?).with("#{CHEF_SPEC_DATA}/fofile").and_return(true) provider.load_current_resource end @@ -336,10 +336,10 @@ describe Chef::Resource::Link do "#{CHEF_SPEC_DATA}/fofile-link" ).and_return(false) - allow(File).to receive(:exists?).with( + allow(File).to receive(:exist?).with( "#{CHEF_SPEC_DATA}/fofile-link" ).and_return(true) - allow(File).to receive(:exists?).with( + allow(File).to receive(:exist?).with( "#{CHEF_SPEC_DATA}/fofile" ).and_return(true) diff --git a/spec/unit/provider/mount/aix_spec.rb b/spec/unit/provider/mount/aix_spec.rb index 3d77a23bd6..de00528b68 100644 --- a/spec/unit/provider/mount/aix_spec.rb +++ b/spec/unit/provider/mount/aix_spec.rb @@ -65,8 +65,8 @@ describe Chef::Provider::Mount::Aix do @provider = Chef::Provider::Mount::Aix.new(@new_resource, @run_context) - allow(::File).to receive(:exists?).with("/dev/sdz1").and_return true - allow(::File).to receive(:exists?).with("/tmp/foo").and_return true + allow(::File).to receive(:exist?).with("/dev/sdz1").and_return true + allow(::File).to receive(:exist?).with("/tmp/foo").and_return true end def stub_mounted(provider, mounted_output) diff --git a/spec/unit/provider/mount/linux_spec.rb b/spec/unit/provider/mount/linux_spec.rb index 3e41f895d1..4f25367c53 100644 --- a/spec/unit/provider/mount/linux_spec.rb +++ b/spec/unit/provider/mount/linux_spec.rb @@ -5,7 +5,7 @@ describe Chef::Provider::Mount::Linux do let(:run_context) do node = Chef::Node.new events = Chef::EventDispatch::Dispatcher.new - run_context = Chef::RunContext.new(node, {}, events) + Chef::RunContext.new(node, {}, events) end let(:new_resource) do @@ -22,9 +22,10 @@ describe Chef::Provider::Mount::Linux do end before(:each) do - allow(::File).to receive(:exists?).with("/dev/sdz1").and_return true - allow(::File).to receive(:exists?).with("/tmp/foo").and_return true - allow(::File).to receive(:exists?).with("//192.168.11.102/Share/backup").and_return true + allow(::File).to receive(:exist?).with("/etc/fstab").and_return false + allow(::File).to receive(:exist?).with("/dev/sdz1").and_return true + allow(::File).to receive(:exist?).with("/tmp/foo").and_return true + allow(::File).to receive(:exist?).with("//192.168.11.102/Share/backup").and_return true allow(::File).to receive(:realpath).with("/dev/sdz1").and_return "/dev/sdz1" allow(::File).to receive(:realpath).with("/tmp/foo").and_return "/tmp/foo" end diff --git a/spec/unit/provider/mount/mount_spec.rb b/spec/unit/provider/mount/mount_spec.rb index 9a7d9198b5..1985b52ca0 100644 --- a/spec/unit/provider/mount/mount_spec.rb +++ b/spec/unit/provider/mount/mount_spec.rb @@ -34,8 +34,8 @@ describe Chef::Provider::Mount::Mount do @provider = Chef::Provider::Mount::Mount.new(@new_resource, @run_context) - allow(::File).to receive(:exists?).with("/dev/sdz1").and_return true - allow(::File).to receive(:exists?).with("/tmp/foo").and_return true + allow(::File).to receive(:exist?).with("/dev/sdz1").and_return true + allow(::File).to receive(:exist?).with("/tmp/foo").and_return true allow(::File).to receive(:realpath).with("/dev/sdz1").and_return "/dev/sdz1" allow(::File).to receive(:realpath).with("/tmp/foo").and_return "/tmp/foo" end @@ -82,12 +82,12 @@ describe Chef::Provider::Mount::Mount do end it "should raise an error if the mount device does not exist" do - allow(::File).to receive(:exists?).with("/dev/sdz1").and_return false + allow(::File).to receive(:exist?).with("/dev/sdz1").and_return false expect { @provider.load_current_resource; @provider.mountable? }.to raise_error(Chef::Exceptions::Mount) end it "should not call mountable? with load_current_resource - CHEF-1565" do - allow(::File).to receive(:exists?).with("/dev/sdz1").and_return false + allow(::File).to receive(:exist?).with("/dev/sdz1").and_return false expect(@provider).to receive(:mounted?).and_return(true) expect(@provider).to receive(:enabled?).and_return(true) expect(@provider).not_to receive(:mountable?) @@ -99,12 +99,12 @@ describe Chef::Provider::Mount::Mount do @new_resource.device_type :uuid @new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a" expect(@provider).to receive(:shell_out_compacted).with("/sbin/findfs", "UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_return(status) - expect(::File).to receive(:exists?).with("").and_return(false) + expect(::File).to receive(:exist?).with("").and_return(false) expect { @provider.load_current_resource; @provider.mountable? }.to raise_error(Chef::Exceptions::Mount) end it "should raise an error if the mount point does not exist" do - allow(::File).to receive(:exists?).with("/tmp/foo").and_return false + allow(::File).to receive(:exist?).with("/tmp/foo").and_return false expect { @provider.load_current_resource; @provider.mountable? }.to raise_error(Chef::Exceptions::Mount) end diff --git a/spec/unit/provider/package/rpm_spec.rb b/spec/unit/provider/package/rpm_spec.rb index edf39b0f3f..d42e3061bc 100644 --- a/spec/unit/provider/package/rpm_spec.rb +++ b/spec/unit/provider/package/rpm_spec.rb @@ -41,7 +41,7 @@ describe Chef::Provider::Package::Rpm do let(:rpm_q_status) { instance_double("Mixlib::ShellOut", exitstatus: rpm_q_exitstatus, stdout: rpm_q_stdout) } before(:each) do - allow(::File).to receive(:exist?).with("PLEASE STUB File.exists? EXACTLY").and_return(true) + allow(::File).to receive(:exist?).with("PLEASE STUB File.exist? EXACTLY").and_return(true) # Ensure all shell out usage is stubbed with exact arguments allow(provider).to receive(:shell_out_compacted!).with("PLEASE STUB YOUR SHELLOUT CALLS").and_return(nil) diff --git a/spec/unit/provider/template_spec.rb b/spec/unit/provider/template_spec.rb index 84cbfc5d08..e6e251bc22 100644 --- a/spec/unit/provider/template_spec.rb +++ b/spec/unit/provider/template_spec.rb @@ -50,7 +50,7 @@ describe Chef::Provider::Template do let(:content) do content = double("Chef::Provider::File::Content::Template", template_location: "/foo/bar/baz") - allow(File).to receive(:exists?).with("/foo/bar/baz").and_return(true) + allow(File).to receive(:exist?).with("/foo/bar/baz").and_return(true) content end @@ -76,7 +76,7 @@ describe Chef::Provider::Template do it "stops executing when the local template source can't be found" do setup_normal_file allow(content).to receive(:template_location).and_return("/baz/bar/foo") - allow(File).to receive(:exists?).with("/baz/bar/foo").and_return(false) + allow(File).to receive(:exist?).with("/baz/bar/foo").and_return(false) expect { provider.run_action(:create) }.to raise_error Chef::Mixin::WhyRun::ResourceRequirements::Assertion::AssertionFailure end |