Rubocop: test/test_regenerator.rb

This commit is contained in:
Pat Hawks 2016-05-25 22:00:29 -05:00
parent 474fc0a9a8
commit 98262b73d5
1 changed files with 12 additions and 13 deletions

View File

@ -1,4 +1,4 @@
require 'helper'
require "helper"
class TestRegenerator < JekyllUnitTest
context "The site regenerator" do
@ -39,11 +39,10 @@ class TestRegenerator < JekyllUnitTest
# we need to create the destinations for these files,
# because regenerate? checks if the destination exists
[@page, @post, @document, @asset_file].each do |item|
if item.respond_to?(:destination)
dest = item.destination(@site.dest)
FileUtils.mkdir_p(File.dirname(dest))
FileUtils.touch(dest)
end
next unless item.respond_to?(:destination)
dest = item.destination(@site.dest)
FileUtils.mkdir_p(File.dirname(dest))
FileUtils.touch(dest)
end
@regenerator.write_metadata
@regenerator = Regenerator.new(@site)
@ -69,7 +68,7 @@ class TestRegenerator < JekyllUnitTest
[@page, @post, @document, @asset_file].each do |item|
if item.respond_to?(:destination)
dest = item.destination(@site.dest)
File.unlink(dest) unless !File.exist?(dest)
File.unlink(dest) if File.exist?(dest)
end
end
@ -128,7 +127,7 @@ class TestRegenerator < JekyllUnitTest
FileUtils.rm_rf(source_dir(".jekyll-metadata"))
@site = Site.new(Jekyll.configuration({
"source" => source_dir,
"source" => source_dir,
"destination" => dest_dir,
"incremental" => true
}))
@ -152,7 +151,7 @@ class TestRegenerator < JekyllUnitTest
assert @regenerator.cache[@path]
@regenerator.clear_cache
assert_equal @regenerator.cache, {}
assert_equal @regenerator.cache, {}
end
should "write to the metadata file" do
@ -171,7 +170,7 @@ class TestRegenerator < JekyllUnitTest
metadata_file = source_dir(".jekyll-metadata")
@regenerator = Regenerator.new(@site)
File.open(metadata_file, 'w') do |f|
File.open(metadata_file, "w") do |f|
f.write(@regenerator.metadata.to_yaml)
end
@ -182,7 +181,7 @@ class TestRegenerator < JekyllUnitTest
should "not crash when reading corrupted marshal file" do
metadata_file = source_dir(".jekyll-metadata")
File.open(metadata_file, "w") do |file|
file.puts Marshal.dump({ foo: 'bar' })[0,5]
file.puts Marshal.dump({ :foo => "bar" })[0, 5]
end
@regenerator = Regenerator.new(@site)
@ -282,7 +281,7 @@ class TestRegenerator < JekyllUnitTest
end
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
assert @regenerator.metadata[multi_dep_path]["deps"].length > 2
@ -310,7 +309,7 @@ class TestRegenerator < JekyllUnitTest
setup do
FileUtils.rm_rf(source_dir(".jekyll-metadata"))
@site = Site.new(Jekyll.configuration({
"source" => source_dir,
"source" => source_dir,
"destination" => dest_dir,
"incremental" => false
}))