Rubocop: test/test_regenerator.rb
This commit is contained in:
parent
474fc0a9a8
commit
98262b73d5
|
@ -1,4 +1,4 @@
|
||||||
require 'helper'
|
require "helper"
|
||||||
|
|
||||||
class TestRegenerator < JekyllUnitTest
|
class TestRegenerator < JekyllUnitTest
|
||||||
context "The site regenerator" do
|
context "The site regenerator" do
|
||||||
|
@ -39,11 +39,10 @@ class TestRegenerator < JekyllUnitTest
|
||||||
# we need to create the destinations for these files,
|
# we need to create the destinations for these files,
|
||||||
# because regenerate? checks if the destination exists
|
# because regenerate? checks if the destination exists
|
||||||
[@page, @post, @document, @asset_file].each do |item|
|
[@page, @post, @document, @asset_file].each do |item|
|
||||||
if item.respond_to?(:destination)
|
next unless item.respond_to?(:destination)
|
||||||
dest = item.destination(@site.dest)
|
dest = item.destination(@site.dest)
|
||||||
FileUtils.mkdir_p(File.dirname(dest))
|
FileUtils.mkdir_p(File.dirname(dest))
|
||||||
FileUtils.touch(dest)
|
FileUtils.touch(dest)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
@regenerator.write_metadata
|
@regenerator.write_metadata
|
||||||
@regenerator = Regenerator.new(@site)
|
@regenerator = Regenerator.new(@site)
|
||||||
|
@ -69,7 +68,7 @@ class TestRegenerator < JekyllUnitTest
|
||||||
[@page, @post, @document, @asset_file].each do |item|
|
[@page, @post, @document, @asset_file].each do |item|
|
||||||
if item.respond_to?(:destination)
|
if item.respond_to?(:destination)
|
||||||
dest = item.destination(@site.dest)
|
dest = item.destination(@site.dest)
|
||||||
File.unlink(dest) unless !File.exist?(dest)
|
File.unlink(dest) if File.exist?(dest)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -128,7 +127,7 @@ class TestRegenerator < JekyllUnitTest
|
||||||
FileUtils.rm_rf(source_dir(".jekyll-metadata"))
|
FileUtils.rm_rf(source_dir(".jekyll-metadata"))
|
||||||
|
|
||||||
@site = Site.new(Jekyll.configuration({
|
@site = Site.new(Jekyll.configuration({
|
||||||
"source" => source_dir,
|
"source" => source_dir,
|
||||||
"destination" => dest_dir,
|
"destination" => dest_dir,
|
||||||
"incremental" => true
|
"incremental" => true
|
||||||
}))
|
}))
|
||||||
|
@ -152,7 +151,7 @@ class TestRegenerator < JekyllUnitTest
|
||||||
assert @regenerator.cache[@path]
|
assert @regenerator.cache[@path]
|
||||||
|
|
||||||
@regenerator.clear_cache
|
@regenerator.clear_cache
|
||||||
assert_equal @regenerator.cache, {}
|
assert_equal @regenerator.cache, {}
|
||||||
end
|
end
|
||||||
|
|
||||||
should "write to the metadata file" do
|
should "write to the metadata file" do
|
||||||
|
@ -171,7 +170,7 @@ class TestRegenerator < JekyllUnitTest
|
||||||
metadata_file = source_dir(".jekyll-metadata")
|
metadata_file = source_dir(".jekyll-metadata")
|
||||||
@regenerator = Regenerator.new(@site)
|
@regenerator = Regenerator.new(@site)
|
||||||
|
|
||||||
File.open(metadata_file, 'w') do |f|
|
File.open(metadata_file, "w") do |f|
|
||||||
f.write(@regenerator.metadata.to_yaml)
|
f.write(@regenerator.metadata.to_yaml)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -182,7 +181,7 @@ class TestRegenerator < JekyllUnitTest
|
||||||
should "not crash when reading corrupted marshal file" do
|
should "not crash when reading corrupted marshal file" do
|
||||||
metadata_file = source_dir(".jekyll-metadata")
|
metadata_file = source_dir(".jekyll-metadata")
|
||||||
File.open(metadata_file, "w") do |file|
|
File.open(metadata_file, "w") do |file|
|
||||||
file.puts Marshal.dump({ foo: 'bar' })[0,5]
|
file.puts Marshal.dump({ :foo => "bar" })[0, 5]
|
||||||
end
|
end
|
||||||
|
|
||||||
@regenerator = Regenerator.new(@site)
|
@regenerator = Regenerator.new(@site)
|
||||||
|
@ -282,7 +281,7 @@ class TestRegenerator < JekyllUnitTest
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not regenerate again if multiple dependencies" do
|
should "not regenerate again if multiple dependencies" do
|
||||||
multi_deps = @regenerator.metadata.select {|k,v| v['deps'].length > 2}
|
multi_deps = @regenerator.metadata.select { |_k, v| v["deps"].length > 2 }
|
||||||
multi_dep_path = multi_deps.keys.first
|
multi_dep_path = multi_deps.keys.first
|
||||||
|
|
||||||
assert @regenerator.metadata[multi_dep_path]["deps"].length > 2
|
assert @regenerator.metadata[multi_dep_path]["deps"].length > 2
|
||||||
|
@ -310,7 +309,7 @@ class TestRegenerator < JekyllUnitTest
|
||||||
setup do
|
setup do
|
||||||
FileUtils.rm_rf(source_dir(".jekyll-metadata"))
|
FileUtils.rm_rf(source_dir(".jekyll-metadata"))
|
||||||
@site = Site.new(Jekyll.configuration({
|
@site = Site.new(Jekyll.configuration({
|
||||||
"source" => source_dir,
|
"source" => source_dir,
|
||||||
"destination" => dest_dir,
|
"destination" => dest_dir,
|
||||||
"incremental" => false
|
"incremental" => false
|
||||||
}))
|
}))
|
||||||
|
|
Loading…
Reference in New Issue