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