jekyll-3.0.1/ 0000755 0001750 0001750 00000000000 12623014201 012630 5 ustar uwabami uwabami jekyll-3.0.1/benchmark/ 0000755 0001750 0001750 00000000000 12623014201 014562 5 ustar uwabami uwabami jekyll-3.0.1/benchmark/jekyll-sanitize-path 0000644 0001750 0001750 00000003037 12623014201 020560 0 ustar uwabami uwabami #!/usr/bin/env ruby require_relative '../lib/jekyll' require 'benchmark/ips' base_directory = Dir.pwd Benchmark.ips do |x| # # Does not include the base_directory # x.report('with no questionable path') do Jekyll.sanitized_path(base_directory, '') end x.report('with a single-part questionable path') do Jekyll.sanitized_path(base_directory, 'thingy') end x.report('with a multi-part questionable path') do Jekyll.sanitized_path(base_directory, 'thingy/in/my/soup') end x.report('with a single-part traversal path') do Jekyll.sanitized_path(base_directory, '../thingy') end x.report('with a multi-part traversal path') do Jekyll.sanitized_path(base_directory, '../thingy/in/my/../../soup') end # # Including the base_directory # x.report('with the exact same paths') do Jekyll.sanitized_path(base_directory, base_directory) end x.report('with a single-part absolute path including the base_directory') do Jekyll.sanitized_path(base_directory, File.join(base_directory, 'thingy')) end x.report('with a multi-part absolute path including the base_directory') do Jekyll.sanitized_path(base_directory, File.join(base_directory, 'thingy/in/my/soup')) end x.report('with a single-part traversal path including the base_directory') do Jekyll.sanitized_path(base_directory, File.join(base_directory, 'thingy/..')) end x.report('with a multi-part traversal path including the base_directory') do Jekyll.sanitized_path(base_directory, File.join('thingy/in/my/../../soup')) end end jekyll-3.0.1/benchmark/end-with-vs-regexp 0000644 0001750 0001750 00000001002 12623014201 020133 0 ustar uwabami uwabami require 'benchmark/ips' Benchmark.ips do |x| path_without_ending_slash = '/some/very/very/long/path/to/a/file/i/like' x.report('no slash regexp') { path_without_ending_slash =~ /\/$/ } x.report('no slash end_with?') { path_without_ending_slash.end_with?("/") } end Benchmark.ips do |x| path_with_ending_slash = '/some/very/very/long/path/to/a/file/i/like/' x.report('slash regexp') { path_with_ending_slash =~ /\/$/ } x.report('slash end_with?') { path_with_ending_slash.end_with?("/") } end jekyll-3.0.1/benchmark/sequential-assignment 0000644 0001750 0001750 00000000256 12623014201 021030 0 ustar uwabami uwabami require 'benchmark/ips' Benchmark.ips do |x| x.report('parallel assignment') do a, b = 1, 2 end x.report('multi-line assignment') do a = 1 b = 2 end end jekyll-3.0.1/benchmark/string-replacement 0000644 0001750 0001750 00000000556 12623014201 020316 0 ustar uwabami uwabami require 'benchmark/ips' def str 'http://baruco.org/2014/some-talk-with-some-amount-of-value' end Benchmark.ips do |x| x.report('#tr') { str.tr('some', 'a') } x.report('#gsub') { str.gsub('some', 'a') } x.report('#gsub!') { str.gsub!('some', 'a') } x.report('#sub') { str.sub('some', 'a') } x.report('#sub!') { str.sub!('some', 'a') } end jekyll-3.0.1/benchmark/string-concat 0000644 0001750 0001750 00000000217 12623014201 017260 0 ustar uwabami uwabami require 'benchmark/ips' url = "http://jekyllrb.com" Benchmark.ips do |x| x.report('+=') { url += '/' } x.report('<<') { url << '/' } end jekyll-3.0.1/benchmark/proc-call-vs-yield 0000644 0001750 0001750 00000000312 12623014201 020107 0 ustar uwabami uwabami require 'benchmark/ips' def fast yield end def slow(&block) block.call end Benchmark.ips do |x| x.report('yield') { fast { (0..9).to_a } } x.report('block.call') { slow { (0..9).to_a } } end jekyll-3.0.1/benchmark/symbol-to-proc 0000644 0001750 0001750 00000000225 12623014201 017372 0 ustar uwabami uwabami require 'benchmark/ips' Benchmark.ips do |x| x.report('block') { (1..100).map { |i| i.to_s } } x.report('&:to_s') { (1..100).map(&:to_s) } end jekyll-3.0.1/benchmark/flat-map 0000644 0001750 0001750 00000000757 12623014201 016217 0 ustar uwabami uwabami require 'benchmark/ips' enum = (0..50).to_a nested = enum.map { |i| [i] } def do_thing(blah) blah * 1 end Benchmark.ips do |x| x.report('.map.flatten with nested arrays') { nested.map { |i| do_thing(i) }.flatten(1) } x.report('.flat_map with nested arrays') { nested.flat_map { |i| do_thing(i) } } x.report('.map.flatten with no nested arrays') { enum.map { |i| do_thing(i) }.flatten(1) } x.report('.flat_map with no nested arrays') { enum.flat_map { |i| do_thing(i) } } end jekyll-3.0.1/benchmark/hash-fetch 0000644 0001750 0001750 00000000423 12623014201 016516 0 ustar uwabami uwabami require 'benchmark/ips' h = {:bar => 'uco'} Benchmark.ips do |x| x.report('fetch with no block') { h.fetch(:bar, (0..9).to_a) } x.report('fetch with a block') { h.fetch(:bar) { (0..9).to_a } } x.report('brackets with an ||') { h[:bar] || (0..9).to_a } end jekyll-3.0.1/test/ 0000755 0001750 0001750 00000000000 12623014201 013607 5 ustar uwabami uwabami jekyll-3.0.1/test/test_kramdown.rb 0000644 0001750 0001750 00000004451 12623014201 017021 0 ustar uwabami uwabami # encoding: UTF-8 require 'helper' class TestKramdown < JekyllUnitTest context "kramdown" do setup do @config = { 'markdown' => 'kramdown', 'kramdown' => { 'auto_ids' => false, 'footnote_nr' => 1, 'entity_output' => 'as_char', 'toc_levels' => '1..6', 'smart_quotes' => 'lsquo,rsquo,ldquo,rdquo', 'enable_coderay' => true, 'coderay_bold_every'=> 12, 'coderay' => { 'coderay_css' => :style, 'coderay_bold_every' => 8 } } } @config = Jekyll.configuration(@config) @markdown = Converters::Markdown.new(@config) end # http://kramdown.gettalong.org/converter/html.html#options should "pass kramdown options" do assert_equal "
(“|“)Pit(’|’)hy(”|”)<\/p>/, @markdown.convert(%{"Pit'hy"}).strip override = { 'kramdown' => { 'smart_quotes' => 'lsaquo,rsaquo,laquo,raquo' } } markdown = Converters::Markdown.new(Utils.deep_merge_hashes(@config, override)) assert_match /
(«|«)Pit(›|›)hy(»|»)<\/p>/, markdown.convert(%{"Pit'hy"}).strip end should "render fenced code blocks with syntax highlighting" do assert_equal "
puts \"Hello world\"\n
\n“smart”
", @markdown.convert('"smart"').strip end should "render toc" do toc = <<-TOCsomething really simple
\n", @filter.markdownify("something **really** simple") end should "sassify with simple string" do assert_equal "p {\n color: #123456; }\n", @filter.sassify("$blue:#123456\np\n color: $blue") end should "scssify with simple string" do assert_equal "p {\n color: #123456; }\n", @filter.scssify("$blue:#123456; p{color: $blue}") end should "convert array to sentence string with no args" do assert_equal "", @filter.array_to_sentence_string([]) end should "convert array to sentence string with one arg" do assert_equal "1", @filter.array_to_sentence_string([1]) assert_equal "chunky", @filter.array_to_sentence_string(["chunky"]) end should "convert array to sentence string with two args" do assert_equal "1 and 2", @filter.array_to_sentence_string([1, 2]) assert_equal "chunky and bacon", @filter.array_to_sentence_string(["chunky", "bacon"]) end should "convert array to sentence string with multiple args" do assert_equal "1, 2, 3, and 4", @filter.array_to_sentence_string([1, 2, 3, 4]) assert_equal "chunky, bacon, bits, and pieces", @filter.array_to_sentence_string(["chunky", "bacon", "bits", "pieces"]) end context "date filters" do context "with Time object" do should "format a date with short format" do assert_equal "27 Mar 2013", @filter.date_to_string(@sample_time) end should "format a date with long format" do assert_equal "27 March 2013", @filter.date_to_long_string(@sample_time) end should "format a time with xmlschema" do assert_equal "2013-03-27T11:22:33+00:00", @filter.date_to_xmlschema(@sample_time) end should "format a time according to RFC-822" do assert_equal "Wed, 27 Mar 2013 11:22:33 +0000", @filter.date_to_rfc822(@sample_time) end end context "with Date object" do should "format a date with short format" do assert_equal "27 Mar 2013", @filter.date_to_string(@sample_date) end should "format a date with long format" do assert_equal "27 March 2013", @filter.date_to_long_string(@sample_date) end should "format a time with xmlschema" do assert_equal "2013-03-27T00:00:00+00:00", @filter.date_to_xmlschema(@sample_date) end should "format a time according to RFC-822" do assert_equal "Wed, 27 Mar 2013 00:00:00 +0000", @filter.date_to_rfc822(@sample_date) end end context "with String object" do should "format a date with short format" do assert_equal "11 Sep 2001", @filter.date_to_string(@time_as_string) end should "format a date with long format" do assert_equal "11 September 2001", @filter.date_to_long_string(@time_as_string) end should "format a time with xmlschema" do assert_equal "2001-09-11T12:46:30+00:00", @filter.date_to_xmlschema(@time_as_string) end should "format a time according to RFC-822" do assert_equal "Tue, 11 Sep 2001 12:46:30 +0000", @filter.date_to_rfc822(@time_as_string) end end context "with a Numeric object" do should "format a date with short format" do assert_equal "10 May 2014", @filter.date_to_string(@time_as_numeric) end should "format a date with long format" do assert_equal "10 May 2014", @filter.date_to_long_string(@time_as_numeric) end should "format a time with xmlschema" do assert_match /2014-05-10T00:10:07/, @filter.date_to_xmlschema(@time_as_numeric) end should "format a time according to RFC-822" do assert_equal "Sat, 10 May 2014 00:10:07 +0000", @filter.date_to_rfc822(@time_as_numeric) end end end should "escape xml with ampersands" do assert_equal "AT&T", @filter.xml_escape("AT&T") assert_equal "<code>command <filename></code>", @filter.xml_escape("command <filename>
")
end
should "not error when xml escaping nil" do
assert_equal "", @filter.xml_escape(nil)
end
should "escape space as plus" do
assert_equal "my+things", @filter.cgi_escape("my things")
end
should "escape special characters" do
assert_equal "hey%21", @filter.cgi_escape("hey!")
end
should "escape space as %20" do
assert_equal "my%20things", @filter.uri_escape("my things")
end
context "jsonify filter" do
should "convert hash to json" do
assert_equal "{\"age\":18}", @filter.jsonify({:age => 18})
end
should "convert array to json" do
assert_equal "[1,2]", @filter.jsonify([1, 2])
assert_equal "[{\"name\":\"Jack\"},{\"name\":\"Smith\"}]", @filter.jsonify([{:name => 'Jack'}, {:name => 'Smith'}])
end
class M < Struct.new(:message)
def to_liquid
[message]
end
end
class T < Struct.new(:name)
def to_liquid
{ "name" => name, :v => 1, :thing => M.new({:kay => "jewelers"}), :stuff => true }
end
end
should "call #to_liquid " do
expected = [
{
"name" => "Jeremiah",
"v" => 1,
"thing" => [
{
"kay" => "jewelers"
}
],
"stuff" => true
},
{
"name" => "Smathers",
"v" => 1,
"thing" => [
{
"kay" => "jewelers"
}
],
"stuff" => true
}
]
result = @filter.jsonify([T.new("Jeremiah"), T.new("Smathers")])
assert_equal expected, JSON.parse(result)
end
should "handle hashes with all sorts of weird keys and values" do
my_hash = { "posts" => Array.new(3) { |i| T.new(i) } }
expected = {
"posts" => [
{
"name" => 0,
"v" => 1,
"thing" => [
{
"kay" => "jewelers"
}
],
"stuff" => true
},
{
"name" => 1,
"v" => 1,
"thing" => [
{
"kay" => "jewelers"
}
],
"stuff" => true
},
{
"name" => 2,
"v" => 1,
"thing" => [
{
"kay" => "jewelers"
}
],
"stuff" => true
}
]
}
result = @filter.jsonify(my_hash)
assert_equal expected, JSON.parse(result)
end
end
context "group_by filter" do
should "successfully group array of Jekyll::Page's" do
@filter.site.process
grouping = @filter.group_by(@filter.site.pages, "layout")
grouping.each do |g|
assert ["default", "nil", ""].include?(g["name"]), "#{g['name']} isn't a valid grouping."
case g["name"]
when "default"
assert g["items"].is_a?(Array), "The list of grouped items for 'default' is not an Array."
assert_equal 5, g["items"].size
when "nil"
assert g["items"].is_a?(Array), "The list of grouped items for 'nil' is not an Array."
assert_equal 2, g["items"].size
when ""
assert g["items"].is_a?(Array), "The list of grouped items for '' is not an Array."
assert_equal 11, g["items"].size
end
end
end
end
context "where filter" do
should "return any input that is not an array" do
assert_equal "some string", @filter.where("some string", "la", "le")
end
should "filter objects in a hash appropriately" do
hash = {"a"=>{"color"=>"red"}, "b"=>{"color"=>"blue"}}
assert_equal 1, @filter.where(hash, "color", "red").length
assert_equal [{"color"=>"red"}], @filter.where(hash, "color", "red")
end
should "filter objects appropriately" do
assert_equal 2, @filter.where(@array_of_objects, "color", "red").length
end
should "stringify during comparison for compatibility with liquid parsing" do
hash = {
"The Words" => {"rating" => 1.2, "featured" => false},
"Limitless" => {"rating" => 9.2, "featured" => true},
"Hustle" => {"rating" => 4.7, "featured" => true},
}
results = @filter.where(hash, "featured", "true")
assert_equal 2, results.length
assert_equal 9.2, results[0]["rating"]
assert_equal 4.7, results[1]["rating"]
results = @filter.where(hash, "rating", 4.7)
assert_equal 1, results.length
assert_equal 4.7, results[0]["rating"]
end
end
context "sort filter" do
should "raise Exception when input is nil" do
err = assert_raises ArgumentError do
@filter.sort(nil)
end
assert_equal "Cannot sort a null object.", err.message
end
should "return sorted numbers" do
assert_equal [1, 2, 2.2, 3], @filter.sort([3, 2.2, 2, 1])
end
should "return sorted strings" do
assert_equal ["10", "2"], @filter.sort(["10", "2"])
assert_equal [{"a" => "10"}, {"a" => "2"}], @filter.sort([{"a" => "10"}, {"a" => "2"}], "a")
assert_equal ["FOO", "Foo", "foo"], @filter.sort(["foo", "Foo", "FOO"])
assert_equal ["_foo", "foo", "foo_"], @filter.sort(["foo_", "_foo", "foo"])
# Cyrillic
assert_equal ["ВУЗ", "Вуз", "вуз"], @filter.sort(["Вуз", "вуз", "ВУЗ"])
assert_equal ["_вуз", "вуз", "вуз_"], @filter.sort(["вуз_", "_вуз", "вуз"])
# Hebrew
assert_equal ["אלף", "בית"], @filter.sort(["בית", "אלף"])
end
should "return sorted by property array" do
assert_equal [{"a" => 1}, {"a" => 2}, {"a" => 3}, {"a" => 4}],
@filter.sort([{"a" => 4}, {"a" => 3}, {"a" => 1}, {"a" => 2}], "a")
end
should "return sorted by property array with nils first" do
ary = [{"a" => 2}, {"b" => 1}, {"a" => 1}]
assert_equal [{"b" => 1}, {"a" => 1}, {"a" => 2}], @filter.sort(ary, "a")
assert_equal @filter.sort(ary, "a"), @filter.sort(ary, "a", "first")
end
should "return sorted by property array with nils last" do
assert_equal [{"a" => 1}, {"a" => 2}, {"b" => 1}],
@filter.sort([{"a" => 2}, {"b" => 1}, {"a" => 1}], "a", "last")
end
end
context "inspect filter" do
should "return a HTML-escaped string representation of an object" do
assert_equal "{"<a>"=>1}", @filter.inspect({ "" => 1 })
end
end
context "slugify filter" do
should "return a slugified string" do
assert_equal "q-bert-says", @filter.slugify(" Q*bert says @!#?@!")
end
should "return a slugified string with mode" do
assert_equal "q-bert-says-@!-@!", @filter.slugify(" Q*bert says @!#?@!", "pretty")
end
end
context "push filter" do
should "return a new array with the element pushed to the end" do
assert_equal %w{hi there bernie}, @filter.push(%w{hi there}, "bernie")
end
end
context "pop filter" do
should "return a new array with the last element popped" do
assert_equal %w{hi there}, @filter.pop(%w{hi there bernie})
end
should "allow multiple els to be popped" do
assert_equal %w{hi there bert}, @filter.pop(%w{hi there bert and ernie}, 2)
end
should "cast string inputs for # into nums" do
assert_equal %w{hi there bert}, @filter.pop(%w{hi there bert and ernie}, "2")
end
end
context "shift filter" do
should "return a new array with the element removed from the front" do
assert_equal %w{a friendly greeting}, @filter.shift(%w{just a friendly greeting})
end
should "allow multiple els to be shifted" do
assert_equal %w{bert and ernie}, @filter.shift(%w{hi there bert and ernie}, 2)
end
should "cast string inputs for # into nums" do
assert_equal %w{bert and ernie}, @filter.shift(%w{hi there bert and ernie}, "2")
end
end
context "unshift filter" do
should "return a new array with the element put at the front" do
assert_equal %w{aloha there bernie}, @filter.unshift(%w{there bernie}, "aloha")
end
end
end
end
jekyll-3.0.1/test/test_page.rb 0000644 0001750 0001750 00000022644 12623014201 016117 0 ustar uwabami uwabami require 'helper'
class TestPage < JekyllUnitTest
def setup_page(*args)
dir, file = args
dir, file = ['', dir] if file.nil?
@page = Page.new(@site, source_dir, dir, file)
end
def do_render(page)
layouts = { "default" => Layout.new(@site, source_dir('_layouts'), "simple.html")}
page.render(layouts, {"site" => {"posts" => []}})
end
context "A Page" do
setup do
clear_dest
@site = Site.new(Jekyll.configuration({
"source" => source_dir,
"destination" => dest_dir,
"skip_config_files" => true
}))
end
context "processing pages" do
should "create url based on filename" do
@page = setup_page('contacts.html')
assert_equal "/contacts.html", @page.url
end
should "not published when published yaml is false" do
@page = setup_page("unpublished.html")
assert_equal false, @page.published?
end
should "create url with non-alphabetic characters" do
@page = setup_page('+', '%# +.md')
assert_equal "/+/%25%23%20+.html", @page.url
end
context "in a directory hierarchy" do
should "create url based on filename" do
@page = setup_page('/contacts', 'bar.html')
assert_equal "/contacts/bar.html", @page.url
end
should "create index url based on filename" do
@page = setup_page('/contacts', 'index.html')
assert_equal "/contacts/", @page.url
end
end
should "deal properly with extensions" do
@page = setup_page('deal.with.dots.html')
assert_equal ".html", @page.ext
end
should "deal properly with dots" do
@page = setup_page('deal.with.dots.html')
@dest_file = dest_dir("deal.with.dots.html")
assert_equal "deal.with.dots", @page.basename
assert_equal "/deal.with.dots", @page.url
assert_equal @dest_file, @page.destination(dest_dir)
end
should "make properties accessible through #[]" do
page = setup_page('properties.html')
attrs = {
content: "All the properties.\n",
dir: "/properties/",
excerpt: nil,
foo: 'bar',
layout: 'default',
name: "properties.html",
path: "properties.html",
permalink: '/properties/',
published: nil,
title: 'Properties Page',
url: "/properties/"
}
attrs.each do |attr, val|
attr_str = attr.to_s
result = page[attr_str]
assert_equal val, result, "For test
}, @result
end
should "render markdown with pygments with line numbers" do
assert_match %{1 test
}, @result
end
end
context "post content has highlight with file reference" do
setup do
fill_post("./jekyll.gemspec", {'highlighter' => 'pygments'})
end
should "not embed the file" do
assert_match %{./jekyll.gemspec
}, @result
end
end
context "post content has highlight tag with UTF character" do
setup do
fill_post("Æ", {'highlighter' => 'pygments'})
end
should "render markdown with pygments line handling" do
assert_match %{Æ
}, @result
end
end
context "post content has highlight tag with preceding spaces & lines" do
setup do
code = <<-EOS
[,1] [,2]
[1,] FALSE TRUE
[2,] FALSE TRUE
EOS
fill_post(code, {'highlighter' => 'pygments'})
end
should "only strip the preceding newlines" do
assert_match %{ [,1] [,2]}, @result
end
end
context "post content has highlight tag with preceding spaces & lines in several places" do
setup do
code = <<-EOS
[,1] [,2]
[1,] FALSE TRUE
[2,] FALSE TRUE
EOS
fill_post(code, {'highlighter' => 'pygments'})
end
should "only strip the newlines which precede and succeed the entire block" do
assert_match " [,1] [,2]\n\n\n[1,] FALSE TRUE\n[2,] FALSE TRUE
", @result
end
end
context "post content has highlight tag with preceding spaces & Windows-style newlines" do
setup do
fill_post "\r\n\r\n\r\n [,1] [,2]", {'highlighter' => 'pygments'}
end
should "only strip the preceding newlines" do
assert_match %{ [,1] [,2]}, @result
end
end
context "post content has highlight tag with only preceding spaces" do
setup do
code = <<-EOS
[,1] [,2]
[1,] FALSE TRUE
[2,] FALSE TRUE
EOS
fill_post(code, {'highlighter' => 'pygments'})
end
should "only strip the preceding newlines" do
assert_match %{ [,1] [,2]}, @result
end
end
end
context "with the rouge highlighter" do
context "post content has highlight tag" do
setup do
fill_post("test")
end
should "render markdown with rouge" do
assert_match %{test
}, @result
end
should "render markdown with rouge with line numbers" do
assert_match %{1
test\n
}, @result
end
end
context "post content has highlight with file reference" do
setup do
fill_post("./jekyll.gemspec")
end
should "not embed the file" do
assert_match %{./jekyll.gemspec
}, @result
end
end
context "post content has highlight tag with UTF character" do
setup do
fill_post("Æ")
end
should "render markdown with pygments line handling" do
assert_match %{Æ
}, @result
end
end
context "post content has highlight tag with preceding spaces & lines" do
setup do
fill_post <<-EOS
[,1] [,2]
[1,] FALSE TRUE
[2,] FALSE TRUE
EOS
end
should "only strip the preceding newlines" do
assert_match %{ [,1] [,2]}, @result
end
end
context "post content has highlight tag with preceding spaces & lines in several places" do
setup do
fill_post <<-EOS
[,1] [,2]
[1,] FALSE TRUE
[2,] FALSE TRUE
EOS
end
should "only strip the newlines which precede and succeed the entire block" do
assert_match " [,1] [,2]\n\n\n[1,] FALSE TRUE\n[2,] FALSE TRUE
", @result
end
end
context "post content has highlight tag with preceding spaces & Windows-style newlines" do
setup do
fill_post "\r\n\r\n\r\n [,1] [,2]"
end
should "only strip the preceding newlines" do
assert_match %{ [,1] [,2]}, @result
end
end
context "post content has highlight tag with only preceding spaces" do
setup do
fill_post <<-EOS
[,1] [,2]
[1,] FALSE TRUE
[2,] FALSE TRUE
EOS
end
should "only strip the preceding newlines" do
assert_match %{ [,1] [,2]}, @result
end
end
end
context "simple post with markdown and pre tags" do
setup do
@content = < 'rdiscount'
})
end
should "parse correctly" do
assert_match %r{FIGHT!}, @result
assert_match %r{FINISH HIM}, @result
end
end
context "using Kramdown" do
setup do
create_post(@content, 'markdown' => 'kramdown')
end
should "parse correctly" do
assert_match %r{FIGHT!}, @result
assert_match %r{FINISH HIM}, @result
end
end
context "using Redcarpet" do
setup do
if jruby?
skip(
"JRuby does not perform well with CExt, test disabled."
)
end
create_post(@content, {
'markdown' => 'redcarpet'
})
end
should "parse correctly" do
assert_match %r{FIGHT!}, @result
assert_match %r{FINISH HIM}, @result
end
end
end
context "simple page with post linking" do
setup do
content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
end
should "not cause an error" do
refute_match /markdown\-html\-error/, @result
end
should "have the url to the \"complex\" post from 2008-11-21" do
assert_match %r{/2008/11/21/complex/}, @result
end
end
context "simple page with nested post linking" do
setup do
content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
end
should "not cause an error" do
refute_match /markdown\-html\-error/, @result
end
should "have the url to the \"complex\" post from 2008-11-21" do
assert_match %r{1\s/2008/11/21/complex/}, @result
assert_match %r{2\s/2008/11/21/complex/}, @result
end
should "have the url to the \"nested\" post from 2008-11-21" do
assert_match %r{3\s/2008/11/21/nested/}, @result
assert_match %r{4\s/2008/11/21/nested/}, @result
end
end
context "simple page with invalid post name linking" do
should "cause an error" do
content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
end
end
end
context "include tag with parameters" do
context "with symlink'd include" do
should "not allow symlink includes" do
File.open("tmp/pages-test", 'w') { |file| file.write("SYMLINK TEST") }
assert_raises IOError do
content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true, 'safe' => true })
end
refute_match /SYMLINK TEST/, @result
end
should "not expose the existence of symlinked files" do
ex = assert_raises IOError do
content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true, 'safe' => true })
end
assert_match /should exist and should not be a symlink/, ex.message
end
end
context "with one parameter" do
setup do
content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
end
should "correctly output include variable" do
assert_match "value", @result.strip
end
should "ignore parameters if unused" do
assert_match "
\nTom Preston-Werner\ngithub.com/mojombo
\n", @result
end
end
context "with invalid parameter syntax" do
should "throw a ArgumentError" do
content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
end
content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
end
end
end
context "with several parameters" do
setup do
content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
end
should "list all parameters" do
assert_match 'param1 = new_value ', @result
assert_match 'param2 = another ', @result
end
should "not include previously used parameters" do
assert_match "", @result
end
end
context "without parameters" do
setup do
content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
end
should "include file with empty parameters" do
assert_match "", @result
end
end
context "with custom includes directory" do
setup do
content = < '_includes_custom', 'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
end
should "include file from custom directory" do
assert_match "custom_included", @result
end
end
context "without parameters within if statement" do
setup do
content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
end
should "include file with empty parameters within if statement" do
assert_match "", @result
end
end
context "include missing file" do
setup do
@content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
end
assert_equal 'Included file \'_includes/missing.html\' not found', exception.message
end
end
context "include tag with variable and liquid filters" do
setup do
site = fixture_site({'pygments' => true}).tap(&:read).tap(&:render)
post = site.posts.docs.find {|p| p.basename.eql? "2013-12-17-include-variable-filters.markdown" }
@content = post.output
end
should "include file as variable with liquid filters" do
assert_match %r{1 included}, @content
assert_match %r{2 included}, @content
assert_match %r{3 included}, @content
end
should "include file as variable and liquid filters with arbitrary whitespace" do
assert_match %r{4 included}, @content
assert_match %r{5 included}, @content
assert_match %r{6 included}, @content
end
should "include file as variable and filters with additional parameters" do
assert_match 'var1 = foo ', @content
assert_match 'var2 = bar ', @content
end
should "include file as partial variable" do
assert_match %r{8 included}, @content
end
end
end
context "relative include tag with variable and liquid filters" do
setup do
site = fixture_site({'pygments' => true}).tap(&:read).tap(&:render)
post = site.posts.docs.find {|p| p.basename.eql? "2014-09-02-relative-includes.markdown" }
@content = post.output
end
should "include file as variable with liquid filters" do
assert_match %r{1 relative_include}, @content
assert_match %r{2 relative_include}, @content
assert_match %r{3 relative_include}, @content
end
should "include file as variable and liquid filters with arbitrary whitespace" do
assert_match %r{4 relative_include}, @content
assert_match %r{5 relative_include}, @content
assert_match %r{6 relative_include}, @content
end
should "include file as variable and filters with additional parameters" do
assert_match 'var1 = foo ', @content
assert_match 'var2 = bar ', @content
end
should "include file as partial variable" do
assert_match %r{8 relative_include}, @content
end
should "include files relative to self" do
assert_match %r{9 —\ntitle: Test Post Where YAML}, @content
end
context "trying to do bad stuff" do
context "include missing file" do
setup do
@content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
end
assert_equal 'Included file \'./missing.html\' not found', exception.message
end
end
context "include existing file above you" do
setup do
@content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
end
assert_equal "Invalid syntax for include tag. File contains invalid characters or sequences:\n\n ../README.markdown\n\nValid syntax:\n\n {% include_relative file.ext param='value' param2='value' %}\n\n", exception.message
end
end
end
context "with symlink'd include" do
should "not allow symlink includes" do
File.open("tmp/pages-test", 'w') { |file| file.write("SYMLINK TEST") }
assert_raises IOError do
content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true, 'safe' => true })
end
refute_match /SYMLINK TEST/, @result
end
should "not expose the existence of symlinked files" do
ex = assert_raises IOError do
content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true, 'safe' => true })
end
assert_match /should exist and should not be a symlink/, ex.message
end
end
end
end
jekyll-3.0.1/test/test_configuration.rb 0000644 0001750 0001750 00000023131 12623014201 020042 0 ustar uwabami uwabami require 'helper'
class TestConfiguration < JekyllUnitTest
@@defaults = Jekyll::Configuration::DEFAULTS.add_default_collections.freeze
context "#stringify_keys" do
setup do
@mixed_keys = Configuration[{
'markdown' => 'kramdown',
:permalink => 'date',
'baseurl' => '/',
:include => ['.htaccess'],
:source => './'
}]
@string_keys = Configuration[{
'markdown' => 'kramdown',
'permalink' => 'date',
'baseurl' => '/',
'include' => ['.htaccess'],
'source' => './'
}]
end
should "stringify symbol keys" do
assert_equal @string_keys, @mixed_keys.stringify_keys
end
should "not mess with keys already strings" do
assert_equal @string_keys, @string_keys.stringify_keys
end
end
context "#config_files" do
setup do
@config = Configuration[{"source" => source_dir}]
@no_override = {}
@one_config_file = {"config" => "config.yml"}
@multiple_files = {"config" => %w[config/site.yml config/deploy.toml configuration.yml]}
end
should "always return an array" do
assert @config.config_files(@no_override).is_a?(Array)
assert @config.config_files(@one_config_file).is_a?(Array)
assert @config.config_files(@multiple_files).is_a?(Array)
end
should "return the default config path if no config files are specified" do
assert_equal [source_dir("_config.yml")], @config.config_files(@no_override)
end
should "return .yaml if it exists but .yml does not" do
allow(File).to receive(:exist?).with(source_dir("_config.yml")).and_return(false)
allow(File).to receive(:exist?).with(source_dir("_config.yaml")).and_return(true)
assert_equal [source_dir("_config.yaml")], @config.config_files(@no_override)
end
should "return .yml if both .yml and .yaml exist" do
allow(File).to receive(:exist?).with(source_dir("_config.yml")).and_return(true)
assert_equal [source_dir("_config.yml")], @config.config_files(@no_override)
end
should "return the config if given one config file" do
assert_equal %w[config.yml], @config.config_files(@one_config_file)
end
should "return an array of the config files if given many config files" do
assert_equal %w[config/site.yml config/deploy.toml configuration.yml], @config.config_files(@multiple_files)
end
end
context "#backwards_compatibilize" do
setup do
@config = Configuration[{
"auto" => true,
"watch" => true,
"server" => true,
"exclude" => "READ-ME.md, Gemfile,CONTRIBUTING.hello.markdown",
"include" => "STOP_THE_PRESSES.txt,.heloses, .git",
"pygments" => true,
"plugins" => true,
"layouts" => true,
"data_source" => true,
}]
end
should "unset 'auto' and 'watch'" do
assert @config.key?("auto")
assert @config.key?("watch")
assert !@config.backwards_compatibilize.key?("auto")
assert !@config.backwards_compatibilize.key?("watch")
end
should "unset 'server'" do
assert @config.key?("server")
assert !@config.backwards_compatibilize.key?("server")
end
should "transform string exclude into an array" do
assert @config.key?("exclude")
assert @config.backwards_compatibilize.key?("exclude")
assert_equal @config.backwards_compatibilize["exclude"], %w[READ-ME.md Gemfile CONTRIBUTING.hello.markdown]
end
should "transform string include into an array" do
assert @config.key?("include")
assert @config.backwards_compatibilize.key?("include")
assert_equal @config.backwards_compatibilize["include"], %w[STOP_THE_PRESSES.txt .heloses .git]
end
should "set highlighter to pygments" do
assert @config.key?("pygments")
assert !@config.backwards_compatibilize.key?("pygments")
assert_equal @config.backwards_compatibilize["highlighter"], "pygments"
end
should "adjust directory names" do
assert @config.key?("plugins")
assert !@config.backwards_compatibilize.key?("plugins")
assert @config.backwards_compatibilize["plugins_dir"]
assert @config.key?("layouts")
assert !@config.backwards_compatibilize.key?("layouts")
assert @config.backwards_compatibilize["layouts_dir"]
assert @config.key?("data_source")
assert !@config.backwards_compatibilize.key?("data_source")
assert @config.backwards_compatibilize["data_dir"]
end
end
context "#fix_common_issues" do
setup do
@config = Proc.new do |val|
Configuration[{
'paginate' => val
}]
end
end
should "sets an invalid 'paginate' value to nil" do
assert_nil @config.call(0).fix_common_issues['paginate']
assert_nil @config.call(-1).fix_common_issues['paginate']
assert_nil @config.call(true).fix_common_issues['paginate']
end
end
context "loading configuration" do
setup do
@path = File.join(Dir.pwd, '_config.yml')
@user_config = File.join(Dir.pwd, "my_config_file.yml")
end
should "fire warning with no _config.yml" do
allow(SafeYAML).to receive(:load_file).with(@path) { raise SystemCallError, "No such file or directory - #{@path}" }
allow($stderr).to receive(:puts).with("Configuration file: none".yellow)
assert_equal @@defaults, Jekyll.configuration({})
end
should "load configuration as hash" do
allow(SafeYAML).to receive(:load_file).with(@path).and_return(Hash.new)
allow($stdout).to receive(:puts).with("Configuration file: #{@path}")
assert_equal @@defaults, Jekyll.configuration({})
end
should "fire warning with bad config" do
allow(SafeYAML).to receive(:load_file).with(@path).and_return(Array.new)
allow($stderr).to receive(:puts).and_return(("WARNING: ".rjust(20) + "Error reading configuration. Using defaults (and options).").yellow)
allow($stderr).to receive(:puts).and_return("Configuration file: (INVALID) #{@path}".yellow)
assert_equal @@defaults, Jekyll.configuration({})
end
should "fire warning when user-specified config file isn't there" do
allow(SafeYAML).to receive(:load_file).with(@user_config) { raise SystemCallError, "No such file or directory - #{@user_config}" }
allow($stderr).to receive(:puts).with(("Fatal: ".rjust(20) + "The configuration file '#{@user_config}' could not be found.").red)
assert_raises LoadError do
Jekyll.configuration({'config' => [@user_config]})
end
end
should "not clobber YAML.load to the dismay of other libraries" do
assert_equal :foo, YAML.load(':foo')
# as opposed to: assert_equal ':foo', SafeYAML.load(':foo')
end
end
context "loading config from external file" do
setup do
@paths = {
:default => File.join(Dir.pwd, '_config.yml'),
:other => File.join(Dir.pwd, '_config.live.yml'),
:toml => source_dir('_config.dev.toml'),
:empty => ""
}
end
should "load default plus posts config if no config_file is set" do
allow(SafeYAML).to receive(:load_file).with(@paths[:default]).and_return({})
allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:default]}")
assert_equal @@defaults, Jekyll.configuration({})
end
should "load different config if specified" do
allow(SafeYAML).to receive(:load_file).with(@paths[:other]).and_return({"baseurl" => "http://wahoo.dev"})
allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:other]}")
assert_equal Utils.deep_merge_hashes(@@defaults, { "baseurl" => "http://wahoo.dev" }), Jekyll.configuration({ "config" => @paths[:other] })
end
should "load default config if path passed is empty" do
allow(SafeYAML).to receive(:load_file).with(@paths[:default]).and_return({})
allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:default]}")
assert_equal @@defaults, Jekyll.configuration({ "config" => @paths[:empty] })
end
should "successfully load a TOML file" do
Jekyll.logger.log_level = :warn
assert_equal @@defaults.clone.merge({ "baseurl" => "/you-beautiful-blog-you", "title" => "My magnificent site, wut" }), Jekyll.configuration({ "config" => [@paths[:toml]] })
Jekyll.logger.log_level = :info
end
should "load multiple config files" do
External.require_with_graceful_fail('toml')
allow(SafeYAML).to receive(:load_file).with(@paths[:default]).and_return(Hash.new)
allow(SafeYAML).to receive(:load_file).with(@paths[:other]).and_return(Hash.new)
allow(TOML).to receive(:load_file).with(@paths[:toml]).and_return(Hash.new)
allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:default]}")
allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:other]}")
allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:toml]}")
assert_equal @@defaults, Jekyll.configuration({ "config" => [@paths[:default], @paths[:other], @paths[:toml]] })
end
should "load multiple config files and last config should win" do
allow(SafeYAML).to receive(:load_file).with(@paths[:default]).and_return({"baseurl" => "http://example.dev"})
allow(SafeYAML).to receive(:load_file).with(@paths[:other]).and_return({"baseurl" => "http://wahoo.dev"})
allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:default]}")
allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:other]}")
assert_equal Utils.deep_merge_hashes(@@defaults, { "baseurl" => "http://wahoo.dev" }), Jekyll.configuration({ "config" => [@paths[:default], @paths[:other]] })
end
end
end
jekyll-3.0.1/test/test_redcarpet.rb 0000644 0001750 0001750 00000005161 12623014201 017147 0 ustar uwabami uwabami require 'helper'
class TestRedcarpet < JekyllUnitTest
context "redcarpet" do
setup do
if jruby?
then skip(
"JRuby does not perform well with CExt, test disabled."
)
end
@config = {
'markdown' => 'redcarpet',
'redcarpet' => {
'extensions' => [
'smart', 'strikethrough', 'filter_html'
]
}
}
@markdown = Converters::Markdown.new @config
end
should "pass redcarpet options" do
assert_equal "Some Header
", @markdown.convert('# Some Header #').strip
end
should "pass redcarpet SmartyPants options" do
assert_equal "“smart”
", @markdown.convert('"smart"').strip
end
should "pass redcarpet extensions" do
assert_equal "deleted
", @markdown.convert('~~deleted~~').strip
end
should "pass redcarpet render options" do
assert_equal "bad code not here: i am bad
", @markdown.convert('**bad code not here**: ').strip
end
context "with pygments enabled" do
setup do
@markdown = Converters::Markdown.new @config.merge({ 'highlighter' => 'pygments' })
end
should "render fenced code blocks with syntax highlighting" do
assert_equal "puts "Hello world"\n
", @markdown.convert(
<<-EOS
```ruby
puts "Hello world"
```
EOS
).strip
end
end
context "with rouge enabled" do
setup do
@markdown = Converters::Markdown.new @config.merge({ 'highlighter' => 'rouge' })
end
should "render fenced code blocks with syntax highlighting" do
assert_equal "puts \"Hello world\"\n
", @markdown.convert(
<<-EOS
```ruby
puts "Hello world"
```
EOS
).strip
end
end
context "without any highlighter" do
setup do
@markdown = Converters::Markdown.new @config.merge({ 'highlighter' => nil })
end
should "render fenced code blocks without syntax highlighting" do
assert_equal "puts "Hello world"\n
", @markdown.convert(
<<-EOS
```ruby
puts "Hello world"
```
EOS
).strip
end
end
end
end
jekyll-3.0.1/test/test_url.rb 0000644 0001750 0001750 00000003101 12623014201 015770 0 ustar uwabami uwabami require 'helper'
class TestURL < JekyllUnitTest
context "The URL class" do
should "throw an exception if neither permalink or template is specified" do
assert_raises ArgumentError do
URL.new(:placeholders => {})
end
end
should "replace placeholders in templates" do
assert_equal "/foo/bar", URL.new(
:template => "/:x/:y",
:placeholders => {:x => "foo", :y => "bar"}
).to_s
end
should "handle multiple of the same key in the template" do
assert_equal '/foo/bar/foo/', URL.new(
:template => "/:x/:y/:x/",
:placeholders => {:x => "foo", :y => "bar"}
).to_s
end
should "use permalink if given" do
assert_equal "/le/perma/link", URL.new(
:template => "/:x/:y",
:placeholders => {:x => "foo", :y => "bar"},
:permalink => "/le/perma/link"
).to_s
end
should "replace placeholders in permalinks" do
assert_equal "/foo/bar", URL.new(
:template => "/baz",
:permalink => "/:x/:y",
:placeholders => {:x => "foo", :y => "bar"}
).to_s
end
should "handle multiple of the same key in the permalink" do
assert_equal '/foo/bar/foo/', URL.new(
:template => "/baz",
:permalink => "/:x/:y/:x/",
:placeholders => {:x => "foo", :y => "bar"}
).to_s
end
should "handle nil values for keys in the template" do
assert_equal '/foo/bar/', URL.new(
:template => "/:x/:y/:z/",
:placeholders => {:x => "foo", :y => "bar", :z => nil}
).to_s
end
end
end
jekyll-3.0.1/test/test_generated_site.rb 0000644 0001750 0001750 00000005342 12623014201 020161 0 ustar uwabami uwabami require 'helper'
class TestGeneratedSite < JekyllUnitTest
context "generated sites" do
setup do
clear_dest
config = Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir})
@site = fixture_site config
@site.process
@index = File.read(dest_dir('index.html'))
end
should "ensure post count is as expected" do
assert_equal 48, @site.posts.size
end
should "insert site.posts into the index" do
assert @index.include?("#{@site.posts.size} Posts")
end
should "render latest post's content" do
assert @index.include?(@site.posts.last.content)
end
should "hide unpublished posts" do
published = Dir[dest_dir('publish_test/2008/02/02/*.html')].map {|f| File.basename(f)}
assert_equal 1, published.size
assert_equal "published.html", published.first
end
should "hide unpublished page" do
assert !File.exist?(dest_dir('/unpublished.html'))
end
should "not copy _posts directory" do
assert !File.exist?(dest_dir('_posts'))
end
should "process other static files and generate correct permalinks" do
assert File.exist?(dest_dir('/about/index.html'))
assert File.exist?(dest_dir('/contacts.html'))
end
should "print a nice list of static files" do
time_regexp = "\\d+:\\d+"
expected_output = Regexp.new <<-OUTPUT
- /css/screen.css last edited at #{time_regexp} with extname .css
- /pgp.key last edited at #{time_regexp} with extname .key
- /products.yml last edited at #{time_regexp} with extname .yml
- /symlink-test/symlinked-dir/screen.css last edited at #{time_regexp} with extname .css
OUTPUT
assert_match expected_output, File.read(dest_dir('static_files.html'))
end
end
context "generating limited posts" do
setup do
clear_dest
config = Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir, 'limit_posts' => 5})
@site = fixture_site config
@site.process
@index = File.read(dest_dir('index.html'))
end
should "generate only the specified number of posts" do
assert_equal 5, @site.posts.size
end
should "ensure limit posts is 0 or more" do
assert_raises ArgumentError do
clear_dest
config = Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir, 'limit_posts' => -1})
@site = fixture_site config
end
end
should "acceptable limit post is 0" do
clear_dest
config = Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir, 'limit_posts' => 0})
assert Site.new(config), "Couldn't create a site with the given limit_posts."
end
end
end
jekyll-3.0.1/test/test_liquid_extensions.rb 0000644 0001750 0001750 00000001517 12623014201 020745 0 ustar uwabami uwabami require 'helper'
class TestLiquidExtensions < JekyllUnitTest
context "looking up a variable in a Liquid context" do
class SayHi < Liquid::Tag
include Jekyll::LiquidExtensions
def initialize(tag_name, markup, tokens)
@markup = markup.strip
end
def render(context)
"hi #{lookup_variable(context, @markup)}"
end
end
Liquid::Template.register_tag('say_hi', SayHi)
setup do
@template = Liquid::Template.parse("{% say_hi page.name %}") # Parses and compiles the template
end
should "extract the var properly" do
assert_equal @template.render({'page' => {'name' => 'tobi'}}), 'hi tobi'
end
should "return the variable name if the value isn't there" do
assert_equal @template.render({'page' => {'title' => 'tobi'}}), 'hi page.name'
end
end
end
jekyll-3.0.1/test/fixtures/ 0000755 0001750 0001750 00000000000 12623014201 015460 5 ustar uwabami uwabami jekyll-3.0.1/test/fixtures/broken_front_matter1.erb 0000644 0001750 0001750 00000000113 12623014201 022272 0 ustar uwabami uwabami # Some stuff on the first line
---
test: good
---
Real content starts here
jekyll-3.0.1/test/fixtures/broken_front_matter2.erb 0000644 0001750 0001750 00000000055 12623014201 022300 0 ustar uwabami uwabami ---
bad yaml: [
---
Real content starts here
jekyll-3.0.1/test/fixtures/broken_front_matter3.erb 0000644 0001750 0001750 00000000073 12623014201 022301 0 ustar uwabami uwabami ---
test: good
---
Real content starts here
jekyll-3.0.1/test/fixtures/exploit_front_matter.erb 0000644 0001750 0001750 00000000102 12623014201 022413 0 ustar uwabami uwabami ---
test: !ruby/hash:DoesNotExist {}
---
Real content starts here
jekyll-3.0.1/test/fixtures/front_matter.erb 0000644 0001750 0001750 00000000054 12623014201 020655 0 ustar uwabami uwabami ---
test: good
---
Real content starts here
jekyll-3.0.1/test/test_coffeescript.rb 0000644 0001750 0001750 00000002204 12623014201 017645 0 ustar uwabami uwabami require 'helper'
class TestCoffeeScript < JekyllUnitTest
context "converting CoffeeScript" do
setup do
External.require_with_graceful_fail('jekyll-coffeescript')
@site = fixture_site
@site.process
@test_coffeescript_file = dest_dir("js/coffeescript.js")
@js_output = <<-JS
(function() {
$(function() {
var cube, cubes, list, num, square;
list = [1, 2, 3, 4, 5];
square = function(x) {
return x * x;
};
cube = function(x) {
return square(x) * x;
};
cubes = (function() {
var i, len, results;
results = [];
for (i = 0, len = list.length; i < len; i++) {
num = list[i];
results.push(math.cube(num));
}
return results;
})();
if (typeof elvis !== "undefined" && elvis !== null) {
return alert("I knew it!");
}
});
}).call(this);
JS
end
should "write a JS file in place" do
assert File.exist?(@test_coffeescript_file), "Can't find the converted CoffeeScript file in the dest_dir."
end
should "produce JS" do
assert_equal @js_output, File.read(@test_coffeescript_file)
end
end
end
jekyll-3.0.1/test/test_plugin_manager.rb 0000644 0001750 0001750 00000002046 12623014201 020165 0 ustar uwabami uwabami require 'helper'
class TestPluginManager < JekyllUnitTest
def with_no_gemfile
FileUtils.mv "Gemfile", "Gemfile.old"
yield
ensure
FileUtils.mv "Gemfile.old", "Gemfile"
end
def test_requiring_from_bundler
with_env("JEKYLL_NO_BUNDLER_REQUIRE", nil) do
assert Jekyll::PluginManager.require_from_bundler, 'require_from_bundler should return true.'
assert ENV["JEKYLL_NO_BUNDLER_REQUIRE"], 'Gemfile plugins were not required.'
end
end
def test_blocking_requiring_from_bundler
with_env("JEKYLL_NO_BUNDLER_REQUIRE", "true") do
assert_equal false, Jekyll::PluginManager.require_from_bundler, "Gemfile plugins were required but shouldn't have been"
assert ENV["JEKYLL_NO_BUNDLER_REQUIRE"]
end
end
def test_no_gemfile
with_env("JEKYLL_NO_BUNDLER_REQUIRE", nil) do
with_no_gemfile do
assert_equal false, Jekyll::PluginManager.require_from_bundler, "Gemfile plugins were required but shouldn't have been"
assert_nil ENV["JEKYLL_NO_BUNDLER_REQUIRE"]
end
end
end
end
jekyll-3.0.1/test/test_command.rb 0000644 0001750 0001750 00000001171 12623014201 016611 0 ustar uwabami uwabami require 'helper'
class TestCommand < JekyllUnitTest
context "when calling .add_build_options" do
should "add common options" do
cmd = Object.new
mocks_expect(cmd).to receive(:option).at_least(:once)
Command.add_build_options(cmd)
end
end
context "when calling .process_site" do
context "when fatal error occurs" do
should "exit with non-zero error code" do
site = Object.new
def site.process; raise Jekyll::Errors::FatalException; end
error = assert_raises(SystemExit) { Command.process_site(site) }
refute_equal 0, error.status
end
end
end
end
jekyll-3.0.1/test/test_layout_reader.rb 0000644 0001750 0001750 00000002035 12623014201 020032 0 ustar uwabami uwabami require 'helper'
class TestLayoutReader < JekyllUnitTest
context "reading layouts" do
setup do
config = Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir})
@site = fixture_site config
end
should "read layouts" do
layouts = LayoutReader.new(@site).read
assert_equal ["default", "simple", "post/simple"].sort, layouts.keys.sort
end
context "when no _layouts directory exists in CWD" do
should "know to use the layout directory relative to the site source" do
assert_equal LayoutReader.new(@site).layout_directory, source_dir("_layouts")
end
end
context "when a _layouts directory exists in CWD" do
setup do
allow(File).to receive(:directory?).and_return(true)
allow(Dir).to receive(:pwd).and_return(source_dir("blah"))
end
should "know to use the layout directory relative to CWD" do
assert_equal LayoutReader.new(@site).layout_directory, source_dir("blah/_layouts")
end
end
end
end
jekyll-3.0.1/test/test_new_command.rb 0000644 0001750 0001750 00000006336 12623014201 017472 0 ustar uwabami uwabami require 'helper'
require 'jekyll/commands/new'
class TestNewCommand < JekyllUnitTest
def dir_contents(path)
Dir["#{path}/**/*"].each do |file|
file.gsub! path, ''
end
end
def site_template
File.expand_path("../lib/site_template", File.dirname(__FILE__))
end
context 'when args contains a path' do
setup do
@path = 'new-site'
@args = [@path]
@full_path = File.expand_path(@path, Dir.pwd)
end
teardown do
FileUtils.rm_r @full_path
end
should 'create a new directory' do
assert !File.exist?(@full_path)
Jekyll::Commands::New.process(@args)
assert File.exist?(@full_path)
end
should 'display a success message' do
Jekyll::Commands::New.process(@args)
output = Jekyll.logger.messages.last
success_message = "New jekyll site installed in #{@full_path}."
assert_includes output, success_message
end
should 'copy the static files in site template to the new directory' do
static_template_files = dir_contents(site_template).reject do |f|
File.extname(f) == '.erb'
end
capture_stdout { Jekyll::Commands::New.process(@args) }
new_site_files = dir_contents(@full_path).reject do |f|
File.extname(f) == '.markdown'
end
assert_same_elements static_template_files, new_site_files
end
should 'process any ERB files' do
erb_template_files = dir_contents(site_template).select do |f|
File.extname(f) == '.erb'
end
stubbed_date = '2013-01-01'
allow_any_instance_of(Time).to receive(:strftime) { stubbed_date }
erb_template_files.each do |f|
f.chomp! '.erb'
f.gsub! '0000-00-00', stubbed_date
end
capture_stdout { Jekyll::Commands::New.process(@args) }
new_site_files = dir_contents(@full_path).select do |f|
erb_template_files.include? f
end
assert_same_elements erb_template_files, new_site_files
end
should 'create blank project' do
blank_contents = %w(/_drafts /_layouts /_posts /index.html)
capture_stdout { Jekyll::Commands::New.process(@args, '--blank') }
assert_same_elements blank_contents, dir_contents(@full_path)
end
should 'force created folder' do
capture_stdout { Jekyll::Commands::New.process(@args) }
output = capture_stdout { Jekyll::Commands::New.process(@args, '--force') }
assert_match /New jekyll site installed in/, output
end
end
context 'when multiple args are given' do
setup do
@site_name_with_spaces = 'new site name'
@multiple_args = @site_name_with_spaces.split
end
teardown do
FileUtils.rm_r File.expand_path(@site_name_with_spaces, Dir.pwd)
end
should 'create a new directory' do
assert !File.exist?(@site_name_with_spaces)
capture_stdout { Jekyll::Commands::New.process(@multiple_args) }
assert File.exist?(@site_name_with_spaces)
end
end
context 'when no args are given' do
setup do
@empty_args = []
end
should 'raise an ArgumentError' do
exception = assert_raises ArgumentError do
Jekyll::Commands::New.process(@empty_args)
end
assert_equal 'You must specify a path.', exception.message
end
end
end
jekyll-3.0.1/test/test_path_sanitization.rb 0000644 0001750 0001750 00000001201 12623014201 020715 0 ustar uwabami uwabami require 'helper'
class TestPathSanitization < JekyllUnitTest
context "on Windows with absolute source" do
setup do
@source = "C:/Users/xmr/Desktop/mpc-hc.org"
@dest = "./_site/"
allow(Dir).to receive(:pwd).and_return("C:/Users/xmr/Desktop/mpc-hc.org")
end
should "strip drive name from path" do
assert_equal "C:/Users/xmr/Desktop/mpc-hc.org/_site", Jekyll.sanitized_path(@source, @dest)
end
should "strip just the initial drive name" do
assert_equal "/tmp/foobar/jail/..c:/..c:/..c:/etc/passwd", Jekyll.sanitized_path("/tmp/foobar/jail", "..c:/..c:/..c:/etc/passwd")
end
end
end
jekyll-3.0.1/test/test_static_file.rb 0000644 0001750 0001750 00000010545 12623014201 017466 0 ustar uwabami uwabami require 'helper'
class TestStaticFile < JekyllUnitTest
def make_dummy_file(filename)
File.write(source_dir(filename), "some content")
end
def modify_dummy_file(filename)
offset = "some content".size
File.write(source_dir(filename), "more content", offset)
end
def remove_dummy_file(filename)
File.delete(source_dir(filename))
end
def setup_static_file(base, dir, name)
StaticFile.new(@site, base, dir, name)
end
def setup_static_file_with_collection(base, dir, name, label, metadata)
site = fixture_site 'collections' => {label => metadata}
StaticFile.new(site, base, dir, name, site.collections[label])
end
def setup_static_file_with_defaults(base, dir, name, defaults)
site = fixture_site 'defaults' => defaults
StaticFile.new(site, base, dir, name)
end
context "A StaticFile" do
setup do
clear_dest
@old_pwd = Dir.pwd
Dir.chdir source_dir
@site = fixture_site
@filename = "static_file.txt"
make_dummy_file(@filename)
@static_file = setup_static_file(nil, nil, @filename)
end
teardown do
remove_dummy_file(@filename) if File.exist?(source_dir(@filename))
Dir.chdir @old_pwd
end
should "have a source file path" do
static_file = setup_static_file("root", "dir", @filename)
assert_equal "root/dir/#{@filename}", static_file.path
end
should "ignore a nil base or dir" do
assert_equal "dir/#{@filename}", setup_static_file(nil, "dir", @filename).path
assert_equal "base/#{@filename}", setup_static_file("base", nil, @filename).path
end
should "have a destination relative directory without a collection" do
static_file = setup_static_file("root", "dir/subdir", "file.html")
assert_equal nil, static_file.type
assert_equal "dir/subdir/file.html", static_file.url
assert_equal "dir/subdir", static_file.destination_rel_dir
end
should "have a destination relative directory with a collection" do
static_file = setup_static_file_with_collection(
"root", "_foo/dir/subdir", "file.html", "foo", {"output" => true})
assert_equal :foo, static_file.type
assert_equal "/foo/dir/subdir/file.html", static_file.url
assert_equal "/foo/dir/subdir", static_file.destination_rel_dir
end
should "use its collection's permalink template for the destination relative directory" do
static_file = setup_static_file_with_collection(
"root", "_foo/dir/subdir", "file.html", "foo",
{"output" => true, "permalink" => "/:path/"})
assert_equal :foo, static_file.type
assert_equal "/dir/subdir/file.html", static_file.url
assert_equal "/dir/subdir", static_file.destination_rel_dir
end
should "be writable by default" do
static_file = setup_static_file("root", "dir/subdir", "file.html")
assert(static_file.write?,
"static_file.write? should return true by default")
end
should "use the _config.yml defaults to determine writability" do
defaults = [{
"scope" => {"path" => "private"},
"values" => {"published" => false}
}]
static_file = setup_static_file_with_defaults(
"root", "private/dir/subdir", "file.html", defaults)
assert(!static_file.write?,
"static_file.write? should return false when _config.yml sets " +
"`published: false`")
end
should "know its last modification time" do
assert_equal Time.new.to_i, @static_file.mtime
end
should "known if the source path is modified, when it is" do
sleep 1
modify_dummy_file(@filename)
assert @static_file.modified?
end
should "known if the source path is modified, when its not" do
@static_file.write(dest_dir)
sleep 1 # wait, else the times are still the same
assert !@static_file.modified?
end
should "known whether to write the file to the filesystem" do
assert @static_file.write?, "always true, with current implementation"
end
should "be able to write itself to the desitination direcotry" do
assert @static_file.write(dest_dir)
end
should "be able to convert to liquid" do
expected = {
"extname" => ".txt",
"modified_time" => @static_file.modified_time,
"path" => "/static_file.txt",
}
assert_equal expected, @static_file.to_liquid
end
end
end
jekyll-3.0.1/test/source/ 0000755 0001750 0001750 00000000000 12623014201 015107 5 ustar uwabami uwabami jekyll-3.0.1/test/source/symlink-test/ 0000755 0001750 0001750 00000000000 12623014201 017552 5 ustar uwabami uwabami jekyll-3.0.1/test/source/symlink-test/_data 0000777 0001750 0001750 00000000000 12623014201 021750 2../_data ustar uwabami uwabami jekyll-3.0.1/test/source/symlink-test/symlinked-dir 0000777 0001750 0001750 00000000000 12623014201 023173 2../css ustar uwabami uwabami jekyll-3.0.1/test/source/symlink-test/symlinked-file 0000777 0001750 0001750 00000000000 12623014201 024616 2../index.html ustar uwabami uwabami jekyll-3.0.1/test/source/_sass/ 0000755 0001750 0001750 00000000000 12623014201 016217 5 ustar uwabami uwabami jekyll-3.0.1/test/source/_sass/_grid.scss 0000644 0001750 0001750 00000000025 12623014201 020175 0 ustar uwabami uwabami .half { width: 50%; } jekyll-3.0.1/test/source/properties.html 0000644 0001750 0001750 00000000145 12623014201 020171 0 ustar uwabami uwabami ---
foo: bar
layout: default
permalink: /properties/
title: Properties Page
---
All the properties.
jekyll-3.0.1/test/source/exploit.md 0000644 0001750 0001750 00000000075 12623014201 017117 0 ustar uwabami uwabami ---
permalink: /%2e%2e/%2e%2e/%2e%2e/baddie.html
---
# Test
jekyll-3.0.1/test/source/js/ 0000755 0001750 0001750 00000000000 12623014201 015523 5 ustar uwabami uwabami jekyll-3.0.1/test/source/js/coffeescript.coffee 0000644 0001750 0001750 00000000312 12623014201 021344 0 ustar uwabami uwabami ---
message: "I knew it!"
---
$ ->
list = [1, 2, 3, 4, 5]
square = (x) -> x * x
cube = (x) -> square(x) * x
cubes = (math.cube num for num in list)
alert "{{ page.message }}" if elvis?
jekyll-3.0.1/test/source/_data/ 0000755 0001750 0001750 00000000000 12623014201 016157 5 ustar uwabami uwabami jekyll-3.0.1/test/source/_data/products.yml 0000777 0001750 0001750 00000000000 12623014201 023343 2../products.yml ustar uwabami uwabami jekyll-3.0.1/test/source/_data/categories/ 0000755 0001750 0001750 00000000000 12623014201 020304 5 ustar uwabami uwabami jekyll-3.0.1/test/source/_data/categories/dairy.yaml 0000644 0001750 0001750 00000000113 12623014201 022273 0 ustar uwabami uwabami name: Dairy
products:
- name: cheese
price: 5.3
- name: milk
price: 2.5 jekyll-3.0.1/test/source/_data/members.json 0000644 0001750 0001750 00000000247 12623014201 020507 0 ustar uwabami uwabami [
{
"name": "Jack",
"age": 27,
"blog": "http://example.com/jack"
},
{
"name": "John",
"age": 32,
"blog": "http://example.com/john"
}
]
jekyll-3.0.1/test/source/_data/members.yaml 0000644 0001750 0001750 00000000157 12623014201 020500 0 ustar uwabami uwabami - name: Jack
age: 27
blog: http://example.com/jack
- name: John
age: 32
blog: http://example.com/john
jekyll-3.0.1/test/source/_data/languages.yml 0000644 0001750 0001750 00000000016 12623014201 020645 0 ustar uwabami uwabami - java
- ruby
jekyll-3.0.1/test/source/products.yml 0000644 0001750 0001750 00000000065 12623014201 017476 0 ustar uwabami uwabami - name: sugar
price: 5.3
- name: salt
price: 2.5
jekyll-3.0.1/test/source/+/ 0000755 0001750 0001750 00000000000 12623014201 015241 5 ustar uwabami uwabami jekyll-3.0.1/test/source/+/%# +.md 0000644 0001750 0001750 00000000140 12623014201 016060 0 ustar uwabami uwabami ---
layout: default
title : Page name with non-alphabetic character
---
Line 1
{{ page.title }}
jekyll-3.0.1/test/source/+/foo.md 0000644 0001750 0001750 00000000140 12623014201 016341 0 ustar uwabami uwabami ---
layout: default
title : Page inside +
permalink: /+/plus+in+url
---
Line 1
{{ page.title }}
jekyll-3.0.1/test/source/deal.with.dots.html 0000644 0001750 0001750 00000000151 12623014201 020621 0 ustar uwabami uwabami ---
title: Deal with dots
permalink: /deal.with.dots
---
Let's test if jekyll deals properly with dots.
jekyll-3.0.1/test/source/contacts/ 0000755 0001750 0001750 00000000000 12623014201 016725 5 ustar uwabami uwabami jekyll-3.0.1/test/source/contacts/bar.html 0000644 0001750 0001750 00000000070 12623014201 020354 0 ustar uwabami uwabami ---
title: Contact Information
---
Contact Information
jekyll-3.0.1/test/source/contacts/index.html 0000644 0001750 0001750 00000000070 12623014201 020717 0 ustar uwabami uwabami ---
title: Contact Information
---
Contact Information
jekyll-3.0.1/test/source/about.html 0000644 0001750 0001750 00000000070 12623014201 017104 0 ustar uwabami uwabami ---
title: About
permalink: /about/
---
About the site
jekyll-3.0.1/test/source/css/ 0000755 0001750 0001750 00000000000 12623014201 015677 5 ustar uwabami uwabami jekyll-3.0.1/test/source/css/screen.css 0000644 0001750 0001750 00000001773 12623014201 017700 0 ustar uwabami uwabami /*****************************************************************************/
/*
/* Common
/*
/*****************************************************************************/
/* Global Reset */
* {
margin: 0;
padding: 0;
}
html, body {
height: 100%;
}
body {
background-color: white;
font: 13.34px helvetica, arial, clean, sans-serif;
*font-size: small;
text-align: center;
}
h1, h2, h3, h4, h5, h6 {
font-size: 100%;
}
h1 {
margin-bottom: 1em;
}
p {
margin: 1em 0;
}
a {
color: #00a;
}
a:hover {
color: black;
}
a:visited {
color: #a0a;
}
table {
font-size: inherit;
font: 100%;
}
/*****************************************************************************/
/*
/* Site
/*
/*****************************************************************************/
.site {
font-size: 110%;
text-align: justify;
width: 40em;
margin: 3em auto 2em auto;
line-height: 1.5em;
}
.title {
color: #a00;
font-weight: bold;
margin-bottom: 2em;
}
.site .meta {
color: #aaa;
} jekyll-3.0.1/test/source/css/main.scss 0000644 0001750 0001750 00000000030 12623014201 017511 0 ustar uwabami uwabami ---
---
@import "grid"; jekyll-3.0.1/test/source/_posts/ 0000755 0001750 0001750 00000000000 12623014201 016416 5 ustar uwabami uwabami jekyll-3.0.1/test/source/_posts/2010-01-09-timezone-override.markdown 0000644 0001750 0001750 00000000170 12623014201 024653 0 ustar uwabami uwabami ---
date: 2010-01-10 13:07:09 +00:00
---
Post with a front matter time with timezone
{{ page.date | date_to_string }}
jekyll-3.0.1/test/source/_posts/2009-05-18-tags.markdown 0000644 0001750 0001750 00000000102 12623014201 022151 0 ustar uwabami uwabami ---
title: Some Tags
tags:
- food
- cooking
- pizza
---
Awesome!
jekyll-3.0.1/test/source/_posts/2008-11-21-complex.markdown 0000644 0001750 0001750 00000000143 12623014201 022655 0 ustar uwabami uwabami ---
layout: default
title: Complex
---
url: {{ page.url }}
date: {{ page.date }}
id: {{ page.id }} jekyll-3.0.1/test/source/_posts/2009-03-12-hash-#1.markdown 0000644 0001750 0001750 00000000070 12623014201 022333 0 ustar uwabami uwabami ---
layout: default
title: Hash #1
---
Hashes are nice
jekyll-3.0.1/test/source/_posts/2008-12-03-permalinked-post.markdown 0000644 0001750 0001750 00000000211 12623014201 024461 0 ustar uwabami uwabami ---
title: Post with Permalink
permalink: my_category/permalinked-post
---
h1. {{ page.title }}
Best post ever