diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-08-11 13:30:10 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-08-12 14:02:34 -0700 |
commit | 4848c89b7cc5e4a4d4fac7c8bff962f7df69f719 (patch) | |
tree | cf1bc6d0b30f226573da88158049f1334b6ce1bd /spec/unit | |
parent | 798cac61accc035b51aaac25160bf1d5e9715252 (diff) | |
download | chef-4848c89b7cc5e4a4d4fac7c8bff962f7df69f719.tar.gz |
File.exists? -> File.exist?exist
Update some of these methods
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'spec/unit')
-rw-r--r-- | spec/unit/environment_spec.rb | 14 | ||||
-rw-r--r-- | spec/unit/knife/bootstrap_spec.rb | 28 | ||||
-rw-r--r-- | spec/unit/knife/cookbook_download_spec.rb | 8 | ||||
-rw-r--r-- | spec/unit/knife/cookbook_metadata_from_file_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/knife/core/hashed_command_loader_spec.rb | 6 | ||||
-rw-r--r-- | spec/unit/knife/supermarket_share_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/provider/service/arch_service_spec.rb | 5 | ||||
-rw-r--r-- | spec/unit/provider/service/debian_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/provider/service/gentoo_service_spec.rb | 14 | ||||
-rw-r--r-- | spec/unit/provider/service/macosx_spec.rb | 6 | ||||
-rw-r--r-- | spec/unit/provider/service/redhat_spec.rb | 4 | ||||
-rw-r--r-- | spec/unit/provider/service/upstart_service_spec.rb | 6 | ||||
-rw-r--r-- | spec/unit/role_spec.rb | 22 |
13 files changed, 60 insertions, 59 deletions
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) |