Skip to content

Commit

Permalink
Replace Dir.exists?/File.exists? with Dir.exist?/File.exist?
Browse files Browse the repository at this point in the history
`Dir.exists?` and `File.exists?` removed from Ruby 3.2.0
https://www.ruby-lang.org/en/news/2022/12/25/ruby-3-2-0-released/
  • Loading branch information
chaaaaarlotte committed Dec 28, 2022
1 parent 69e5746 commit d75dbb4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ install:

build_script:
- set SSL_CERT_FILE=C:/ruby24-x64/ssl/cert.pem
- ruby -rfileutils -e 'FileUtils.rm_r(File.join(Gem.dir, "cache", "bundler")) if Dir.exists?(File.join(Gem.dir, "cache", "bundler"))'
- ruby -rfileutils -e 'FileUtils.rm_r(File.join(Gem.dir, "cache", "bundler")) if Dir.exist?(File.join(Gem.dir, "cache", "bundler"))'
- bundle install --jobs 3 --retry 3
- net user
- net localgroup
Expand Down
12 changes: 6 additions & 6 deletions lib/serverspec/setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def self.safe_create_spec
end
EOF

if File.exists? "spec/#{@hostname}/sample_spec.rb"
if File.exist? "spec/#{@hostname}/sample_spec.rb"
old_content = File.read("spec/#{@hostname}/sample_spec.rb")
if old_content != content
$stderr.puts "!! spec/#{@hostname}/sample_spec.rb already exists and differs from template"
Expand All @@ -141,7 +141,7 @@ def self.safe_create_spec
end

def self.safe_mkdir(dir)
if File.exists? dir
if File.exist? dir
unless File.directory? dir
$stderr.puts "!! #{dir} already exists and is not a directory"
end
Expand All @@ -153,7 +153,7 @@ def self.safe_mkdir(dir)

def self.safe_create_spec_helper
content = ERB.new(spec_helper_template, nil, '-').result(binding)
if File.exists? 'spec/spec_helper.rb'
if File.exist? 'spec/spec_helper.rb'
old_content = File.read('spec/spec_helper.rb')
if old_content != content
$stderr.puts "!! spec/spec_helper.rb already exists and differs from template"
Expand Down Expand Up @@ -196,7 +196,7 @@ def self.safe_create_rakefile
end
end
EOF
if File.exists? 'Rakefile'
if File.exist? 'Rakefile'
old_content = File.read('Rakefile')
if old_content != content
$stderr.puts '!! Rakefile already exists and differs from template'
Expand All @@ -212,7 +212,7 @@ def self.safe_create_rakefile
def self.find_vagrantfile
Pathname.new(Dir.pwd).ascend do |dir|
path = File.expand_path('Vagrantfile', dir)
return path if File.exists?(path)
return path if File.exist?(path)
end
nil
end
Expand Down Expand Up @@ -334,7 +334,7 @@ def self.safe_create_dotrspec
--color
--format documentation
EOF
if File.exists? '.rspec'
if File.exist? '.rspec'
old_content = File.read('.rspec')
if old_content != content
$stderr.puts '!! .rspec already exists and differs from template'
Expand Down

0 comments on commit d75dbb4

Please sign in to comment.