Rubocop: test/test_site.rb
This commit is contained in:
parent
5a23b130ce
commit
fbff506faa
|
@ -1,45 +1,47 @@
|
||||||
require 'helper'
|
require "helper"
|
||||||
|
|
||||||
class TestSite < JekyllUnitTest
|
class TestSite < JekyllUnitTest
|
||||||
context "configuring sites" do
|
context "configuring sites" do
|
||||||
should "have an array for plugins by default" do
|
should "have an array for plugins by default" do
|
||||||
site = Site.new default_configuration
|
site = Site.new default_configuration
|
||||||
assert_equal [File.join(Dir.pwd, '_plugins')], site.plugins
|
assert_equal [File.join(Dir.pwd, "_plugins")], site.plugins
|
||||||
end
|
end
|
||||||
|
|
||||||
should "look for plugins under the site directory by default" do
|
should "look for plugins under the site directory by default" do
|
||||||
site = Site.new(site_configuration)
|
site = Site.new(site_configuration)
|
||||||
assert_equal [source_dir('_plugins')], site.plugins
|
assert_equal [source_dir("_plugins")], site.plugins
|
||||||
end
|
end
|
||||||
|
|
||||||
should "have an array for plugins if passed as a string" do
|
should "have an array for plugins if passed as a string" do
|
||||||
site = Site.new(site_configuration({ 'plugins_dir' => '/tmp/plugins' }))
|
site = Site.new(site_configuration({ "plugins_dir" => "/tmp/plugins" }))
|
||||||
assert_equal ['/tmp/plugins'], site.plugins
|
assert_equal ["/tmp/plugins"], site.plugins
|
||||||
end
|
end
|
||||||
|
|
||||||
should "have an array for plugins if passed as an array" do
|
should "have an array for plugins if passed as an array" do
|
||||||
site = Site.new(site_configuration({ 'plugins_dir' => ['/tmp/plugins', '/tmp/otherplugins'] }))
|
site = Site.new(site_configuration({
|
||||||
assert_equal ['/tmp/plugins', '/tmp/otherplugins'], site.plugins
|
"plugins_dir" => ["/tmp/plugins", "/tmp/otherplugins"]
|
||||||
|
}))
|
||||||
|
assert_equal ["/tmp/plugins", "/tmp/otherplugins"], site.plugins
|
||||||
end
|
end
|
||||||
|
|
||||||
should "have an empty array for plugins if nothing is passed" do
|
should "have an empty array for plugins if nothing is passed" do
|
||||||
site = Site.new(site_configuration({ 'plugins_dir' => [] }))
|
site = Site.new(site_configuration({ "plugins_dir" => [] }))
|
||||||
assert_equal [], site.plugins
|
assert_equal [], site.plugins
|
||||||
end
|
end
|
||||||
|
|
||||||
should "have the default for plugins if nil is passed" do
|
should "have the default for plugins if nil is passed" do
|
||||||
site = Site.new(site_configuration({ 'plugins_dir' => nil }))
|
site = Site.new(site_configuration({ "plugins_dir" => nil }))
|
||||||
assert_equal [source_dir('_plugins')], site.plugins
|
assert_equal [source_dir("_plugins")], site.plugins
|
||||||
end
|
end
|
||||||
|
|
||||||
should "expose default baseurl" do
|
should "expose default baseurl" do
|
||||||
site = Site.new(default_configuration)
|
site = Site.new(default_configuration)
|
||||||
assert_equal Jekyll::Configuration::DEFAULTS['baseurl'], site.baseurl
|
assert_equal Jekyll::Configuration::DEFAULTS["baseurl"], site.baseurl
|
||||||
end
|
end
|
||||||
|
|
||||||
should "expose baseurl passed in from config" do
|
should "expose baseurl passed in from config" do
|
||||||
site = Site.new(site_configuration({ 'baseurl' => '/blog' }))
|
site = Site.new(site_configuration({ "baseurl" => "/blog" }))
|
||||||
assert_equal '/blog', site.baseurl
|
assert_equal "/blog", site.baseurl
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
context "creating sites" do
|
context "creating sites" do
|
||||||
|
@ -55,7 +57,7 @@ class TestSite < JekyllUnitTest
|
||||||
end
|
end
|
||||||
|
|
||||||
should "have an empty tag hash by default" do
|
should "have an empty tag hash by default" do
|
||||||
assert_equal Hash.new, @site.tags
|
assert_equal({}, @site.tags)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "give site with parsed pages and posts to generators" do
|
should "give site with parsed pages and posts to generators" do
|
||||||
|
@ -65,14 +67,14 @@ class TestSite < JekyllUnitTest
|
||||||
raise "#{page} isn't a page" unless page.is_a?(Page)
|
raise "#{page} isn't a page" unless page.is_a?(Page)
|
||||||
raise "#{page} doesn't respond to :name" unless page.respond_to?(:name)
|
raise "#{page} doesn't respond to :name" unless page.respond_to?(:name)
|
||||||
end
|
end
|
||||||
site.file_read_opts[:secret_message] = 'hi'
|
site.file_read_opts[:secret_message] = "hi"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@site = Site.new(site_configuration)
|
@site = Site.new(site_configuration)
|
||||||
@site.read
|
@site.read
|
||||||
@site.generate
|
@site.generate
|
||||||
refute_equal 0, @site.pages.size
|
refute_equal 0, @site.pages.size
|
||||||
assert_equal 'hi', @site.file_read_opts[:secret_message]
|
assert_equal "hi", @site.file_read_opts[:secret_message]
|
||||||
end
|
end
|
||||||
|
|
||||||
should "reset data before processing" do
|
should "reset data before processing" do
|
||||||
|
@ -157,13 +159,21 @@ class TestSite < JekyllUnitTest
|
||||||
end
|
end
|
||||||
|
|
||||||
should "setup plugins in priority order" do
|
should "setup plugins in priority order" do
|
||||||
assert_equal @site.converters.sort_by(&:class).map{|c|c.class.priority}, @site.converters.map{|c|c.class.priority}
|
assert_equal(
|
||||||
assert_equal @site.generators.sort_by(&:class).map{|g|g.class.priority}, @site.generators.map{|g|g.class.priority}
|
@site.converters.sort_by(&:class).map { |c| c.class.priority },
|
||||||
|
@site.converters.map { |c| c.class.priority }
|
||||||
|
)
|
||||||
|
assert_equal(
|
||||||
|
@site.generators.sort_by(&:class).map { |g| g.class.priority },
|
||||||
|
@site.generators.map { |g| g.class.priority }
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "sort pages alphabetically" do
|
should "sort pages alphabetically" do
|
||||||
method = Dir.method(:entries)
|
method = Dir.method(:entries)
|
||||||
allow(Dir).to receive(:entries) { |*args, &block| method.call(*args, &block).reverse }
|
allow(Dir).to receive(:entries) do |*args, &block|
|
||||||
|
method.call(*args, &block).reverse
|
||||||
|
end
|
||||||
@site.process
|
@site.process
|
||||||
# files in symlinked directories may appear twice
|
# files in symlinked directories may appear twice
|
||||||
sorted_pages = %w(
|
sorted_pages = %w(
|
||||||
|
@ -192,9 +202,11 @@ class TestSite < JekyllUnitTest
|
||||||
end
|
end
|
||||||
|
|
||||||
should "read posts" do
|
should "read posts" do
|
||||||
@site.posts.docs.concat(PostReader.new(@site).read_posts(''))
|
@site.posts.docs.concat(PostReader.new(@site).read_posts(""))
|
||||||
posts = Dir[source_dir('_posts', '**', '*')]
|
posts = Dir[source_dir("_posts", "**", "*")]
|
||||||
posts.delete_if { |post| File.directory?(post) && !(post =~ Document::DATE_FILENAME_MATCHER) }
|
posts.delete_if do |post|
|
||||||
|
File.directory?(post) && !(post =~ Document::DATE_FILENAME_MATCHER)
|
||||||
|
end
|
||||||
assert_equal posts.size - @num_invalid_posts, @site.posts.size
|
assert_equal posts.size - @num_invalid_posts, @site.posts.size
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -209,11 +221,11 @@ class TestSite < JekyllUnitTest
|
||||||
end
|
end
|
||||||
|
|
||||||
should "expose jekyll version to site payload" do
|
should "expose jekyll version to site payload" do
|
||||||
assert_equal Jekyll::VERSION, @site.site_payload['jekyll']['version']
|
assert_equal Jekyll::VERSION, @site.site_payload["jekyll"]["version"]
|
||||||
end
|
end
|
||||||
|
|
||||||
should "expose list of static files to site payload" do
|
should "expose list of static files to site payload" do
|
||||||
assert_equal @site.static_files, @site.site_payload['site']['static_files']
|
assert_equal @site.static_files, @site.site_payload["site"]["static_files"]
|
||||||
end
|
end
|
||||||
|
|
||||||
should "deploy payload" do
|
should "deploy payload" do
|
||||||
|
@ -221,118 +233,125 @@ class TestSite < JekyllUnitTest
|
||||||
@site.process
|
@site.process
|
||||||
|
|
||||||
posts = Dir[source_dir("**", "_posts", "**", "*")]
|
posts = Dir[source_dir("**", "_posts", "**", "*")]
|
||||||
posts.delete_if { |post| File.directory?(post) && !(post =~ Document::DATE_FILENAME_MATCHER) }
|
posts.delete_if do |post|
|
||||||
categories = %w(2013 bar baz category foo z_category MixedCase Mixedcase publish_test win).sort
|
File.directory?(post) && !(post =~ Document::DATE_FILENAME_MATCHER)
|
||||||
|
end
|
||||||
|
categories = %w(
|
||||||
|
2013 bar baz category foo z_category MixedCase Mixedcase publish_test win
|
||||||
|
).sort
|
||||||
|
|
||||||
assert_equal posts.size - @num_invalid_posts, @site.posts.size
|
assert_equal posts.size - @num_invalid_posts, @site.posts.size
|
||||||
assert_equal categories, @site.categories.keys.sort
|
assert_equal categories, @site.categories.keys.sort
|
||||||
assert_equal 5, @site.categories['foo'].size
|
assert_equal 5, @site.categories["foo"].size
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'error handling' do
|
context "error handling" do
|
||||||
should "raise if destination is included in source" do
|
should "raise if destination is included in source" do
|
||||||
assert_raises Jekyll::Errors::FatalException do
|
assert_raises Jekyll::Errors::FatalException do
|
||||||
Site.new(site_configuration('destination' => source_dir))
|
Site.new(site_configuration("destination" => source_dir))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
should "raise if destination is source" do
|
should "raise if destination is source" do
|
||||||
assert_raises Jekyll::Errors::FatalException do
|
assert_raises Jekyll::Errors::FatalException do
|
||||||
Site.new(site_configuration('destination' => File.join(source_dir, "..")))
|
Site.new(site_configuration("destination" => File.join(source_dir, "..")))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with orphaned files in destination' do
|
context "with orphaned files in destination" do
|
||||||
setup do
|
setup do
|
||||||
clear_dest
|
clear_dest
|
||||||
@site.regenerator.clear
|
@site.regenerator.clear
|
||||||
@site.process
|
@site.process
|
||||||
# generate some orphaned files:
|
# generate some orphaned files:
|
||||||
# single file
|
# single file
|
||||||
File.open(dest_dir('obsolete.html'), 'w')
|
File.open(dest_dir("obsolete.html"), "w")
|
||||||
# single file in sub directory
|
# single file in sub directory
|
||||||
FileUtils.mkdir(dest_dir('qux'))
|
FileUtils.mkdir(dest_dir("qux"))
|
||||||
File.open(dest_dir('qux/obsolete.html'), 'w')
|
File.open(dest_dir("qux/obsolete.html"), "w")
|
||||||
# empty directory
|
# empty directory
|
||||||
FileUtils.mkdir(dest_dir('quux'))
|
FileUtils.mkdir(dest_dir("quux"))
|
||||||
FileUtils.mkdir(dest_dir('.git'))
|
FileUtils.mkdir(dest_dir(".git"))
|
||||||
FileUtils.mkdir(dest_dir('.svn'))
|
FileUtils.mkdir(dest_dir(".svn"))
|
||||||
FileUtils.mkdir(dest_dir('.hg'))
|
FileUtils.mkdir(dest_dir(".hg"))
|
||||||
# single file in repository
|
# single file in repository
|
||||||
File.open(dest_dir('.git/HEAD'), 'w')
|
File.open(dest_dir(".git/HEAD"), "w")
|
||||||
File.open(dest_dir('.svn/HEAD'), 'w')
|
File.open(dest_dir(".svn/HEAD"), "w")
|
||||||
File.open(dest_dir('.hg/HEAD'), 'w')
|
File.open(dest_dir(".hg/HEAD"), "w")
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
FileUtils.rm_f(dest_dir('obsolete.html'))
|
FileUtils.rm_f(dest_dir("obsolete.html"))
|
||||||
FileUtils.rm_rf(dest_dir('qux'))
|
FileUtils.rm_rf(dest_dir("qux"))
|
||||||
FileUtils.rm_f(dest_dir('quux'))
|
FileUtils.rm_f(dest_dir("quux"))
|
||||||
FileUtils.rm_rf(dest_dir('.git'))
|
FileUtils.rm_rf(dest_dir(".git"))
|
||||||
FileUtils.rm_rf(dest_dir('.svn'))
|
FileUtils.rm_rf(dest_dir(".svn"))
|
||||||
FileUtils.rm_rf(dest_dir('.hg'))
|
FileUtils.rm_rf(dest_dir(".hg"))
|
||||||
end
|
end
|
||||||
|
|
||||||
should 'remove orphaned files in destination' do
|
should "remove orphaned files in destination" do
|
||||||
@site.process
|
@site.process
|
||||||
refute_exist dest_dir('obsolete.html')
|
refute_exist dest_dir("obsolete.html")
|
||||||
refute_exist dest_dir('qux')
|
refute_exist dest_dir("qux")
|
||||||
refute_exist dest_dir('quux')
|
refute_exist dest_dir("quux")
|
||||||
assert_exist dest_dir('.git')
|
assert_exist dest_dir(".git")
|
||||||
assert_exist dest_dir('.git', 'HEAD')
|
assert_exist dest_dir(".git", "HEAD")
|
||||||
end
|
end
|
||||||
|
|
||||||
should 'remove orphaned files in destination - keep_files .svn' do
|
should "remove orphaned files in destination - keep_files .svn" do
|
||||||
config = site_configuration('keep_files' => %w{.svn})
|
config = site_configuration("keep_files" => %w(.svn))
|
||||||
@site = Site.new(config)
|
@site = Site.new(config)
|
||||||
@site.process
|
@site.process
|
||||||
refute_exist dest_dir('.htpasswd')
|
refute_exist dest_dir(".htpasswd")
|
||||||
refute_exist dest_dir('obsolete.html')
|
refute_exist dest_dir("obsolete.html")
|
||||||
refute_exist dest_dir('qux')
|
refute_exist dest_dir("qux")
|
||||||
refute_exist dest_dir('quux')
|
refute_exist dest_dir("quux")
|
||||||
refute_exist dest_dir('.git')
|
refute_exist dest_dir(".git")
|
||||||
refute_exist dest_dir('.git', 'HEAD')
|
refute_exist dest_dir(".git", "HEAD")
|
||||||
assert_exist dest_dir('.svn')
|
assert_exist dest_dir(".svn")
|
||||||
assert_exist dest_dir('.svn', 'HEAD')
|
assert_exist dest_dir(".svn", "HEAD")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'using a non-default markdown processor in the configuration' do
|
context "using a non-default markdown processor in the configuration" do
|
||||||
should 'use the non-default markdown processor' do
|
should "use the non-default markdown processor" do
|
||||||
class Jekyll::Converters::Markdown::CustomMarkdown
|
class Jekyll::Converters::Markdown::CustomMarkdown
|
||||||
def initialize(*args)
|
def initialize(*args)
|
||||||
@args = args
|
@args = args
|
||||||
end
|
end
|
||||||
|
|
||||||
def convert(*args)
|
def convert(*_args)
|
||||||
""
|
""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
custom_processor = "CustomMarkdown"
|
custom_processor = "CustomMarkdown"
|
||||||
s = Site.new(site_configuration('markdown' => custom_processor))
|
s = Site.new(site_configuration("markdown" => custom_processor))
|
||||||
s.process
|
s.process
|
||||||
|
|
||||||
# Do some cleanup, we don't like straggling stuff's.
|
# Do some cleanup, we don't like straggling stuff's.
|
||||||
Jekyll::Converters::Markdown.send(:remove_const, :CustomMarkdown)
|
Jekyll::Converters::Markdown.send(:remove_const, :CustomMarkdown)
|
||||||
end
|
end
|
||||||
|
|
||||||
should 'ignore, if there are any bad characters in the class name' do
|
should "ignore, if there are any bad characters in the class name" do
|
||||||
module Jekyll::Converters::Markdown::Custom
|
module Jekyll::Converters::Markdown::Custom
|
||||||
class Markdown
|
class Markdown
|
||||||
def initialize(*args)
|
def initialize(*args)
|
||||||
@args = args
|
@args = args
|
||||||
end
|
end
|
||||||
|
|
||||||
def convert(*args)
|
def convert(*_args)
|
||||||
""
|
""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
bad_processor = "Custom::Markdown"
|
bad_processor = "Custom::Markdown"
|
||||||
s = Site.new(site_configuration('markdown' => bad_processor, 'incremental' => false))
|
s = Site.new(site_configuration(
|
||||||
|
"markdown" => bad_processor,
|
||||||
|
"incremental" => false
|
||||||
|
))
|
||||||
assert_raises Jekyll::Errors::FatalException do
|
assert_raises Jekyll::Errors::FatalException do
|
||||||
s.process
|
s.process
|
||||||
end
|
end
|
||||||
|
@ -342,96 +361,105 @@ class TestSite < JekyllUnitTest
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with an invalid markdown processor in the configuration' do
|
context "with an invalid markdown processor in the configuration" do
|
||||||
should 'not throw an error at initialization time' do
|
should "not throw an error at initialization time" do
|
||||||
bad_processor = 'not a processor name'
|
bad_processor = "not a processor name"
|
||||||
assert Site.new(site_configuration('markdown' => bad_processor))
|
assert Site.new(site_configuration("markdown" => bad_processor))
|
||||||
end
|
end
|
||||||
|
|
||||||
should 'throw FatalException at process time' do
|
should "throw FatalException at process time" do
|
||||||
bad_processor = 'not a processor name'
|
bad_processor = "not a processor name"
|
||||||
s = Site.new(site_configuration('markdown' => bad_processor, 'incremental' => false))
|
s = Site.new(site_configuration(
|
||||||
|
"markdown" => bad_processor,
|
||||||
|
"incremental" => false
|
||||||
|
))
|
||||||
assert_raises Jekyll::Errors::FatalException do
|
assert_raises Jekyll::Errors::FatalException do
|
||||||
s.process
|
s.process
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'data directory' do
|
context "data directory" do
|
||||||
should 'auto load yaml files' do
|
should "auto load yaml files" do
|
||||||
site = Site.new(site_configuration)
|
site = Site.new(site_configuration)
|
||||||
site.process
|
site.process
|
||||||
|
|
||||||
file_content = SafeYAML.load_file(File.join(source_dir, '_data', 'members.yaml'))
|
file_content = SafeYAML.load_file(File.join(source_dir, "_data", "members.yaml"))
|
||||||
|
|
||||||
assert_equal site.data['members'], file_content
|
assert_equal site.data["members"], file_content
|
||||||
assert_equal site.site_payload['site']['data']['members'], file_content
|
assert_equal site.site_payload["site"]["data"]["members"], file_content
|
||||||
end
|
end
|
||||||
|
|
||||||
should 'load yaml files from extracted method' do
|
should "load yaml files from extracted method" do
|
||||||
site = Site.new(site_configuration)
|
site = Site.new(site_configuration)
|
||||||
site.process
|
site.process
|
||||||
|
|
||||||
file_content = DataReader.new(site).read_data_file(source_dir('_data', 'members.yaml'))
|
file_content = DataReader.new(site)
|
||||||
|
.read_data_file(source_dir("_data", "members.yaml"))
|
||||||
|
|
||||||
assert_equal site.data['members'], file_content
|
assert_equal site.data["members"], file_content
|
||||||
assert_equal site.site_payload['site']['data']['members'], file_content
|
assert_equal site.site_payload["site"]["data"]["members"], file_content
|
||||||
end
|
end
|
||||||
|
|
||||||
should 'auto load yml files' do
|
should "auto load yml files" do
|
||||||
site = Site.new(site_configuration)
|
site = Site.new(site_configuration)
|
||||||
site.process
|
site.process
|
||||||
|
|
||||||
file_content = SafeYAML.load_file(File.join(source_dir, '_data', 'languages.yml'))
|
file_content = SafeYAML.load_file(File.join(source_dir, "_data", "languages.yml"))
|
||||||
|
|
||||||
assert_equal site.data['languages'], file_content
|
assert_equal site.data["languages"], file_content
|
||||||
assert_equal site.site_payload['site']['data']['languages'], file_content
|
assert_equal site.site_payload["site"]["data"]["languages"], file_content
|
||||||
end
|
end
|
||||||
|
|
||||||
should 'auto load json files' do
|
should "auto load json files" do
|
||||||
site = Site.new(site_configuration)
|
site = Site.new(site_configuration)
|
||||||
site.process
|
site.process
|
||||||
|
|
||||||
file_content = SafeYAML.load_file(File.join(source_dir, '_data', 'members.json'))
|
file_content = SafeYAML.load_file(File.join(source_dir, "_data", "members.json"))
|
||||||
|
|
||||||
assert_equal site.data['members'], file_content
|
assert_equal site.data["members"], file_content
|
||||||
assert_equal site.site_payload['site']['data']['members'], file_content
|
assert_equal site.site_payload["site"]["data"]["members"], file_content
|
||||||
end
|
end
|
||||||
|
|
||||||
should 'auto load yaml files in subdirectory' do
|
should "auto load yaml files in subdirectory" do
|
||||||
site = Site.new(site_configuration)
|
site = Site.new(site_configuration)
|
||||||
site.process
|
site.process
|
||||||
|
|
||||||
file_content = SafeYAML.load_file(File.join(source_dir, '_data', 'categories', 'dairy.yaml'))
|
file_content = SafeYAML.load_file(File.join(
|
||||||
|
source_dir, "_data", "categories", "dairy.yaml"
|
||||||
|
))
|
||||||
|
|
||||||
assert_equal site.data['categories']['dairy'], file_content
|
assert_equal site.data["categories"]["dairy"], file_content
|
||||||
assert_equal site.site_payload['site']['data']['categories']['dairy'], file_content
|
assert_equal(
|
||||||
|
site.site_payload["site"]["data"]["categories"]["dairy"],
|
||||||
|
file_content
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "load symlink files in unsafe mode" do
|
should "load symlink files in unsafe mode" do
|
||||||
site = Site.new(site_configuration('safe' => false))
|
site = Site.new(site_configuration("safe" => false))
|
||||||
site.process
|
site.process
|
||||||
|
|
||||||
file_content = SafeYAML.load_file(File.join(source_dir, '_data', 'products.yml'))
|
file_content = SafeYAML.load_file(File.join(source_dir, "_data", "products.yml"))
|
||||||
|
|
||||||
assert_equal site.data['products'], file_content
|
assert_equal site.data["products"], file_content
|
||||||
assert_equal site.site_payload['site']['data']['products'], file_content
|
assert_equal site.site_payload["site"]["data"]["products"], file_content
|
||||||
end
|
end
|
||||||
|
|
||||||
should "load the symlink files in safe mode, as they resolve to inside site.source" do
|
should "load the symlink files in safe mode, " \
|
||||||
site = Site.new(site_configuration('safe' => true))
|
"as they resolve to inside site.source" do
|
||||||
|
site = Site.new(site_configuration("safe" => true))
|
||||||
site.process
|
site.process
|
||||||
file_content = SafeYAML.load_file(File.join(source_dir, '_data', 'products.yml'))
|
file_content = SafeYAML.load_file(File.join(source_dir, "_data", "products.yml"))
|
||||||
assert_equal site.data['products'], file_content
|
assert_equal site.data["products"], file_content
|
||||||
assert_equal site.site_payload['site']['data']['products'], file_content
|
assert_equal site.site_payload["site"]["data"]["products"], file_content
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "manipulating the Jekyll environment" do
|
context "manipulating the Jekyll environment" do
|
||||||
setup do
|
setup do
|
||||||
@site = Site.new(site_configuration({
|
@site = Site.new(site_configuration({
|
||||||
'incremental' => false
|
"incremental" => false
|
||||||
}))
|
}))
|
||||||
@site.process
|
@site.process
|
||||||
@page = @site.pages.find { |p| p.name == "environment.html" }
|
@page = @site.pages.find { |p| p.name == "environment.html" }
|
||||||
|
@ -445,7 +473,7 @@ class TestSite < JekyllUnitTest
|
||||||
setup do
|
setup do
|
||||||
ENV["JEKYLL_ENV"] = "production"
|
ENV["JEKYLL_ENV"] = "production"
|
||||||
@site = Site.new(site_configuration({
|
@site = Site.new(site_configuration({
|
||||||
'incremental' => false
|
"incremental" => false
|
||||||
}))
|
}))
|
||||||
@site.process
|
@site.process
|
||||||
@page = @site.pages.find { |p| p.name == "environment.html" }
|
@page = @site.pages.find { |p| p.name == "environment.html" }
|
||||||
|
@ -463,7 +491,7 @@ class TestSite < JekyllUnitTest
|
||||||
|
|
||||||
context "with liquid profiling" do
|
context "with liquid profiling" do
|
||||||
setup do
|
setup do
|
||||||
@site = Site.new(site_configuration('profile' => true))
|
@site = Site.new(site_configuration("profile" => true))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Suppress output while testing
|
# Suppress output while testing
|
||||||
|
@ -483,7 +511,7 @@ class TestSite < JekyllUnitTest
|
||||||
context "incremental build" do
|
context "incremental build" do
|
||||||
setup do
|
setup do
|
||||||
@site = Site.new(site_configuration({
|
@site = Site.new(site_configuration({
|
||||||
'incremental' => true
|
"incremental" => true
|
||||||
}))
|
}))
|
||||||
@site.read
|
@site.read
|
||||||
end
|
end
|
||||||
|
@ -533,8 +561,6 @@ class TestSite < JekyllUnitTest
|
||||||
mtime2 = File.stat(dest).mtime.to_i
|
mtime2 = File.stat(dest).mtime.to_i
|
||||||
refute_equal mtime1, mtime2 # must be regenerated
|
refute_equal mtime1, mtime2 # must be regenerated
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue