Merge pull request #5761 from jekyll/pull/consistent_comma

Merge pull request 5761
This commit is contained in:
jekyllbot 2017-01-12 16:41:15 -08:00 committed by GitHub
commit 76410d16d1
48 changed files with 281 additions and 279 deletions

View File

@ -127,5 +127,7 @@ Style/StringLiterals:
EnforcedStyle: double_quotes EnforcedStyle: double_quotes
Style/StringLiteralsInInterpolation: Style/StringLiteralsInInterpolation:
EnforcedStyle: double_quotes EnforcedStyle: double_quotes
Style/TrailingCommaInLiteral:
EnforcedStyleForMultiline: consistent_comma
Style/UnneededCapitalW: Style/UnneededCapitalW:
Enabled: false Enabled: false

View File

@ -16,7 +16,7 @@ module Jekyll
:pending => "\u203D".yellow, :pending => "\u203D".yellow,
:undefined => "\u2718".red, :undefined => "\u2718".red,
:passed => "\u2714".green, :passed => "\u2714".green,
:skipped => "\u203D".blue :skipped => "\u203D".blue,
}.freeze }.freeze
# #

View File

@ -142,7 +142,7 @@ def location(folder, direction)
end end
[before || ".", [before || ".",
after || "."] after || ".",]
end end
# #
@ -160,7 +160,7 @@ def seconds_agnostic_datetime(datetime = Time.now)
[ [
Regexp.escape(date), Regexp.escape(date),
"#{time}:\\d{2}", "#{time}:\\d{2}",
Regexp.escape(zone) Regexp.escape(zone),
] \ ] \
.join("\\ ") .join("\\ ")
end end

View File

@ -35,7 +35,7 @@ module Jekyll
fsnotify_buggy?(site), fsnotify_buggy?(site),
!deprecated_relative_permalinks(site), !deprecated_relative_permalinks(site),
!conflicting_urls(site), !conflicting_urls(site),
!urls_only_differ_by_case(site) !urls_only_differ_by_case(site),
].all? ].all?
end end

View File

@ -10,9 +10,9 @@ module Jekyll
"ssl_key" => ["--ssl-key [KEY]", "X.509 (SSL) Private Key."], "ssl_key" => ["--ssl-key [KEY]", "X.509 (SSL) Private Key."],
"port" => ["-P", "--port [PORT]", "Port to listen on"], "port" => ["-P", "--port [PORT]", "Port to listen on"],
"show_dir_listing" => ["--show-dir-listing", "show_dir_listing" => ["--show-dir-listing",
"Show a directory listing instead of loading your index file."], "Show a directory listing instead of loading your index file.",],
"skip_initial_build" => ["skip_initial_build", "--skip-initial-build", "skip_initial_build" => ["skip_initial_build", "--skip-initial-build",
"Skips the initial site build which occurs before the server is started."] "Skips the initial site build which occurs before the server is started.",],
}.freeze }.freeze
# #
@ -88,7 +88,7 @@ module Jekyll
index.rhtml index.rhtml
index.cgi index.cgi
index.xml index.xml
) ),
} }
opts[:DirectoryIndex] = [] if opts[:JekyllOptions]["show_dir_listing"] opts[:DirectoryIndex] = [] if opts[:JekyllOptions]["show_dir_listing"]
@ -116,8 +116,8 @@ module Jekyll
WEBrick::Config::FileHandler.merge({ WEBrick::Config::FileHandler.merge({
:FancyIndexing => true, :FancyIndexing => true,
:NondisclosureName => [ :NondisclosureName => [
".ht*", "~*" ".ht*", "~*",
] ],
}) })
end end
@ -139,7 +139,7 @@ module Jekyll
:prefix => ssl_enabled ? "https" : "http", :prefix => ssl_enabled ? "https" : "http",
:address => address, :address => address,
:port => port, :port => port,
:baseurl => baseurl ? "#{baseurl}/" : "" :baseurl => baseurl ? "#{baseurl}/" : "",
}) })
end end

View File

@ -6,7 +6,7 @@ module Jekyll
class Servlet < WEBrick::HTTPServlet::FileHandler class Servlet < WEBrick::HTTPServlet::FileHandler
DEFAULTS = { DEFAULTS = {
"Cache-Control" => "private, max-age=0, proxy-revalidate, " \ "Cache-Control" => "private, max-age=0, proxy-revalidate, " \
"no-store, no-cache, must-revalidate" "no-store, no-cache, must-revalidate",
}.freeze }.freeze
def initialize(server, root, callbacks) def initialize(server, root, callbacks)

View File

@ -58,15 +58,15 @@ module Jekyll
"defaults" => [], "defaults" => [],
"liquid" => { "liquid" => {
"error_mode" => "warn" "error_mode" => "warn",
}, },
"rdiscount" => { "rdiscount" => {
"extensions" => [] "extensions" => [],
}, },
"redcarpet" => { "redcarpet" => {
"extensions" => [] "extensions" => [],
}, },
"kramdown" => { "kramdown" => {
@ -76,8 +76,8 @@ module Jekyll
"smart_quotes" => "lsquo,rsquo,ldquo,rdquo", "smart_quotes" => "lsquo,rsquo,ldquo,rdquo",
"input" => "GFM", "input" => "GFM",
"hard_wrap" => false, "hard_wrap" => false,
"footnote_nr" => 1 "footnote_nr" => 1,
} },
}.map { |k, v| [k, v.freeze] }].freeze }.map { |k, v| [k, v.freeze] }].freeze
class << self class << self

View File

@ -11,7 +11,7 @@ module Jekyll
"line_numbers" => "inline", "line_numbers" => "inline",
"line_number_start" => 1, "line_number_start" => 1,
"tab_width" => 4, "tab_width" => 4,
"wrap" => "div" "wrap" => "div",
}.freeze }.freeze
def initialize(config) def initialize(config)

View File

@ -21,7 +21,7 @@ class Jekyll::Converters::Markdown::RedcarpetParser
code, code,
{ {
:lexer => lang, :lexer => lang,
:options => { :encoding => "utf-8" } :options => { :encoding => "utf-8" },
} }
), ),
lang lang

View File

@ -196,7 +196,7 @@ module Jekyll
@url = URL.new({ @url = URL.new({
:template => url_template, :template => url_template,
:placeholders => url_placeholders, :placeholders => url_placeholders,
:permalink => permalink :permalink => permalink,
}).to_s }).to_s
end end
@ -469,14 +469,14 @@ module Jekyll
"category", "category",
"categories" "categories"
) )
).map(&:to_s).flatten.uniq ).map(&:to_s).flatten.uniq,
}) })
end end
private private
def populate_tags def populate_tags
merge_data!({ merge_data!({
"tags" => Utils.pluralized_array_from_hash(data, "tag", "tags").flatten "tags" => Utils.pluralized_array_from_hash(data, "tag", "tags").flatten,
}) })
end end

View File

@ -20,7 +20,7 @@ module Jekyll
def to_h def to_h
@to_h ||= { @to_h ||= {
"version" => version, "version" => version,
"environment" => environment "environment" => environment,
} }
end end

View File

@ -2,7 +2,7 @@ module Jekyll
class EntryFilter class EntryFilter
attr_reader :site attr_reader :site
SPECIAL_LEADING_CHARACTERS = [ SPECIAL_LEADING_CHARACTERS = [
".", "_", "#", "~" ".", "_", "#", "~",
].freeze ].freeze
def initialize(site, base_directory = nil) def initialize(site, base_directory = nil)

View File

@ -54,7 +54,7 @@ module Jekyll
array << { array << {
"name" => item.first, "name" => item.first,
"items" => item.last, "items" => item.last,
"size" => item.last.size "size" => item.last.size,
} }
end end
end end

View File

@ -6,7 +6,7 @@ module Jekyll
PRIORITY_MAP = { PRIORITY_MAP = {
:low => 10, :low => 10,
:normal => 20, :normal => 20,
:high => 30 :high => 30,
}.freeze }.freeze
# initial empty hooks # initial empty hooks
@ -17,26 +17,26 @@ module Jekyll
:post_read => [], :post_read => [],
:pre_render => [], :pre_render => [],
:post_render => [], :post_render => [],
:post_write => [] :post_write => [],
}, },
:pages => { :pages => {
:post_init => [], :post_init => [],
:pre_render => [], :pre_render => [],
:post_render => [], :post_render => [],
:post_write => [] :post_write => [],
}, },
:posts => { :posts => {
:post_init => [], :post_init => [],
:pre_render => [], :pre_render => [],
:post_render => [], :post_render => [],
:post_write => [] :post_write => [],
}, },
:documents => { :documents => {
:post_init => [], :post_init => [],
:pre_render => [], :pre_render => [],
:post_render => [], :post_render => [],
:post_write => [] :post_write => [],
} },
} }
# map of all hooks and their priorities # map of all hooks and their priorities
@ -64,7 +64,7 @@ module Jekyll
:post_init => [], :post_init => [],
:pre_render => [], :pre_render => [],
:post_render => [], :post_render => [],
:post_write => [] :post_write => [],
} }
unless @registry[owner][event] unless @registry[owner][event]

View File

@ -6,7 +6,7 @@ module Jekyll
:debug => ::Logger::DEBUG, :debug => ::Logger::DEBUG,
:info => ::Logger::INFO, :info => ::Logger::INFO,
:warn => ::Logger::WARN, :warn => ::Logger::WARN,
:error => ::Logger::ERROR :error => ::Logger::ERROR,
}.freeze }.freeze
# Public: Create a new instance of a log writer # Public: Create a new instance of a log writer

View File

@ -98,7 +98,7 @@ module Jekyll
@url ||= URL.new({ @url ||= URL.new({
:template => template, :template => template,
:placeholders => url_placeholders, :placeholders => url_placeholders,
:permalink => permalink :permalink => permalink,
}).to_s }).to_s
end end
@ -108,7 +108,7 @@ module Jekyll
{ {
:path => @dir, :path => @dir,
:basename => basename, :basename => basename,
:output_ext => output_ext :output_ext => output_ext,
} }
end end

View File

@ -5,7 +5,7 @@ module Jekyll
:highest => 100, :highest => 100,
:lowest => -100, :lowest => -100,
:normal => 0, :normal => 0,
:high => 10 :high => 10,
}.freeze }.freeze
# #

View File

@ -54,7 +54,7 @@ module Jekyll
when ".csv" when ".csv"
CSV.read(path, { CSV.read(path, {
:headers => true, :headers => true,
:encoding => site.config["encoding"] :encoding => site.config["encoding"],
}).map(&:to_hash) }).map(&:to_hash)
else else
SafeYAML.load_file(path) SafeYAML.load_file(path)

View File

@ -57,7 +57,7 @@ module Jekyll
path = @site.in_source_dir(File.join(dir, magic_dir, entry)) path = @site.in_source_dir(File.join(dir, magic_dir, entry))
Document.new(path, { Document.new(path, {
:site => @site, :site => @site,
:collection => @site.posts :collection => @site.posts,
}) })
end.reject(&:nil?) end.reject(&:nil?)
end end

View File

@ -40,7 +40,7 @@ module Jekyll
metadata[path] = { metadata[path] = {
"mtime" => File.mtime(path), "mtime" => File.mtime(path),
"deps" => [] "deps" => [],
} }
cache[path] = true cache[path] = true
end end

View File

@ -101,7 +101,7 @@ module Jekyll
"name" => name, "name" => name,
"extname" => extname, "extname" => extname,
"modified_time" => modified_time, "modified_time" => modified_time,
"path" => File.join("", relative_path) "path" => File.join("", relative_path),
} }
end end
@ -112,7 +112,7 @@ module Jekyll
@collection.relative_directory.size..relative_path.size], @collection.relative_directory.size..relative_path.size],
:output_ext => "", :output_ext => "",
:name => "", :name => "",
:title => "" :title => "",
} }
end end
@ -125,7 +125,7 @@ module Jekyll
else else
::Jekyll::URL.new({ ::Jekyll::URL.new({
:template => @collection.url_template, :template => @collection.url_template,
:placeholders => placeholders :placeholders => placeholders,
}) })
end.to_s.gsub(%r!/$!, "") end.to_s.gsub(%r!/$!, "")
end end

View File

@ -54,7 +54,7 @@ eos
[:hl_lines, opts.fetch(:hl_lines, nil)], [:hl_lines, opts.fetch(:hl_lines, nil)],
[:linenos, opts.fetch(:linenos, nil)], [:linenos, opts.fetch(:linenos, nil)],
[:encoding, opts.fetch(:encoding, "utf-8")], [:encoding, opts.fetch(:encoding, "utf-8")],
[:cssclass, opts.fetch(:cssclass, nil)] [:cssclass, opts.fetch(:cssclass, nil)],
].reject { |f| f.last.nil? }] ].reject { |f| f.last.nil? }]
else else
opts opts
@ -125,7 +125,7 @@ eos
def add_code_tag(code) def add_code_tag(code)
code_attributes = [ code_attributes = [
"class=\"language-#{@lang.to_s.tr("+", "-")}\"", "class=\"language-#{@lang.to_s.tr("+", "-")}\"",
"data-lang=\"#{@lang}\"" "data-lang=\"#{@lang}\"",
].join(" ") ].join(" ")
"<figure class=\"highlight\"><pre><code #{code_attributes}>"\ "<figure class=\"highlight\"><pre><code #{code_attributes}>"\
"#{code.chomp}</code></pre></figure>" "#{code.chomp}</code></pre></figure>"

View File

@ -28,7 +28,7 @@ class Jekyll::ThemeBuilder
def template_file(filename) def template_file(filename)
[ [
root.join("theme_template", "#{filename}.erb"), root.join("theme_template", "#{filename}.erb"),
root.join("theme_template", filename.to_s) root.join("theme_template", filename.to_s),
].find(&:exist?) ].find(&:exist?)
end end

View File

@ -17,7 +17,7 @@ module Jekyll
:yellow => 33, :yellow => 33,
:white => 37, :white => 37,
:blue => 34, :blue => 34,
:cyan => 36 :cyan => 36,
}.freeze }.freeze
# Strip ANSI from the current string. It also strips cursor stuff, # Strip ANSI from the current string. It also strips cursor stuff,

View File

@ -46,7 +46,7 @@ include Jekyll
Minitest::Reporters.use! [ Minitest::Reporters.use! [
Minitest::Reporters::DefaultReporter.new( Minitest::Reporters::DefaultReporter.new(
:color => true :color => true
) ),
] ]
module Minitest::Assertions module Minitest::Assertions
@ -107,9 +107,9 @@ class JekyllUnitTest < Minitest::Test
site = fixture_site({ site = fixture_site({
"collections" => { "collections" => {
"methods" => { "methods" => {
"output" => true "output" => true,
} },
} },
}) })
site.read site.read
matching_doc = site.collections["methods"].docs.find do |doc| matching_doc = site.collections["methods"].docs.find do |doc|
@ -133,10 +133,10 @@ class JekyllUnitTest < Minitest::Test
def site_configuration(overrides = {}) def site_configuration(overrides = {})
full_overrides = build_configs(overrides, build_configs({ full_overrides = build_configs(overrides, build_configs({
"destination" => dest_dir, "destination" => dest_dir,
"incremental" => false "incremental" => false,
})) }))
Configuration.from(full_overrides.merge({ Configuration.from(full_overrides.merge({
"source" => source_dir "source" => source_dir,
})) }))
end end

View File

@ -91,9 +91,9 @@ class TestCollections < JekyllUnitTest
@site = fixture_site({ @site = fixture_site({
"collections" => { "collections" => {
"methods" => { "methods" => {
"permalink" => "/awesome/:path/" "permalink" => "/awesome/:path/",
} },
} },
}) })
@site.process @site.process
@collection = @site.collections["methods"] @collection = @site.collections["methods"]
@ -107,7 +107,7 @@ class TestCollections < JekyllUnitTest
context "with a collection" do context "with a collection" do
setup do setup do
@site = fixture_site({ @site = fixture_site({
"collections" => ["methods"] "collections" => ["methods"],
}) })
@site.process @site.process
@collection = @site.collections["methods"] @collection = @site.collections["methods"]
@ -158,9 +158,9 @@ class TestCollections < JekyllUnitTest
"collections" => { "collections" => {
"methods" => { "methods" => {
"foo" => "bar", "foo" => "bar",
"baz" => "whoo" "baz" => "whoo",
} },
} },
}) })
@site.process @site.process
@collection = @site.collections["methods"] @collection = @site.collections["methods"]
@ -175,7 +175,7 @@ class TestCollections < JekyllUnitTest
setup do setup do
@site = fixture_site({ @site = fixture_site({
"collections" => ["methods"], "collections" => ["methods"],
"safe" => true "safe" => true,
}) })
@site.process @site.process
@collection = @site.collections["methods"] @collection = @site.collections["methods"]
@ -198,7 +198,7 @@ class TestCollections < JekyllUnitTest
setup do setup do
@site = fixture_site({ @site = fixture_site({
"collections" => ["with.dots"], "collections" => ["with.dots"],
"safe" => true "safe" => true,
}) })
@site.process @site.process
@collection = @site.collections["with.dots"] @collection = @site.collections["with.dots"]

View File

@ -86,12 +86,12 @@ class TestCommandsServe < JekyllUnitTest
"config" => %w(_config.yml _development.yml), "config" => %w(_config.yml _development.yml),
"serving" => true, "serving" => true,
"watch" => false, # for not having guard output when running the tests "watch" => false, # for not having guard output when running the tests
"url" => "http://localhost:4000" "url" => "http://localhost:4000",
} }
expect(Jekyll::Commands::Serve).to receive(:process).with(custom_options) expect(Jekyll::Commands::Serve).to receive(:process).with(custom_options)
@merc.execute(:serve, { "config" => %w(_config.yml _development.yml), @merc.execute(:serve, { "config" => %w(_config.yml _development.yml),
"watch" => false }) "watch" => false, })
end end
context "in development environment" do context "in development environment" do
@ -113,7 +113,7 @@ class TestCommandsServe < JekyllUnitTest
"port" => "9999", "port" => "9999",
"url" => "https://jekyllrb.com/", "url" => "https://jekyllrb.com/",
"ssl_cert" => "foo", "ssl_cert" => "foo",
"ssl_key" => "bar" "ssl_key" => "bar",
}) })
assert_equal 1, Jekyll.sites.count assert_equal 1, Jekyll.sites.count
@ -146,13 +146,13 @@ class TestCommandsServe < JekyllUnitTest
should "raise if enabling without key or cert" do should "raise if enabling without key or cert" do
assert_raises RuntimeError do assert_raises RuntimeError do
custom_opts({ custom_opts({
"ssl_key" => "foo" "ssl_key" => "foo",
}) })
end end
assert_raises RuntimeError do assert_raises RuntimeError do
custom_opts({ custom_opts({
"ssl_key" => "foo" "ssl_key" => "foo",
}) })
end end
end end
@ -166,7 +166,7 @@ class TestCommandsServe < JekyllUnitTest
"ssl_cert" => "foo", "ssl_cert" => "foo",
"source" => "bar", "source" => "bar",
"enable_ssl" => true, "enable_ssl" => true,
"ssl_key" => "bar" "ssl_key" => "bar",
}) })
assert result[:SSLEnable] assert result[:SSLEnable]

View File

@ -4,7 +4,7 @@ require "colorator"
class TestConfiguration < JekyllUnitTest class TestConfiguration < JekyllUnitTest
test_config = { test_config = {
"source" => new(nil).source_dir, "source" => new(nil).source_dir,
"destination" => dest_dir "destination" => dest_dir,
} }
context ".from" do context ".from" do
@ -34,8 +34,8 @@ class TestConfiguration < JekyllUnitTest
{ {
"posts" => { "posts" => {
"output" => true, "output" => true,
"permalink" => "/:categories/:year/:month/:day/:title:output_ext" "permalink" => "/:categories/:year/:month/:day/:title:output_ext",
} },
} }
) )
end end
@ -85,8 +85,8 @@ class TestConfiguration < JekyllUnitTest
{ {
"posts" => { "posts" => {
"output" => true, "output" => true,
"permalink" => "/:categories/:year/:month/:day/:title/" "permalink" => "/:categories/:year/:month/:day/:title/",
} },
} }
) )
@ -109,14 +109,14 @@ class TestConfiguration < JekyllUnitTest
:permalink => "date", :permalink => "date",
"baseurl" => "/", "baseurl" => "/",
:include => [".htaccess"], :include => [".htaccess"],
:source => "./" :source => "./",
}] }]
@string_keys = Configuration[{ @string_keys = Configuration[{
"markdown" => "kramdown", "markdown" => "kramdown",
"permalink" => "date", "permalink" => "date",
"baseurl" => "/", "baseurl" => "/",
"include" => [".htaccess"], "include" => [".htaccess"],
"source" => "./" "source" => "./",
}] }]
end end
should "stringify symbol keys" do should "stringify symbol keys" do
@ -132,7 +132,7 @@ class TestConfiguration < JekyllUnitTest
@no_override = {} @no_override = {}
@one_config_file = { "config" => "config.yml" } @one_config_file = { "config" => "config.yml" }
@multiple_files = { @multiple_files = {
"config" => %w(config/site.yml config/deploy.toml configuration.yml) "config" => %w(config/site.yml config/deploy.toml configuration.yml),
} }
end end
@ -205,7 +205,7 @@ class TestConfiguration < JekyllUnitTest
"pygments" => true, "pygments" => true,
"plugins" => true, "plugins" => true,
"layouts" => true, "layouts" => true,
"data_source" => true "data_source" => true,
}] }]
end end
should "unset 'auto' and 'watch'" do should "unset 'auto' and 'watch'" do
@ -255,7 +255,7 @@ class TestConfiguration < JekyllUnitTest
setup do setup do
@config = proc do |val| @config = proc do |val|
Configuration[{ Configuration[{
"paginate" => val "paginate" => val,
}] }]
end end
end end
@ -327,7 +327,7 @@ class TestConfiguration < JekyllUnitTest
:default => source_dir("_config.yml"), :default => source_dir("_config.yml"),
:other => source_dir("_config.live.yml"), :other => source_dir("_config.live.yml"),
:toml => source_dir("_config.dev.toml"), :toml => source_dir("_config.dev.toml"),
:empty => "" :empty => "",
} }
end end
@ -372,7 +372,7 @@ class TestConfiguration < JekyllUnitTest
Jekyll.logger.log_level = :warn Jekyll.logger.log_level = :warn
assert_equal \ assert_equal \
site_configuration({ "baseurl" => "/you-beautiful-blog-you", site_configuration({ "baseurl" => "/you-beautiful-blog-you",
"title" => "My magnificent site, wut" }), "title" => "My magnificent site, wut", }),
Jekyll.configuration(test_config.merge({ "config" => [@paths[:toml]] })) Jekyll.configuration(test_config.merge({ "config" => [@paths[:toml]] }))
Jekyll.logger.log_level = :info Jekyll.logger.log_level = :info
end end
@ -435,9 +435,9 @@ class TestConfiguration < JekyllUnitTest
"docs" => {}, "docs" => {},
"posts" => { "posts" => {
"output" => true, "output" => true,
"permalink" => "/:categories/:year/:month/:day/:title:output_ext" "permalink" => "/:categories/:year/:month/:day/:title:output_ext",
} },
} },
}) })
end end
@ -449,9 +449,9 @@ class TestConfiguration < JekyllUnitTest
"collections" => { "collections" => {
"posts" => { "posts" => {
"output" => true, "output" => true,
"permalink" => "/:categories/:year/:month/:day/:title:output_ext" "permalink" => "/:categories/:year/:month/:day/:title:output_ext",
} },
} },
}) })
end end
@ -461,9 +461,9 @@ class TestConfiguration < JekyllUnitTest
"collections" => { "collections" => {
"posts" => { "posts" => {
"output" => true, "output" => true,
"permalink" => "/:categories/:year/:month/:day/:title:output_ext" "permalink" => "/:categories/:year/:month/:day/:title:output_ext",
} },
} },
}) })
end end
@ -471,16 +471,16 @@ class TestConfiguration < JekyllUnitTest
posts_permalink = "/:year/:title/" posts_permalink = "/:year/:title/"
conf = Configuration[default_configuration].tap do |c| conf = Configuration[default_configuration].tap do |c|
c["collections"] = { c["collections"] = {
"posts" => { "permalink" => posts_permalink } "posts" => { "permalink" => posts_permalink },
} }
end end
assert_equal conf.add_default_collections, conf.merge({ assert_equal conf.add_default_collections, conf.merge({
"collections" => { "collections" => {
"posts" => { "posts" => {
"output" => true, "output" => true,
"permalink" => posts_permalink "permalink" => posts_permalink,
} },
} },
}) })
end end
end end

View File

@ -10,7 +10,7 @@ class TestDoctorCommand < JekyllUnitTest
should "return success on a valid site/page" do should "return success on a valid site/page" do
@site = Site.new(Jekyll.configuration({ @site = Site.new(Jekyll.configuration({
"source" => File.join(source_dir, "/_urls_differ_by_case_valid"), "source" => File.join(source_dir, "/_urls_differ_by_case_valid"),
"destination" => dest_dir "destination" => dest_dir,
})) }))
@site.process @site.process
output = capture_stderr do output = capture_stderr do
@ -23,7 +23,7 @@ class TestDoctorCommand < JekyllUnitTest
should "return warning for pages only differing by case" do should "return warning for pages only differing by case" do
@site = Site.new(Jekyll.configuration({ @site = Site.new(Jekyll.configuration({
"source" => File.join(source_dir, "/_urls_differ_by_case_invalid"), "source" => File.join(source_dir, "/_urls_differ_by_case_invalid"),
"destination" => dest_dir "destination" => dest_dir,
})) }))
@site.process @site.process
output = capture_stderr do output = capture_stderr do

View File

@ -8,7 +8,7 @@ class TestDocument < JekyllUnitTest
context "a document in a collection" do context "a document in a collection" do
setup do setup do
@site = fixture_site({ @site = fixture_site({
"collections" => ["methods"] "collections" => ["methods"],
}) })
@site.process @site.process
@document = @site.collections["methods"].docs.detect do |d| @document = @site.collections["methods"].docs.detect do |d|
@ -118,10 +118,10 @@ class TestDocument < JekyllUnitTest
"scope" => { "path"=>"", "type"=>"slides" }, "scope" => { "path"=>"", "type"=>"slides" },
"values" => { "values" => {
"nested" => { "nested" => {
"key" => "myval" "key" => "myval",
} },
} },
}] },],
}) })
@site.process @site.process
@document = @site.collections["slides"].docs.select { |d| d.is_a?(Document) }.first @document = @site.collections["slides"].docs.select { |d| d.is_a?(Document) }.first
@ -143,10 +143,10 @@ class TestDocument < JekyllUnitTest
"values" => { "values" => {
"nested" => { "nested" => {
"test1" => "default1", "test1" => "default1",
"test2" => "default1" "test2" => "default1",
} },
} },
}] },],
}) })
@site.process @site.process
@document = @site.collections["slides"].docs[1] @document = @site.collections["slides"].docs[1]
@ -170,10 +170,10 @@ class TestDocument < JekyllUnitTest
"scope" => { "path"=>"_slides", "type"=>"slides" }, "scope" => { "path"=>"_slides", "type"=>"slides" },
"values" => { "values" => {
"nested" => { "nested" => {
"key" => "value123" "key" => "value123",
} },
} },
}] },],
}) })
@site.process @site.process
@document = @site.collections["slides"].docs.first @document = @site.collections["slides"].docs.first
@ -194,10 +194,10 @@ class TestDocument < JekyllUnitTest
"scope" => { "path"=>"somepath", "type"=>"slides" }, "scope" => { "path"=>"somepath", "type"=>"slides" },
"values" => { "values" => {
"nested" => { "nested" => {
"key" => "myval" "key" => "myval",
} },
} },
}] },],
}) })
@site.process @site.process
@document = @site.collections["slides"].docs.first @document = @site.collections["slides"].docs.first
@ -213,7 +213,7 @@ class TestDocument < JekyllUnitTest
context "a document in a collection with a custom permalink" do context "a document in a collection with a custom permalink" do
setup do setup do
@site = fixture_site({ @site = fixture_site({
"collections" => ["slides"] "collections" => ["slides"],
}) })
@site.process @site.process
@document = @site.collections["slides"].docs[2] @document = @site.collections["slides"].docs[2]
@ -235,10 +235,10 @@ class TestDocument < JekyllUnitTest
"collections" => { "collections" => {
"slides" => { "slides" => {
"output" => true, "output" => true,
"permalink" => "/slides/test/:name" "permalink" => "/slides/test/:name",
}
}, },
"permalink" => "pretty" },
"permalink" => "pretty",
}) })
@site.process @site.process
@document = @site.collections["slides"].docs[0] @document = @site.collections["slides"].docs[0]
@ -263,9 +263,9 @@ class TestDocument < JekyllUnitTest
@site = fixture_site({ @site = fixture_site({
"collections" => { "collections" => {
"slides" => { "slides" => {
"output" => true "output" => true,
} },
} },
}) })
@site.permalink_style = :pretty @site.permalink_style = :pretty
@site.process @site.process
@ -287,9 +287,9 @@ class TestDocument < JekyllUnitTest
@site = fixture_site({ @site = fixture_site({
"collections" => { "collections" => {
"slides" => { "slides" => {
"output" => true "output" => true,
} },
} },
}) })
@site.permalink_style = :pretty @site.permalink_style = :pretty
@site.process @site.process
@ -307,9 +307,9 @@ class TestDocument < JekyllUnitTest
@site = fixture_site({ @site = fixture_site({
"collections" => { "collections" => {
"slides" => { "slides" => {
"output" => true "output" => true,
} },
} },
}) })
@site.process @site.process
@document = @site.collections["slides"].docs[6] @document = @site.collections["slides"].docs[6]
@ -339,9 +339,9 @@ class TestDocument < JekyllUnitTest
"collections" => { "collections" => {
"slides" => { "slides" => {
"output" => true, "output" => true,
"permalink" => "/slides/:title" "permalink" => "/slides/:title",
} },
} },
}) })
@site.process @site.process
@document = @site.collections["slides"].docs[3] @document = @site.collections["slides"].docs[3]
@ -381,8 +381,8 @@ class TestDocument < JekyllUnitTest
context "document with a permalink with dots & a trailing slash" do context "document with a permalink with dots & a trailing slash" do
setup do setup do
@site = fixture_site({ "collections" => { @site = fixture_site({ "collections" => {
"with.dots" => { "output" => true } "with.dots" => { "output" => true },
} }) }, })
@site.process @site.process
@document = @site.collections["with.dots"].docs.last @document = @site.collections["with.dots"].docs.last
@dest_file = dest_dir("with.dots", "permalink.with.slash.tho", "index.html") @dest_file = dest_dir("with.dots", "permalink.with.slash.tho", "index.html")
@ -406,9 +406,9 @@ class TestDocument < JekyllUnitTest
@site = fixture_site({ @site = fixture_site({
"collections" => { "collections" => {
"slides" => { "slides" => {
"output" => true "output" => true,
} },
} },
}) })
@site.process @site.process
@files = @site.collections["slides"].docs @files = @site.collections["slides"].docs
@ -436,9 +436,9 @@ class TestDocument < JekyllUnitTest
@site = fixture_site({ @site = fixture_site({
"collections" => { "collections" => {
"slides" => { "slides" => {
"output" => true "output" => true,
} },
} },
}) })
@site.process @site.process
@document = @site.collections["slides"].files.find do |doc| @document = @site.collections["slides"].files.find do |doc|
@ -469,9 +469,9 @@ class TestDocument < JekyllUnitTest
@site = fixture_site({ @site = fixture_site({
"collections" => { "collections" => {
"methods" => { "methods" => {
"output" => true "output" => true,
} },
} },
}) })
@site.process @site.process
@document = @site.collections["methods"].docs.find do |doc| @document = @site.collections["methods"].docs.find do |doc|
@ -498,9 +498,9 @@ class TestDocument < JekyllUnitTest
@site = fixture_site({ @site = fixture_site({
"collections" => { "collections" => {
"methods" => { "methods" => {
"output" => true "output" => true,
} },
} },
}) })
@site.process @site.process
@document = @site.collections["methods"].docs.find do |doc| @document = @site.collections["methods"].docs.find do |doc|

View File

@ -4,7 +4,7 @@ class TestDrop < JekyllUnitTest
context "a document drop" do context "a document drop" do
setup do setup do
@site = fixture_site({ @site = fixture_site({
"collections" => ["methods"] "collections" => ["methods"],
}) })
@site.process @site.process
@document = @site.collections["methods"].docs.detect do |d| @document = @site.collections["methods"].docs.detect do |d|

View File

@ -17,7 +17,7 @@ class TestEntryFilter < JekyllUnitTest
should "allow regexp filtering" do should "allow regexp filtering" do
files = %w(README.md) files = %w(README.md)
@site.exclude = [ @site.exclude = [
%r!README! %r!README!,
] ]
assert_empty @site.reader.filter_entries( assert_empty @site.reader.filter_entries(

View File

@ -4,13 +4,13 @@ class TestExcerpt < JekyllUnitTest
def setup_post(file) def setup_post(file)
Document.new(@site.in_source_dir(File.join("_posts", file)), { Document.new(@site.in_source_dir(File.join("_posts", file)), {
:site => @site, :site => @site,
:collection => @site.posts :collection => @site.posts,
}).tap(&:read) }).tap(&:read)
end end
def do_render(document) def do_render(document)
@site.layouts = { @site.layouts = {
"default" => Layout.new(@site, source_dir("_layouts"), "simple.html") "default" => Layout.new(@site, source_dir("_layouts"), "simple.html"),
} }
document.output = Jekyll::Renderer.new(@site, document, @site.site_payload).run document.output = Jekyll::Renderer.new(@site, document, @site.site_payload).run
end end

View File

@ -29,7 +29,7 @@ class TestFilters < JekyllUnitTest
@filter = make_filter_mock({ @filter = make_filter_mock({
"timezone" => "UTC", "timezone" => "UTC",
"url" => "http://example.com", "url" => "http://example.com",
"baseurl" => "/base" "baseurl" => "/base",
}) })
@sample_time = Time.utc(2013, 3, 27, 11, 22, 33) @sample_time = Time.utc(2013, 3, 27, 11, 22, 33)
@sample_date = Date.parse("2013-03-27") @sample_date = Date.parse("2013-03-27")
@ -39,7 +39,7 @@ class TestFilters < JekyllUnitTest
@array_of_objects = [ @array_of_objects = [
{ "color" => "red", "size" => "large" }, { "color" => "red", "size" => "large" },
{ "color" => "red", "size" => "medium" }, { "color" => "red", "size" => "medium" },
{ "color" => "blue", "size" => "medium" } { "color" => "blue", "size" => "medium" },
] ]
end end
@ -332,7 +332,7 @@ class TestFilters < JekyllUnitTest
page_url = "about/my_favorite_page/" page_url = "about/my_favorite_page/"
filter = make_filter_mock({ filter = make_filter_mock({
"url" => "http://example.com", "url" => "http://example.com",
"baseurl" => "base" "baseurl" => "base",
}) })
assert_equal "http://example.com/base/#{page_url}", filter.absolute_url(page_url) assert_equal "http://example.com/base/#{page_url}", filter.absolute_url(page_url)
end end
@ -341,7 +341,7 @@ class TestFilters < JekyllUnitTest
page_url = "about/my_favorite_page/" page_url = "about/my_favorite_page/"
filter = make_filter_mock({ filter = make_filter_mock({
"url" => "", "url" => "",
"baseurl" => "base" "baseurl" => "base",
}) })
assert_equal "/base/#{page_url}", filter.absolute_url(page_url) assert_equal "/base/#{page_url}", filter.absolute_url(page_url)
end end
@ -350,7 +350,7 @@ class TestFilters < JekyllUnitTest
page_url = "about/my_favorite_page/" page_url = "about/my_favorite_page/"
filter = make_filter_mock({ filter = make_filter_mock({
"url" => nil, "url" => nil,
"baseurl" => "base" "baseurl" => "base",
}) })
assert_equal "/base/#{page_url}", filter.absolute_url(page_url) assert_equal "/base/#{page_url}", filter.absolute_url(page_url)
end end
@ -359,7 +359,7 @@ class TestFilters < JekyllUnitTest
page_url = "about/my_favorite_page/" page_url = "about/my_favorite_page/"
filter = make_filter_mock({ filter = make_filter_mock({
"url" => "http://example.com", "url" => "http://example.com",
"baseurl" => nil "baseurl" => nil,
}) })
assert_equal "http://example.com/#{page_url}", filter.absolute_url(page_url) assert_equal "http://example.com/#{page_url}", filter.absolute_url(page_url)
end end
@ -368,7 +368,7 @@ class TestFilters < JekyllUnitTest
page_url = "" page_url = ""
filter = make_filter_mock({ filter = make_filter_mock({
"url" => "http://example.com", "url" => "http://example.com",
"baseurl" => "/base" "baseurl" => "/base",
}) })
assert_equal "http://example.com/base", filter.absolute_url(page_url) assert_equal "http://example.com/base", filter.absolute_url(page_url)
end end
@ -377,7 +377,7 @@ class TestFilters < JekyllUnitTest
page_url = "" page_url = ""
filter = make_filter_mock({ filter = make_filter_mock({
"url" => "http://ümlaut.example.org/", "url" => "http://ümlaut.example.org/",
"baseurl" => nil "baseurl" => nil,
}) })
assert_equal "http://xn--mlaut-jva.example.org/", filter.absolute_url(page_url) assert_equal "http://xn--mlaut-jva.example.org/", filter.absolute_url(page_url)
end end
@ -409,7 +409,7 @@ class TestFilters < JekyllUnitTest
page_url = "about/my_favorite_page/" page_url = "about/my_favorite_page/"
filter = make_filter_mock({ filter = make_filter_mock({
"url" => "http://example.com", "url" => "http://example.com",
"baseurl" => nil "baseurl" => nil,
}) })
assert_equal "/#{page_url}", filter.relative_url(page_url) assert_equal "/#{page_url}", filter.relative_url(page_url)
end end
@ -418,7 +418,7 @@ class TestFilters < JekyllUnitTest
page_url = "" page_url = ""
filter = make_filter_mock({ filter = make_filter_mock({
"url" => "http://example.com", "url" => "http://example.com",
"baseurl" => "/base" "baseurl" => "/base",
}) })
assert_equal "/base", filter.relative_url(page_url) assert_equal "/base", filter.relative_url(page_url)
end end
@ -451,7 +451,7 @@ class TestFilters < JekyllUnitTest
"excerpt" => "<p>This should be published.</p>\n", "excerpt" => "<p>This should be published.</p>\n",
"draft" => false, "draft" => false,
"categories" => [ "categories" => [
"publish_test" "publish_test",
], ],
"layout" => "default", "layout" => "default",
"title" => "Publish", "title" => "Publish",
@ -459,7 +459,7 @@ class TestFilters < JekyllUnitTest
"date" => "2008-02-02 00:00:00 +0000", "date" => "2008-02-02 00:00:00 +0000",
"slug" => "published", "slug" => "published",
"ext" => ".markdown", "ext" => ".markdown",
"tags" => [] "tags" => [],
} }
actual = JSON.parse(@filter.jsonify(@filter.site.docs_to_write.first.to_liquid)) actual = JSON.parse(@filter.jsonify(@filter.site.docs_to_write.first.to_liquid))
@ -475,7 +475,7 @@ class TestFilters < JekyllUnitTest
actual = @filter.jsonify(@filter.site.to_liquid) actual = @filter.jsonify(@filter.site.to_liquid)
assert_equal JSON.parse(actual)["jekyll"], { assert_equal JSON.parse(actual)["jekyll"], {
"environment" => "development", "environment" => "development",
"version" => Jekyll::VERSION "version" => Jekyll::VERSION,
} }
end end
@ -491,7 +491,7 @@ class TestFilters < JekyllUnitTest
"name" => name, "name" => name,
:v => 1, :v => 1,
:thing => M.new({ :kay => "jewelers" }), :thing => M.new({ :kay => "jewelers" }),
:stuff => true :stuff => true,
} }
end end
end end
@ -503,21 +503,21 @@ class TestFilters < JekyllUnitTest
"v" => 1, "v" => 1,
"thing" => [ "thing" => [
{ {
"kay" => "jewelers" "kay" => "jewelers",
} },
], ],
"stuff" => true "stuff" => true,
}, },
{ {
"name" => "Smathers", "name" => "Smathers",
"v" => 1, "v" => 1,
"thing" => [ "thing" => [
{ {
"kay" => "jewelers" "kay" => "jewelers",
} },
], ],
"stuff" => true "stuff" => true,
} },
] ]
result = @filter.jsonify([T.new("Jeremiah"), T.new("Smathers")]) result = @filter.jsonify([T.new("Jeremiah"), T.new("Smathers")])
assert_equal expected, JSON.parse(result) assert_equal expected, JSON.parse(result)
@ -533,32 +533,32 @@ class TestFilters < JekyllUnitTest
"v" => 1, "v" => 1,
"thing" => [ "thing" => [
{ {
"kay" => "jewelers" "kay" => "jewelers",
} },
], ],
"stuff" => true "stuff" => true,
}, },
{ {
"name" => 1, "name" => 1,
"v" => 1, "v" => 1,
"thing" => [ "thing" => [
{ {
"kay" => "jewelers" "kay" => "jewelers",
} },
], ],
"stuff" => true "stuff" => true,
}, },
{ {
"name" => 2, "name" => 2,
"v" => 1, "v" => 1,
"thing" => [ "thing" => [
{ {
"kay" => "jewelers" "kay" => "jewelers",
} },
],
"stuff" => true,
},
], ],
"stuff" => true
}
]
} }
result = @filter.jsonify(my_hash) result = @filter.jsonify(my_hash)
assert_equal expected, JSON.parse(result) assert_equal expected, JSON.parse(result)
@ -633,7 +633,7 @@ class TestFilters < JekyllUnitTest
hash = { hash = {
"a" => { "tags"=>%w(x y) }, "a" => { "tags"=>%w(x y) },
"b" => { "tags"=>["x"] }, "b" => { "tags"=>["x"] },
"c" => { "tags"=>%w(y z) } "c" => { "tags"=>%w(y z) },
} }
assert_equal 2, @filter.where(hash, "tags", "x").length assert_equal 2, @filter.where(hash, "tags", "x").length
end end
@ -642,7 +642,7 @@ class TestFilters < JekyllUnitTest
hash = { hash = {
"a" => { "tags"=>%w(x y) }, "a" => { "tags"=>%w(x y) },
"b" => { "tags"=>"x" }, "b" => { "tags"=>"x" },
"c" => { "tags"=>%w(y z) } "c" => { "tags"=>%w(y z) },
} }
assert_equal 2, @filter.where(hash, "tags", "x").length assert_equal 2, @filter.where(hash, "tags", "x").length
end end
@ -651,7 +651,7 @@ class TestFilters < JekyllUnitTest
hash = { hash = {
"a" => { "category"=>"bear" }, "a" => { "category"=>"bear" },
"b" => { "category"=>"wolf" }, "b" => { "category"=>"wolf" },
"c" => { "category"=>%w(bear lion) } "c" => { "category"=>%w(bear lion) },
} }
assert_equal 0, @filter.where(hash, "category", "ear").length assert_equal 0, @filter.where(hash, "category", "ear").length
end end
@ -660,7 +660,7 @@ class TestFilters < JekyllUnitTest
hash = { hash = {
"The Words" => { "rating" => 1.2, "featured" => false }, "The Words" => { "rating" => 1.2, "featured" => false },
"Limitless" => { "rating" => 9.2, "featured" => true }, "Limitless" => { "rating" => 9.2, "featured" => true },
"Hustle" => { "rating" => 4.7, "featured" => true } "Hustle" => { "rating" => 4.7, "featured" => true },
} }
results = @filter.where(hash, "featured", "true") results = @filter.where(hash, "featured", "true")
@ -704,7 +704,7 @@ class TestFilters < JekyllUnitTest
hash = { hash = {
"The Words" => { "rating" => 1.2, "featured" => false }, "The Words" => { "rating" => 1.2, "featured" => false },
"Limitless" => { "rating" => 9.2, "featured" => true }, "Limitless" => { "rating" => 9.2, "featured" => true },
"Hustle" => { "rating" => 4.7, "featured" => true } "Hustle" => { "rating" => 4.7, "featured" => true },
} }
results = @filter.where_exp(hash, "item", "item.featured == true") results = @filter.where_exp(hash, "item", "item.featured == true")
@ -725,7 +725,7 @@ class TestFilters < JekyllUnitTest
{ "id" => "a", "groups" => [1, 2] }, { "id" => "a", "groups" => [1, 2] },
{ "id" => "b", "groups" => [2, 3] }, { "id" => "b", "groups" => [2, 3] },
{ "id" => "c" }, { "id" => "c" },
{ "id" => "d", "groups" => [1, 3] } { "id" => "d", "groups" => [1, 3] },
] ]
should "filter with the contains operator over arrays" do should "filter with the contains operator over arrays" do
results = @filter.where_exp(objects, "obj", "obj.groups contains 1") results = @filter.where_exp(objects, "obj", "obj.groups contains 1")
@ -807,7 +807,7 @@ class TestFilters < JekyllUnitTest
items = [ items = [
{ "version"=>"1.0", "result"=>"slow" }, { "version"=>"1.0", "result"=>"slow" },
{ "version"=>"1.1.5", "result"=>"medium" }, { "version"=>"1.1.5", "result"=>"medium" },
{ "version"=>"2.7.3", "result"=>"fast" } { "version"=>"2.7.3", "result"=>"fast" },
] ]
result = @filter.group_by_exp(items, "item", "item.version | split: '.' | first") result = @filter.group_by_exp(items, "item", "item.version | split: '.' | first")

View File

@ -7,12 +7,12 @@ class TestFrontMatterDefaults < JekyllUnitTest
"defaults" => [{ "defaults" => [{
"scope" => { "scope" => {
"path" => "contacts", "path" => "contacts",
"type" => "page" "type" => "page",
}, },
"values" => { "values" => {
"key" => "val" "key" => "val",
} },
}] },],
}) })
@site.process @site.process
@affected = @site.pages.find { |page| page.relative_path == "contacts/bar.html" } @affected = @site.pages.find { |page| page.relative_path == "contacts/bar.html" }
@ -30,12 +30,12 @@ class TestFrontMatterDefaults < JekyllUnitTest
@site = fixture_site({ @site = fixture_site({
"defaults" => [{ "defaults" => [{
"scope" => { "scope" => {
"path" => "index.html" "path" => "index.html",
}, },
"values" => { "values" => {
"key" => "val" "key" => "val",
} },
}] },],
}) })
@site.process @site.process
@ -54,12 +54,12 @@ class TestFrontMatterDefaults < JekyllUnitTest
@site = fixture_site({ @site = fixture_site({
"defaults" => [{ "defaults" => [{
"scope" => { "scope" => {
"path" => "win" "path" => "win",
}, },
"values" => { "values" => {
"key" => "val" "key" => "val",
} },
}] },],
}) })
@site.process @site.process
@ -78,12 +78,12 @@ class TestFrontMatterDefaults < JekyllUnitTest
@site = fixture_site({ @site = fixture_site({
"defaults" => [{ "defaults" => [{
"scope" => { "scope" => {
"type" => "page" "type" => "page",
}, },
"values" => { "values" => {
"key" => "val" "key" => "val",
} },
}] },],
}) })
@site.process @site.process
@ -103,12 +103,12 @@ class TestFrontMatterDefaults < JekyllUnitTest
@site = fixture_site({ @site = fixture_site({
"defaults" => [{ "defaults" => [{
"scope" => { "scope" => {
"type" => "pages" "type" => "pages",
}, },
"values" => { "values" => {
"key" => "val" "key" => "val",
} },
}] },],
}) })
@site.process @site.process
@affected = @site.pages @affected = @site.pages
@ -129,9 +129,9 @@ class TestFrontMatterDefaults < JekyllUnitTest
"scope" => { "scope" => {
}, },
"values" => { "values" => {
"key" => "val" "key" => "val",
} },
}] },],
}) })
@site.process @site.process
@affected = @site.pages @affected = @site.pages
@ -149,9 +149,9 @@ class TestFrontMatterDefaults < JekyllUnitTest
@site = fixture_site({ @site = fixture_site({
"defaults" => [{ "defaults" => [{
"values" => { "values" => {
"key" => "val" "key" => "val",
} },
}] },],
}) })
@site.process @site.process
@affected = @site.pages @affected = @site.pages
@ -171,9 +171,9 @@ class TestFrontMatterDefaults < JekyllUnitTest
"destination" => dest_dir, "destination" => dest_dir,
"defaults" => [{ "defaults" => [{
"values" => { "values" => {
"date" => "2015-01-01 00:00:01" "date" => "2015-01-01 00:00:01",
} },
}] },],
})) }))
end end

View File

@ -16,9 +16,9 @@ class TestKramdown < JekyllUnitTest
"syntax_highlighter" => "rouge", "syntax_highlighter" => "rouge",
"syntax_highlighter_opts" => { "syntax_highlighter_opts" => {
"bold_every" => 8, "css" => :class "bold_every" => 8, "css" => :class,
} },
} },
} }
@config = Jekyll.configuration(@config) @config = Jekyll.configuration(@config)
@ -43,8 +43,8 @@ class TestKramdown < JekyllUnitTest
override = { override = {
"highlighter" => nil, "highlighter" => nil,
"kramdown" => { "kramdown" => {
"smart_quotes" => "lsaquo,rsaquo,laquo,raquo" "smart_quotes" => "lsaquo,rsaquo,laquo,raquo",
} },
} }
markdown = Converters::Markdown.new(Utils.deep_merge_hashes(@config, override)) markdown = Converters::Markdown.new(Utils.deep_merge_hashes(@config, override))
@ -70,8 +70,8 @@ class TestKramdown < JekyllUnitTest
"highlighter" => nil, "highlighter" => nil,
"markdown" => "kramdown", "markdown" => "kramdown",
"kramdown" => { "kramdown" => {
"syntax_highlighter" => :coderay "syntax_highlighter" => :coderay,
} },
} }
markdown = Converters::Markdown.new(Utils.deep_merge_hashes(@config, override)) markdown = Converters::Markdown.new(Utils.deep_merge_hashes(@config, override))
@ -89,8 +89,8 @@ class TestKramdown < JekyllUnitTest
override = { override = {
"markdown" => "kramdown", "markdown" => "kramdown",
"kramdown" => { "kramdown" => {
"enable_coderay" => true "enable_coderay" => true,
} },
} }
@config.delete("highlighter") @config.delete("highlighter")
@ -115,9 +115,9 @@ class TestKramdown < JekyllUnitTest
"kramdown" => { "kramdown" => {
"syntax_highlighter" => "coderay", "syntax_highlighter" => "coderay",
"coderay" => { "coderay" => {
"hello" => "world" "hello" => "world",
} },
} },
})) }))
expect(Kramdown::Document).to receive(:new) do |arg1, hash| expect(Kramdown::Document).to receive(:new) do |arg1, hash|

View File

@ -4,7 +4,7 @@ class TestLayoutReader < JekyllUnitTest
context "reading layouts" do context "reading layouts" do
setup do setup do
config = Jekyll::Configuration::DEFAULTS.merge({ "source" => source_dir, config = Jekyll::Configuration::DEFAULTS.merge({ "source" => source_dir,
"destination" => dest_dir }) "destination" => dest_dir, })
@site = fixture_site(config) @site = fixture_site(config)
end end

View File

@ -16,7 +16,7 @@ class TestLiquidRenderer < JekyllUnitTest
expected = [ expected = [
%r!^Filename\s+|\s+Count\s+|\s+Bytes\s+|\s+Time$!, %r!^Filename\s+|\s+Count\s+|\s+Bytes\s+|\s+Time$!,
%r!^-+\++-+\++-+\++-+$!, %r!^-+\++-+\++-+\++-+$!,
%r!^_posts/2010-01-09-date-override\.markdown\s+|\s+\d+\s+|\s+\d+\.\d{2}K\s+|\s+\d+\.\d{3}$! %r!^_posts/2010-01-09-date-override\.markdown\s+|\s+\d+\s+|\s+\d+\.\d{2}K\s+|\s+\d+\.\d{3}$!,
] ]
# rubocop:enable Metrics/LineLength # rubocop:enable Metrics/LineLength

View File

@ -12,7 +12,7 @@ class TestPage < JekyllUnitTest
def do_render(page) def do_render(page)
layouts = { layouts = {
"default" => Layout.new(@site, source_dir("_layouts"), "simple.html") "default" => Layout.new(@site, source_dir("_layouts"), "simple.html"),
} }
page.render(layouts, @site.site_payload) page.render(layouts, @site.site_payload)
end end
@ -23,7 +23,7 @@ class TestPage < JekyllUnitTest
@site = Site.new(Jekyll.configuration({ @site = Site.new(Jekyll.configuration({
"source" => source_dir, "source" => source_dir,
"destination" => dest_dir, "destination" => dest_dir,
"skip_config_files" => true "skip_config_files" => true,
})) }))
end end
@ -90,7 +90,7 @@ class TestPage < JekyllUnitTest
:permalink => "/properties/", :permalink => "/properties/",
:published => nil, :published => nil,
:title => "Properties Page", :title => "Properties Page",
:url => "/properties/" :url => "/properties/",
} }
attrs.each do |attr, val| attrs.each do |attr, val|

View File

@ -68,7 +68,7 @@ class TestPluginManager < JekyllUnitTest
should "require plugin files" do should "require plugin files" do
site = double({ :safe => false, site = double({ :safe => false,
:config => { "plugins_dir" => "_plugins" }, :config => { "plugins_dir" => "_plugins" },
:in_source_dir => "/tmp/" }) :in_source_dir => "/tmp/", })
plugin_manager = PluginManager.new(site) plugin_manager = PluginManager.new(site)
expect(Jekyll::External).to receive(:require_with_graceful_fail) expect(Jekyll::External).to receive(:require_with_graceful_fail)
@ -98,9 +98,9 @@ class TestPluginManager < JekyllUnitTest
should "call site's in_source_dir" do should "call site's in_source_dir" do
site = double({ site = double({
:config => { :config => {
"plugins_dir" => Jekyll::Configuration::DEFAULTS["plugins_dir"] "plugins_dir" => Jekyll::Configuration::DEFAULTS["plugins_dir"],
}, },
:in_source_dir => "/tmp/" :in_source_dir => "/tmp/",
}) })
plugin_manager = PluginManager.new(site) plugin_manager = PluginManager.new(site)
@ -132,7 +132,7 @@ class TestPluginManager < JekyllUnitTest
should "print no deprecation warning if jekyll-paginate is present" do should "print no deprecation warning if jekyll-paginate is present" do
site = double({ site = double({
:config => { "paginate" => true, "gems" => ["jekyll-paginate"] } :config => { "paginate" => true, "gems" => ["jekyll-paginate"] },
}) })
plugin_manager = PluginManager.new(site) plugin_manager = PluginManager.new(site)

View File

@ -13,8 +13,8 @@ class TestRdiscount < JekyllUnitTest
"markdown" => "rdiscount", "markdown" => "rdiscount",
"rdiscount" => { "rdiscount" => {
"toc_token" => "{:toc}", "toc_token" => "{:toc}",
"extensions" => %w(smart generate_toc) "extensions" => %w(smart generate_toc),
} },
} }
@markdown = Converters::Markdown.new config @markdown = Converters::Markdown.new config

View File

@ -12,8 +12,8 @@ class TestRedcarpet < JekyllUnitTest
@config = { @config = {
"markdown" => "redcarpet", "markdown" => "redcarpet",
"redcarpet" => { "redcarpet" => {
"extensions" => %w(smart strikethrough filter_html) "extensions" => %w(smart strikethrough filter_html),
} },
} }
@markdown = Converters::Markdown.new @config @markdown = Converters::Markdown.new @config

View File

@ -8,10 +8,10 @@ class TestRegenerator < JekyllUnitTest
@site = fixture_site({ @site = fixture_site({
"collections" => { "collections" => {
"methods" => { "methods" => {
"output" => true "output" => true,
}
}, },
"incremental" => true },
"incremental" => true,
}) })
@site.read @site.read
@ -92,7 +92,7 @@ class TestRegenerator < JekyllUnitTest
setup do setup do
FileUtils.rm_rf(source_dir(".jekyll-metadata")) FileUtils.rm_rf(source_dir(".jekyll-metadata"))
@site = fixture_site({ @site = fixture_site({
"incremental" => true "incremental" => true,
}) })
@site.read @site.read
@ -129,7 +129,7 @@ class TestRegenerator < JekyllUnitTest
@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,
})) }))
@site.process @site.process
@ -311,7 +311,7 @@ class TestRegenerator < JekyllUnitTest
@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,
})) }))
@site.process @site.process

View File

@ -28,7 +28,7 @@ class TestRelatedPosts < JekyllUnitTest
allow_any_instance_of(Jekyll::RelatedPosts).to receive(:display) allow_any_instance_of(Jekyll::RelatedPosts).to receive(:display)
@site = fixture_site({ @site = fixture_site({
"lsi" => true "lsi" => true,
}) })
@site.reset @site.reset

View File

@ -5,7 +5,7 @@ class TestSass < JekyllUnitTest
setup do setup do
@site = Jekyll::Site.new(Jekyll.configuration({ @site = Jekyll::Site.new(Jekyll.configuration({
"source" => source_dir, "source" => source_dir,
"destination" => dest_dir "destination" => dest_dir,
})) }))
@site.process @site.process
@test_css_file = dest_dir("css/main.css") @test_css_file = dest_dir("css/main.css")

View File

@ -20,7 +20,7 @@ class TestSite < JekyllUnitTest
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({ site = Site.new(site_configuration({
"plugins_dir" => ["/tmp/plugins", "/tmp/otherplugins"] "plugins_dir" => ["/tmp/plugins", "/tmp/otherplugins"],
})) }))
array = if Utils::Platforms.windows? array = if Utils::Platforms.windows?
["C:/tmp/plugins", "C:/tmp/otherplugins"] ["C:/tmp/plugins", "C:/tmp/otherplugins"]
@ -485,7 +485,7 @@ class TestSite < JekyllUnitTest
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" }
@ -499,7 +499,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" }
@ -565,7 +565,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

View File

@ -95,8 +95,8 @@ class TestStaticFile < JekyllUnitTest
should "use the _config.yml defaults to determine writability" do should "use the _config.yml defaults to determine writability" do
defaults = [{ defaults = [{
"scope" => { "path" => "private" }, "scope" => { "path" => "private" },
"values" => { "published" => false } "values" => { "published" => false },
}] },]
static_file = setup_static_file_with_defaults( static_file = setup_static_file_with_defaults(
"root", "root",
"private/dir/subdir", "private/dir/subdir",
@ -146,7 +146,7 @@ class TestStaticFile < JekyllUnitTest
"name" => "static_file.txt", "name" => "static_file.txt",
"extname" => ".txt", "extname" => ".txt",
"modified_time" => @static_file.modified_time, "modified_time" => @static_file.modified_time,
"path" => "/static_file.txt" "path" => "/static_file.txt",
} }
assert_equal expected, @static_file.to_liquid assert_equal expected, @static_file.to_liquid
end end

View File

@ -17,7 +17,7 @@ class TestTags < JekyllUnitTest
info = { :filters => [Jekyll::Filters], :registers => { :site => site } } info = { :filters => [Jekyll::Filters], :registers => { :site => site } }
@converter = site.converters.find { |c| c.class == converter_class } @converter = site.converters.find { |c| c.class == converter_class }
payload = { "highlighter_prefix" => @converter.highlighter_prefix, payload = { "highlighter_prefix" => @converter.highlighter_prefix,
"highlighter_suffix" => @converter.highlighter_suffix } "highlighter_suffix" => @converter.highlighter_suffix, }
@result = Liquid::Template.parse(content).render!(payload, info) @result = Liquid::Template.parse(content).render!(payload, info)
@result = @converter.convert(@result) @result = @converter.convert(@result)
@ -487,7 +487,7 @@ CONTENT
end end
create_post(@content, { create_post(@content, {
"markdown" => "rdiscount" "markdown" => "rdiscount",
}) })
end end
@ -517,7 +517,7 @@ CONTENT
end end
create_post(@content, { create_post(@content, {
"markdown" => "redcarpet" "markdown" => "redcarpet",
}) })
end end
@ -541,7 +541,7 @@ CONTENT
"permalink" => "pretty", "permalink" => "pretty",
"source" => source_dir, "source" => source_dir,
"destination" => dest_dir, "destination" => dest_dir,
"read_posts" => true "read_posts" => true,
}) })
end end
@ -567,7 +567,7 @@ CONTENT
"permalink" => "pretty", "permalink" => "pretty",
"source" => source_dir, "source" => source_dir,
"destination" => dest_dir, "destination" => dest_dir,
"read_posts" => true "read_posts" => true,
}) })
end end
@ -596,7 +596,7 @@ CONTENT
"permalink" => "pretty", "permalink" => "pretty",
"source" => source_dir, "source" => source_dir,
"destination" => dest_dir, "destination" => dest_dir,
"read_posts" => true "read_posts" => true,
}) })
end end
@ -628,7 +628,7 @@ CONTENT
"permalink" => "pretty", "permalink" => "pretty",
"source" => source_dir, "source" => source_dir,
"destination" => dest_dir, "destination" => dest_dir,
"read_posts" => true "read_posts" => true,
}) })
end end
@ -664,7 +664,7 @@ CONTENT
"permalink" => "pretty", "permalink" => "pretty",
"source" => source_dir, "source" => source_dir,
"destination" => dest_dir, "destination" => dest_dir,
"read_posts" => true "read_posts" => true,
}) })
end end
end end
@ -683,7 +683,7 @@ CONTENT
"permalink" => "pretty", "permalink" => "pretty",
"source" => source_dir, "source" => source_dir,
"destination" => dest_dir, "destination" => dest_dir,
"read_posts" => true "read_posts" => true,
}) })
end end
end end
@ -703,7 +703,7 @@ CONTENT
create_post(content, { create_post(content, {
"source" => source_dir, "source" => source_dir,
"destination" => dest_dir, "destination" => dest_dir,
"read_all" => true "read_all" => true,
}) })
end end
@ -737,7 +737,7 @@ CONTENT
"source" => source_dir, "source" => source_dir,
"destination" => dest_dir, "destination" => dest_dir,
"collections" => { "methods" => { "output" => true } }, "collections" => { "methods" => { "output" => true } },
"read_collections" => true "read_collections" => true,
}) })
end end
@ -764,7 +764,7 @@ CONTENT
"source" => source_dir, "source" => source_dir,
"destination" => dest_dir, "destination" => dest_dir,
"collections" => { "methods" => { "output" => true } }, "collections" => { "methods" => { "output" => true } },
"read_collections" => true "read_collections" => true,
}) })
end end
@ -796,7 +796,7 @@ CONTENT
"source" => source_dir, "source" => source_dir,
"destination" => dest_dir, "destination" => dest_dir,
"collections" => { "methods" => { "output" => true } }, "collections" => { "methods" => { "output" => true } },
"read_collections" => true "read_collections" => true,
}) })
end end
end end
@ -820,7 +820,7 @@ CONTENT
"source" => source_dir, "source" => source_dir,
"destination" => dest_dir, "destination" => dest_dir,
"read_posts" => true, "read_posts" => true,
"safe" => true "safe" => true,
}) })
end end
@result ||= "" @result ||= ""
@ -842,7 +842,7 @@ CONTENT
"source" => source_dir, "source" => source_dir,
"destination" => dest_dir, "destination" => dest_dir,
"read_posts" => true, "read_posts" => true,
"safe" => true "safe" => true,
}) })
end end
assert_match( assert_match(
@ -868,7 +868,7 @@ CONTENT
"permalink" => "pretty", "permalink" => "pretty",
"source" => source_dir, "source" => source_dir,
"destination" => dest_dir, "destination" => dest_dir,
"read_posts" => true "read_posts" => true,
}) })
end end
@ -896,7 +896,7 @@ CONTENT
"permalink" => "pretty", "permalink" => "pretty",
"source" => source_dir, "source" => source_dir,
"destination" => dest_dir, "destination" => dest_dir,
"read_posts" => true "read_posts" => true,
}) })
end end
@ -913,7 +913,7 @@ CONTENT
"permalink" => "pretty", "permalink" => "pretty",
"source" => source_dir, "source" => source_dir,
"destination" => dest_dir, "destination" => dest_dir,
"read_posts" => true "read_posts" => true,
}) })
end end
end end
@ -932,7 +932,7 @@ CONTENT
"permalink" => "pretty", "permalink" => "pretty",
"source" => source_dir, "source" => source_dir,
"destination" => dest_dir, "destination" => dest_dir,
"read_posts" => true "read_posts" => true,
}) })
end end
@ -959,7 +959,7 @@ CONTENT
"permalink" => "pretty", "permalink" => "pretty",
"source" => source_dir, "source" => source_dir,
"destination" => dest_dir, "destination" => dest_dir,
"read_posts" => true "read_posts" => true,
}) })
end end
@ -982,7 +982,7 @@ CONTENT
"permalink" => "pretty", "permalink" => "pretty",
"source" => source_dir, "source" => source_dir,
"destination" => dest_dir, "destination" => dest_dir,
"read_posts" => true "read_posts" => true,
}) })
end end
@ -1004,7 +1004,7 @@ CONTENT
"permalink" => "pretty", "permalink" => "pretty",
"source" => source_dir, "source" => source_dir,
"destination" => dest_dir, "destination" => dest_dir,
"read_posts" => true "read_posts" => true,
}) })
end end
@ -1030,7 +1030,7 @@ CONTENT
"permalink" => "pretty", "permalink" => "pretty",
"source" => source_dir, "source" => source_dir,
"destination" => dest_dir, "destination" => dest_dir,
"read_posts" => true "read_posts" => true,
}) })
end end
assert_match( assert_match(
@ -1125,7 +1125,7 @@ CONTENT
"permalink" => "pretty", "permalink" => "pretty",
"source" => source_dir, "source" => source_dir,
"destination" => dest_dir, "destination" => dest_dir,
"read_posts" => true "read_posts" => true,
}) })
end end
assert_match "Could not locate the included file 'missing.html' in any of " \ assert_match "Could not locate the included file 'missing.html' in any of " \
@ -1150,7 +1150,7 @@ CONTENT
"permalink" => "pretty", "permalink" => "pretty",
"source" => source_dir, "source" => source_dir,
"destination" => dest_dir, "destination" => dest_dir,
"read_posts" => true "read_posts" => true,
}) })
end end
assert_equal( assert_equal(
@ -1180,7 +1180,7 @@ CONTENT
"source" => source_dir, "source" => source_dir,
"destination" => dest_dir, "destination" => dest_dir,
"read_posts" => true, "read_posts" => true,
"safe" => true "safe" => true,
}) })
end end
@result ||= "" @result ||= ""
@ -1202,7 +1202,7 @@ CONTENT
"source" => source_dir, "source" => source_dir,
"destination" => dest_dir, "destination" => dest_dir,
"read_posts" => true, "read_posts" => true,
"safe" => true "safe" => true,
}) })
end end
assert_match( assert_match(