Use File.exist? instead of deprecated File.exists?
This commit is contained in:
parent
c0358cb7b4
commit
fec6b59950
|
@ -18,19 +18,19 @@ end
|
|||
|
||||
|
||||
Before do
|
||||
FileUtils.mkdir_p(TEST_DIR) unless File.exists?(TEST_DIR)
|
||||
FileUtils.mkdir_p(TEST_DIR) unless File.exist?(TEST_DIR)
|
||||
Dir.chdir(TEST_DIR)
|
||||
end
|
||||
|
||||
After do
|
||||
FileUtils.rm_rf(TEST_DIR) if File.exists?(TEST_DIR)
|
||||
FileUtils.rm_rf(TEST_DIR) if File.exist?(TEST_DIR)
|
||||
FileUtils.rm(JEKYLL_COMMAND_OUTPUT_FILE)
|
||||
end
|
||||
|
||||
World(Test::Unit::Assertions)
|
||||
|
||||
Given /^I have a blank site in "(.*)"$/ do |path|
|
||||
FileUtils.mkdir_p(path) unless File.exists?(path)
|
||||
FileUtils.mkdir_p(path) unless File.exist?(path)
|
||||
end
|
||||
|
||||
Given /^I do not have a "(.*)" directory$/ do |path|
|
||||
|
@ -190,7 +190,7 @@ Then /^the "(.*)" file should +exist$/ do |file|
|
|||
end
|
||||
|
||||
Then /^the "(.*)" file should not exist$/ do |file|
|
||||
assert !File.exists?(file), "The file \"#{file}\" exists"
|
||||
assert !File.exist?(file), "The file \"#{file}\" exists"
|
||||
end
|
||||
|
||||
Then /^I should see today's time in "(.*)"$/ do |file|
|
||||
|
|
|
@ -37,7 +37,7 @@ module Jekyll
|
|||
FileUtils.mkdir_p(destination)
|
||||
|
||||
# monkey patch WEBrick using custom 404 page (/404.html)
|
||||
if File.exists?(File.join(destination, '404.html'))
|
||||
if File.exist?(File.join(destination, '404.html'))
|
||||
WEBrick::HTTPResponse.class_eval do
|
||||
def create_error_page
|
||||
@body = IO.read(File.join(@config[:DocumentRoot], '404.html'))
|
||||
|
|
|
@ -33,7 +33,7 @@ module Jekyll
|
|||
end
|
||||
|
||||
def within(directory)
|
||||
return unless File.exists?(directory)
|
||||
return unless File.exist?(directory)
|
||||
Dir.chdir(directory) { yield }
|
||||
end
|
||||
|
||||
|
|
|
@ -333,7 +333,7 @@ module Jekyll
|
|||
# Returns the list of entries to process
|
||||
def get_entries(dir, subfolder)
|
||||
base = File.join(source, dir, subfolder)
|
||||
return [] unless File.exists?(base)
|
||||
return [] unless File.exist?(base)
|
||||
entries = Dir.chdir(base) { filter_entries(Dir['**/*'], base) }
|
||||
entries.delete_if { |e| File.directory?(File.join(base, e)) }
|
||||
end
|
||||
|
|
|
@ -39,7 +39,7 @@ JS
|
|||
end
|
||||
|
||||
should "write a JS file in place" do
|
||||
assert File.exists?(@test_coffeescript_file), "Can't find the converted CoffeeScript file in the dest_dir."
|
||||
assert File.exist?(@test_coffeescript_file), "Can't find the converted CoffeeScript file in the dest_dir."
|
||||
end
|
||||
|
||||
should "produce JS" do
|
||||
|
|
|
@ -33,7 +33,7 @@ class TestGeneratedSite < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
should "hide unpublished page" do
|
||||
assert !File.exists?(dest_dir('/unpublished.html'))
|
||||
assert !File.exist?(dest_dir('/unpublished.html'))
|
||||
end
|
||||
|
||||
should "not copy _posts directory" do
|
||||
|
@ -41,8 +41,8 @@ class TestGeneratedSite < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
should "process other static files and generate correct permalinks" do
|
||||
assert File.exists?(dest_dir('/about/index.html'))
|
||||
assert File.exists?(dest_dir('/contacts.html'))
|
||||
assert File.exist?(dest_dir('/about/index.html'))
|
||||
assert File.exist?(dest_dir('/contacts.html'))
|
||||
end
|
||||
|
||||
should "print a nice list of static files" do
|
||||
|
|
|
@ -24,9 +24,9 @@ class TestNewCommand < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
should 'create a new directory' do
|
||||
assert !File.exists?(@full_path)
|
||||
assert !File.exist?(@full_path)
|
||||
capture_stdout { Jekyll::Commands::New.process(@args) }
|
||||
assert File.exists?(@full_path)
|
||||
assert File.exist?(@full_path)
|
||||
end
|
||||
|
||||
should 'display a success message' do
|
||||
|
@ -83,9 +83,9 @@ class TestNewCommand < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
should 'create a new directory' do
|
||||
assert !File.exists?(@site_name_with_spaces)
|
||||
assert !File.exist?(@site_name_with_spaces)
|
||||
capture_stdout { Jekyll::Commands::New.process(@multiple_args) }
|
||||
assert File.exists?(@site_name_with_spaces)
|
||||
assert File.exist?(@site_name_with_spaces)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ class TestPage < Test::Unit::TestCase
|
|||
page.write(dest_dir)
|
||||
|
||||
assert File.directory?(dest_dir)
|
||||
assert File.exists?(File.join(dest_dir, 'contacts.html'))
|
||||
assert File.exist?(File.join(dest_dir, 'contacts.html'))
|
||||
end
|
||||
|
||||
should "write even when the folder name is plus and permalink has +" do
|
||||
|
@ -176,7 +176,7 @@ class TestPage < Test::Unit::TestCase
|
|||
page.write(dest_dir)
|
||||
|
||||
assert File.directory?(dest_dir)
|
||||
assert File.exists?(File.join(dest_dir, '+', 'plus+in+url'))
|
||||
assert File.exist?(File.join(dest_dir, '+', 'plus+in+url'))
|
||||
end
|
||||
|
||||
should "write even when permalink has '%# +'" do
|
||||
|
@ -185,7 +185,7 @@ class TestPage < Test::Unit::TestCase
|
|||
page.write(dest_dir)
|
||||
|
||||
assert File.directory?(dest_dir)
|
||||
assert File.exists?(File.join(dest_dir, '+', '%# +.html'))
|
||||
assert File.exist?(File.join(dest_dir, '+', '%# +.html'))
|
||||
end
|
||||
|
||||
should "write properly without html extension" do
|
||||
|
@ -195,7 +195,7 @@ class TestPage < Test::Unit::TestCase
|
|||
page.write(dest_dir)
|
||||
|
||||
assert File.directory?(dest_dir)
|
||||
assert File.exists?(File.join(dest_dir, 'contacts', 'index.html'))
|
||||
assert File.exist?(File.join(dest_dir, 'contacts', 'index.html'))
|
||||
end
|
||||
|
||||
should "write properly with extension different from html" do
|
||||
|
@ -207,7 +207,7 @@ class TestPage < Test::Unit::TestCase
|
|||
assert_equal("/sitemap.xml", page.url)
|
||||
assert_nil(page.url[/\.html$/])
|
||||
assert File.directory?(dest_dir)
|
||||
assert File.exists?(File.join(dest_dir,'sitemap.xml'))
|
||||
assert File.exist?(File.join(dest_dir,'sitemap.xml'))
|
||||
end
|
||||
|
||||
should "write dotfiles properly" do
|
||||
|
@ -216,7 +216,7 @@ class TestPage < Test::Unit::TestCase
|
|||
page.write(dest_dir)
|
||||
|
||||
assert File.directory?(dest_dir)
|
||||
assert File.exists?(File.join(dest_dir, '.htaccess'))
|
||||
assert File.exist?(File.join(dest_dir, '.htaccess'))
|
||||
end
|
||||
|
||||
context "in a directory hierarchy" do
|
||||
|
@ -226,7 +226,7 @@ class TestPage < Test::Unit::TestCase
|
|||
page.write(dest_dir)
|
||||
|
||||
assert File.directory?(dest_dir)
|
||||
assert File.exists?(File.join(dest_dir, 'contacts', 'index.html'))
|
||||
assert File.exist?(File.join(dest_dir, 'contacts', 'index.html'))
|
||||
end
|
||||
|
||||
should "write properly" do
|
||||
|
@ -235,7 +235,7 @@ class TestPage < Test::Unit::TestCase
|
|||
page.write(dest_dir)
|
||||
|
||||
assert File.directory?(dest_dir)
|
||||
assert File.exists?(File.join(dest_dir, 'contacts', 'bar.html'))
|
||||
assert File.exist?(File.join(dest_dir, 'contacts', 'bar.html'))
|
||||
end
|
||||
|
||||
should "write properly without html extension" do
|
||||
|
@ -245,7 +245,7 @@ class TestPage < Test::Unit::TestCase
|
|||
page.write(dest_dir)
|
||||
|
||||
assert File.directory?(dest_dir)
|
||||
assert File.exists?(File.join(dest_dir, 'contacts', 'bar', 'index.html'))
|
||||
assert File.exist?(File.join(dest_dir, 'contacts', 'bar', 'index.html'))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -537,7 +537,7 @@ class TestPost < Test::Unit::TestCase
|
|||
post.write(dest_dir)
|
||||
|
||||
assert File.directory?(dest_dir)
|
||||
assert File.exists?(File.join(dest_dir, '2008', '10', '18', 'foo-bar.html'))
|
||||
assert File.exist?(File.join(dest_dir, '2008', '10', '18', 'foo-bar.html'))
|
||||
end
|
||||
|
||||
should "write properly when url has hash" do
|
||||
|
@ -546,7 +546,7 @@ class TestPost < Test::Unit::TestCase
|
|||
post.write(dest_dir)
|
||||
|
||||
assert File.directory?(dest_dir)
|
||||
assert File.exists?(File.join(dest_dir, '2009', '03', '12',
|
||||
assert File.exist?(File.join(dest_dir, '2009', '03', '12',
|
||||
'hash-#1.html'))
|
||||
end
|
||||
|
||||
|
@ -556,7 +556,7 @@ class TestPost < Test::Unit::TestCase
|
|||
post.write(dest_dir)
|
||||
|
||||
assert File.directory?(dest_dir)
|
||||
assert File.exists?(File.join(dest_dir, '2014', '03', '22',
|
||||
assert File.exist?(File.join(dest_dir, '2014', '03', '22',
|
||||
'escape-+ %20[].html'))
|
||||
end
|
||||
|
||||
|
@ -567,7 +567,7 @@ class TestPost < Test::Unit::TestCase
|
|||
post.write(dest_dir)
|
||||
|
||||
assert File.directory?(dest_dir)
|
||||
assert File.exists?(File.join(dest_dir, 'foo-bar', 'index.html'))
|
||||
assert File.exist?(File.join(dest_dir, 'foo-bar', 'index.html'))
|
||||
end
|
||||
|
||||
should "insert data" do
|
||||
|
|
Loading…
Reference in New Issue