Commit 955db222 by Joost Baaij Committed by Jon Yurek

replace File.exists? with File.exist?

File.exists? has been deprecated since Ruby 1.9.2
parent aa0aec29
......@@ -35,7 +35,7 @@ end
Then /^the attachment "([^"]*)" should exist$/ do |filename|
in_current_dir do
File.exists?(attachment_path(filename)).should be
File.exist?(attachment_path(filename)).should be
end
end
......
......@@ -197,7 +197,7 @@ Given /^I am using Rails newer than ([\d\.]+)$/ do |version|
end
def transform_file(filename)
if File.exists?(filename)
if File.exist?(filename)
content = File.read(filename)
File.open(filename, "w") do |f|
content = yield(content)
......
......@@ -40,7 +40,7 @@ module Paperclip
private
def empty_file?
File.exists?(@filename) && File.size(@filename) == 0
File.exist?(@filename) && File.size(@filename) == 0
end
alias :empty? :empty_file?
......
......@@ -69,7 +69,7 @@ module Paperclip
while(true)
path = File.dirname(path)
FileUtils.rmdir(path)
break if File.exists?(path) # Ruby 1.9.2 does not raise if the removal failed.
break if File.exist?(path) # Ruby 1.9.2 does not raise if the removal failed.
end
rescue Errno::EEXIST, Errno::ENOTEMPTY, Errno::ENOENT, Errno::EINVAL, Errno::ENOTDIR, Errno::EACCES
# Stop trying to remove parent directories
......
......@@ -81,7 +81,7 @@ describe 'Paperclip' do
context "Attachment" do
before do
@thumb_path = "tmp/public/system/dummies/avatars/000/000/001/thumb/5k.png"
File.delete(@thumb_path) if File.exists?(@thumb_path)
File.delete(@thumb_path) if File.exist?(@thumb_path)
rebuild_model styles: { thumb: "50x50#" }
@dummy = Dummy.new
@file = File.new(fixture_file("5k.png"), 'rb')
......@@ -109,8 +109,8 @@ describe 'Paperclip' do
before do
@thumb_small_path = "tmp/public/system/dummies/avatars/000/000/001/thumb_small/5k.png"
@thumb_large_path = "tmp/public/system/dummies/avatars/000/000/001/thumb_large/5k.png"
File.delete(@thumb_small_path) if File.exists?(@thumb_small_path)
File.delete(@thumb_large_path) if File.exists?(@thumb_large_path)
File.delete(@thumb_small_path) if File.exist?(@thumb_small_path)
File.delete(@thumb_large_path) if File.exist?(@thumb_large_path)
rebuild_model styles: { thumb_small: "50x50#", thumb_large: "60x60#" }
@dummy = Dummy.new
@file = File.new(fixture_file("5k.png"), 'rb')
......
......@@ -38,7 +38,7 @@ describe Paperclip::Storage::Filesystem do
it "is removed after after_flush_writes" do
paths = @dummy.avatar.queued_for_write.values.map(&:path)
@dummy.save
assert paths.none?{ |path| File.exists?(path) },
assert paths.none?{ |path| File.exist?(path) },
"Expect all the files to be deleted."
end
......
......@@ -167,7 +167,7 @@ describe Paperclip::Storage::Fog do
it "is removed after after_flush_writes" do
paths = @dummy.avatar.queued_for_write.values.map(&:path)
@dummy.save
assert paths.none?{ |path| File.exists?(path) },
assert paths.none?{ |path| File.exist?(path) },
"Expect all the files to be deleted."
end
......
......@@ -691,7 +691,7 @@ describe Paperclip::Storage::S3 do
@dummy.avatar.stubs(:s3_object).returns(stub(write: true))
paths = @dummy.avatar.queued_for_write.values.map(&:path)
@dummy.save
assert paths.none?{ |path| File.exists?(path) },
assert paths.none?{ |path| File.exist?(path) },
"Expect all the files to be deleted."
end
......
......@@ -24,6 +24,6 @@ describe Paperclip::TempfileFactory do
it 'is able to take nothing as a parameter and not error' do
file = subject.generate
assert File.exists?(file.path)
assert File.exist?(file.path)
end
end
RSpec::Matchers.define :exist do |expected|
match do |actual|
File.exists?(actual)
File.exist?(actual)
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment