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