parent
							
								
									0612542582
								
							
						
					
					
						commit
						9adac3a11e
					
				|  | @ -11,6 +11,7 @@ AllCops: | ||||||
|   TargetRubyVersion: 2.3 |   TargetRubyVersion: 2.3 | ||||||
|   Include: |   Include: | ||||||
|     - lib/**/*.rb |     - lib/**/*.rb | ||||||
|  |     - test/**/*.rb | ||||||
|   Exclude: |   Exclude: | ||||||
|     - bin/**/* |     - bin/**/* | ||||||
|     - exe/**/* |     - exe/**/* | ||||||
|  | @ -82,6 +83,9 @@ Metrics/PerceivedComplexity: | ||||||
|   Max: 8 |   Max: 8 | ||||||
| Naming/FileName: | Naming/FileName: | ||||||
|   Enabled: false |   Enabled: false | ||||||
|  | Naming/HeredocDelimiterNaming: | ||||||
|  |   Exclude: | ||||||
|  |     - test/**/*.rb | ||||||
| Naming/MemoizedInstanceVariableName: | Naming/MemoizedInstanceVariableName: | ||||||
|   Exclude: |   Exclude: | ||||||
|     - lib/jekyll/page_without_a_file.rb |     - lib/jekyll/page_without_a_file.rb | ||||||
|  | @ -104,6 +108,9 @@ Style/Alias: | ||||||
|   EnforcedStyle: prefer_alias_method |   EnforcedStyle: prefer_alias_method | ||||||
| Style/AndOr: | Style/AndOr: | ||||||
|   Severity: error |   Severity: error | ||||||
|  | Style/ClassAndModuleChildren: | ||||||
|  |   Exclude: | ||||||
|  |     - test/**/*.rb | ||||||
| Style/FrozenStringLiteralComment: | Style/FrozenStringLiteralComment: | ||||||
|   EnforcedStyle: always |   EnforcedStyle: always | ||||||
| Style/Documentation: | Style/Documentation: | ||||||
|  |  | ||||||
|  | @ -111,13 +111,13 @@ class JekyllUnitTest < Minitest::Test | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   def fixture_document(relative_path) |   def fixture_document(relative_path) | ||||||
|     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| | ||||||
|       doc.relative_path == relative_path |       doc.relative_path == relative_path | ||||||
|  | @ -138,13 +138,13 @@ class JekyllUnitTest < Minitest::Test | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   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 | ||||||
| 
 | 
 | ||||||
|   def clear_dest |   def clear_dest | ||||||
|  | @ -197,7 +197,6 @@ class FakeLogger | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| module TestWEBrick | module TestWEBrick | ||||||
| 
 |  | ||||||
|   module_function |   module_function | ||||||
| 
 | 
 | ||||||
|   def mount_server(&block) |   def mount_server(&block) | ||||||
|  | @ -205,7 +204,7 @@ module TestWEBrick | ||||||
| 
 | 
 | ||||||
|     begin |     begin | ||||||
|       server.mount("/", Jekyll::Commands::Serve::Servlet, document_root, |       server.mount("/", Jekyll::Commands::Serve::Servlet, document_root, | ||||||
|         document_root_options) |                    document_root_options) | ||||||
| 
 | 
 | ||||||
|       server.start |       server.start | ||||||
|       addr = server.listeners[0].addr |       addr = server.listeners[0].addr | ||||||
|  | @ -235,11 +234,11 @@ module TestWEBrick | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   def document_root_options |   def document_root_options | ||||||
|     WEBrick::Config::FileHandler.merge({ |     WEBrick::Config::FileHandler.merge( | ||||||
|       :FancyIndexing     => true, |       :FancyIndexing     => true, | ||||||
|       :NondisclosureName => [ |       :NondisclosureName => [ | ||||||
|         ".ht*", "~*", |         ".ht*", "~*", | ||||||
|       ], |       ] | ||||||
|     }) |     ) | ||||||
|   end |   end | ||||||
| end | end | ||||||
|  |  | ||||||
|  | @ -9,33 +9,33 @@ class TestCoffeeScript < JekyllUnitTest | ||||||
|       @site = fixture_site |       @site = fixture_site | ||||||
|       @site.process |       @site.process | ||||||
|       @test_coffeescript_file = dest_dir("js/coffeescript.js") |       @test_coffeescript_file = dest_dir("js/coffeescript.js") | ||||||
|       @js_output = <<-JS |       @js_output = <<~JS | ||||||
| (function() { |         (function() { | ||||||
|   $(function() { |           $(function() { | ||||||
|     var cube, cubes, list, num, square; |             var cube, cubes, list, num, square; | ||||||
|     list = [1, 2, 3, 4, 5]; |             list = [1, 2, 3, 4, 5]; | ||||||
|     square = function(x) { |             square = function(x) { | ||||||
|       return x * x; |               return x * x; | ||||||
|     }; |             }; | ||||||
|     cube = function(x) { |             cube = function(x) { | ||||||
|       return square(x) * x; |               return square(x) * x; | ||||||
|     }; |             }; | ||||||
|     cubes = (function() { |             cubes = (function() { | ||||||
|       var i, len, results; |               var i, len, results; | ||||||
|       results = []; |               results = []; | ||||||
|       for (i = 0, len = list.length; i < len; i++) { |               for (i = 0, len = list.length; i < len; i++) { | ||||||
|         num = list[i]; |                 num = list[i]; | ||||||
|         results.push(math.cube(num)); |                 results.push(math.cube(num)); | ||||||
|       } |               } | ||||||
|       return results; |               return results; | ||||||
|     })(); |             })(); | ||||||
|     if (typeof elvis !== "undefined" && elvis !== null) { |             if (typeof elvis !== "undefined" && elvis !== null) { | ||||||
|       return alert("I knew it!"); |               return alert("I knew it!"); | ||||||
|     } |             } | ||||||
|   }); |           }); | ||||||
| 
 | 
 | ||||||
| }).call(this); |         }).call(this); | ||||||
| JS |       JS | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "write a JS file in place" do |     should "write a JS file in place" do | ||||||
|  |  | ||||||
|  | @ -94,13 +94,13 @@ class TestCollections < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "a collection with permalink" do |   context "a collection with permalink" do | ||||||
|     setup do |     setup do | ||||||
|       @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"] | ||||||
|     end |     end | ||||||
|  | @ -112,9 +112,9 @@ 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"] | ||||||
|     end |     end | ||||||
|  | @ -154,35 +154,35 @@ class TestCollections < JekyllUnitTest | ||||||
|     should "not include the underscored files in the list of docs" do |     should "not include the underscored files in the list of docs" do | ||||||
|       refute_includes @collection.docs.map(&:relative_path), "_methods/_do_not_read_me.md" |       refute_includes @collection.docs.map(&:relative_path), "_methods/_do_not_read_me.md" | ||||||
|       refute_includes @collection.docs.map(&:relative_path), |       refute_includes @collection.docs.map(&:relative_path), | ||||||
|                                            "_methods/site/_dont_include_me_either.md" |                       "_methods/site/_dont_include_me_either.md" | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   context "with a collection with metadata" do |   context "with a collection with metadata" do | ||||||
|     setup do |     setup do | ||||||
|       @site = fixture_site({ |       @site = fixture_site( | ||||||
|         "collections" => { |         "collections" => { | ||||||
|           "methods" => { |           "methods" => { | ||||||
|             "foo" => "bar", |             "foo" => "bar", | ||||||
|             "baz" => "whoo", |             "baz" => "whoo", | ||||||
|           }, |           }, | ||||||
|         }, |         } | ||||||
|       }) |       ) | ||||||
|       @site.process |       @site.process | ||||||
|       @collection = @site.collections["methods"] |       @collection = @site.collections["methods"] | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "extract the configuration collection information as metadata" do |     should "extract the configuration collection information as metadata" do | ||||||
|       assert_equal @collection.metadata, { "foo" => "bar", "baz" => "whoo" } |       assert_equal @collection.metadata, "foo" => "bar", "baz" => "whoo" | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   context "in safe mode" do |   context "in safe mode" do | ||||||
|     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"] | ||||||
|     end |     end | ||||||
|  | @ -202,10 +202,10 @@ class TestCollections < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "with dots in the filenames" do |   context "with dots in the filenames" do | ||||||
|     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"] | ||||||
|     end |     end | ||||||
|  | @ -231,14 +231,14 @@ class TestCollections < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "a collection with included dotfiles" do |   context "a collection with included dotfiles" do | ||||||
|     setup do |     setup do | ||||||
|       @site = fixture_site({ |       @site = fixture_site( | ||||||
|         "collections" => { |         "collections" => { | ||||||
|           "methods" => { |           "methods" => { | ||||||
|             "permalink" => "/awesome/:path/", |             "permalink" => "/awesome/:path/", | ||||||
|           }, |           }, | ||||||
|         }, |         }, | ||||||
|         "include"     => %w(.htaccess .gitignore), |         "include"     => %w(.htaccess .gitignore) | ||||||
|       }) |       ) | ||||||
|       @site.process |       @site.process | ||||||
|       @collection = @site.collections["methods"] |       @collection = @site.collections["methods"] | ||||||
|     end |     end | ||||||
|  |  | ||||||
|  | @ -15,7 +15,9 @@ class TestCommand < JekyllUnitTest | ||||||
|     context "when fatal error occurs" do |     context "when fatal error occurs" do | ||||||
|       should "exit with non-zero error code" do |       should "exit with non-zero error code" do | ||||||
|         site = Object.new |         site = Object.new | ||||||
|         def site.process; raise Jekyll::Errors::FatalException; end |         def site.process | ||||||
|  |           raise Jekyll::Errors::FatalException | ||||||
|  |         end | ||||||
|         error = assert_raises(SystemExit) { Command.process_site(site) } |         error = assert_raises(SystemExit) { Command.process_site(site) } | ||||||
|         refute_equal 0, error.status |         refute_equal 0, error.status | ||||||
|       end |       end | ||||||
|  |  | ||||||
|  | @ -5,7 +5,6 @@ require "mercenary" | ||||||
| require "helper" | require "helper" | ||||||
| require "httpclient" | require "httpclient" | ||||||
| require "openssl" | require "openssl" | ||||||
| require "thread" |  | ||||||
| require "tmpdir" | require "tmpdir" | ||||||
| 
 | 
 | ||||||
| class TestCommandsServe < JekyllUnitTest | class TestCommandsServe < JekyllUnitTest | ||||||
|  | @ -126,9 +125,9 @@ class TestCommandsServe < JekyllUnitTest | ||||||
|     should "apply the max and min delay options" do |     should "apply the max and min delay options" do | ||||||
|       skip_if_windows "EventMachine support on Windows is limited" |       skip_if_windows "EventMachine support on Windows is limited" | ||||||
|       opts = serve(@standard_options.merge( |       opts = serve(@standard_options.merge( | ||||||
|         "livereload_max_delay" => "1066", |                      "livereload_max_delay" => "1066", | ||||||
|         "livereload_min_delay" => "3" |                      "livereload_min_delay" => "3" | ||||||
|       )) |                    )) | ||||||
|       content = @client.get_content( |       content = @client.get_content( | ||||||
|         "http://#{opts["host"]}:#{opts["port"]}/#{opts["baseurl"]}/hello.html" |         "http://#{opts["host"]}:#{opts["port"]}/#{opts["baseurl"]}/hello.html" | ||||||
|       ) |       ) | ||||||
|  | @ -191,14 +190,14 @@ class TestCommandsServe < JekyllUnitTest | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       should "use user destinations" do |       should "use user destinations" do | ||||||
|         assert_equal "foo", custom_opts({ "destination" => "foo" })[ |         assert_equal "foo", custom_opts("destination" => "foo")[ | ||||||
|           :DocumentRoot |           :DocumentRoot | ||||||
|         ] |         ] | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       should "use user port" do |       should "use user port" do | ||||||
|         # WHAT?!?!1 Over 9000? That's impossible. |         # WHAT?!?!1 Over 9000? That's impossible. | ||||||
|         assert_equal 9001, custom_opts({ "port" => 9001 })[ |         assert_equal 9001, custom_opts("port" => 9001)[ | ||||||
|           :Port |           :Port | ||||||
|         ] |         ] | ||||||
|       end |       end | ||||||
|  | @ -237,21 +236,20 @@ class TestCommandsServe < JekyllUnitTest | ||||||
|           expect(Jekyll::Commands::Serve).to receive(:start_up_webrick) |           expect(Jekyll::Commands::Serve).to receive(:start_up_webrick) | ||||||
|         end |         end | ||||||
|         should "set the site url by default to `http://localhost:4000`" do |         should "set the site url by default to `http://localhost:4000`" do | ||||||
|           @merc.execute(:serve, { "watch" => false, "url" => "https://jekyllrb.com/" }) |           @merc.execute(:serve, "watch" => false, "url" => "https://jekyllrb.com/") | ||||||
| 
 | 
 | ||||||
|           assert_equal 1, Jekyll.sites.count |           assert_equal 1, Jekyll.sites.count | ||||||
|           assert_equal "http://localhost:4000", Jekyll.sites.first.config["url"] |           assert_equal "http://localhost:4000", Jekyll.sites.first.config["url"] | ||||||
|         end |         end | ||||||
| 
 | 
 | ||||||
|         should "take `host`, `port` and `ssl` into consideration if set" do |         should "take `host`, `port` and `ssl` into consideration if set" do | ||||||
|           @merc.execute(:serve, { |           @merc.execute(:serve, | ||||||
|             "watch"    => false, |                         "watch"    => false, | ||||||
|             "host"     => "example.com", |                         "host"     => "example.com", | ||||||
|             "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 | ||||||
|           assert_equal "https://example.com:9999", Jekyll.sites.first.config["url"] |           assert_equal "https://example.com:9999", Jekyll.sites.first.config["url"] | ||||||
|  | @ -262,7 +260,7 @@ class TestCommandsServe < JekyllUnitTest | ||||||
|         should "not update the site url" do |         should "not update the site url" do | ||||||
|           expect(Jekyll).to receive(:env).and_return("production") |           expect(Jekyll).to receive(:env).and_return("production") | ||||||
|           expect(Jekyll::Commands::Serve).to receive(:start_up_webrick) |           expect(Jekyll::Commands::Serve).to receive(:start_up_webrick) | ||||||
|           @merc.execute(:serve, { "watch" => false, "url" => "https://jekyllrb.com/" }) |           @merc.execute(:serve, "watch" => false, "url" => "https://jekyllrb.com/") | ||||||
| 
 | 
 | ||||||
|           assert_equal 1, Jekyll.sites.count |           assert_equal 1, Jekyll.sites.count | ||||||
|           assert_equal "https://jekyllrb.com/", Jekyll.sites.first.config["url"] |           assert_equal "https://jekyllrb.com/", Jekyll.sites.first.config["url"] | ||||||
|  | @ -271,7 +269,7 @@ class TestCommandsServe < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|       context "verbose" do |       context "verbose" do | ||||||
|         should "debug when verbose" do |         should "debug when verbose" do | ||||||
|           assert_equal custom_opts({ "verbose" => true })[:Logger].level, 5 |           assert_equal custom_opts("verbose" => true)[:Logger].level, 5 | ||||||
|         end |         end | ||||||
| 
 | 
 | ||||||
|         should "warn when not verbose" do |         should "warn when not verbose" do | ||||||
|  | @ -282,15 +280,15 @@ class TestCommandsServe < JekyllUnitTest | ||||||
|       context "enabling SSL" do |       context "enabling SSL" do | ||||||
|         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 | ||||||
| 
 | 
 | ||||||
|  | @ -299,12 +297,12 @@ class TestCommandsServe < JekyllUnitTest | ||||||
|           expect(OpenSSL::X509::Certificate).to receive(:new).and_return("c1") |           expect(OpenSSL::X509::Certificate).to receive(:new).and_return("c1") | ||||||
|           allow(File).to receive(:read).and_return("foo") |           allow(File).to receive(:read).and_return("foo") | ||||||
| 
 | 
 | ||||||
|           result = custom_opts({ |           result = custom_opts( | ||||||
|             "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] | ||||||
|           assert_equal result[:SSLPrivateKey],  "c2" |           assert_equal result[:SSLPrivateKey],  "c2" | ||||||
|  | @ -317,7 +315,7 @@ class TestCommandsServe < JekyllUnitTest | ||||||
|       allow(Jekyll::Commands::Serve).to receive(:start_up_webrick) |       allow(Jekyll::Commands::Serve).to receive(:start_up_webrick) | ||||||
| 
 | 
 | ||||||
|       expect(Jekyll).to receive(:configuration).once.and_call_original |       expect(Jekyll).to receive(:configuration).once.and_call_original | ||||||
|       @merc.execute(:serve, { "watch" => false }) |       @merc.execute(:serve, "watch" => false) | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| end | end | ||||||
|  |  | ||||||
|  | @ -15,7 +15,7 @@ class TestConfiguration < JekyllUnitTest | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "merge input over defaults" do |     should "merge input over defaults" do | ||||||
|       result = Configuration.from({ "source" => "blah" }) |       result = Configuration.from("source" => "blah") | ||||||
|       refute_equal result["source"], Configuration::DEFAULTS["source"] |       refute_equal result["source"], Configuration::DEFAULTS["source"] | ||||||
|       assert_equal result["source"], "blah" |       assert_equal result["source"], "blah" | ||||||
|     end |     end | ||||||
|  | @ -28,11 +28,9 @@ class TestConfiguration < JekyllUnitTest | ||||||
|       result = Configuration.from({}) |       result = Configuration.from({}) | ||||||
|       assert_equal( |       assert_equal( | ||||||
|         result["collections"], |         result["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 | ||||||
|  | @ -72,7 +70,7 @@ class TestConfiguration < JekyllUnitTest | ||||||
|       assert_instance_of Hash, result["collections"] |       assert_instance_of Hash, result["collections"] | ||||||
|       assert_equal( |       assert_equal( | ||||||
|         result["collections"], |         result["collections"], | ||||||
|         { "posts" => { "output" => true }, "methods" => {} } |         "posts" => { "output" => true }, "methods" => {} | ||||||
|       ) |       ) | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|  | @ -81,17 +79,15 @@ class TestConfiguration < JekyllUnitTest | ||||||
|         .add_default_collections |         .add_default_collections | ||||||
|       assert_equal( |       assert_equal( | ||||||
|         result["collections"], |         result["collections"], | ||||||
|         { |         "posts" => { | ||||||
|           "posts" => { |           "output"    => true, | ||||||
|             "output"    => true, |           "permalink" => "/:categories/:year/:month/:day/:title/", | ||||||
|             "permalink" => "/:categories/:year/:month/:day/:title/", |  | ||||||
|           }, |  | ||||||
|         } |         } | ||||||
|       ) |       ) | ||||||
| 
 | 
 | ||||||
|       result = Configuration[{ "permalink" => nil, "collections" => {} }] |       result = Configuration[{ "permalink" => nil, "collections" => {} }] | ||||||
|         .add_default_collections |         .add_default_collections | ||||||
|       assert_equal result["collections"], { "posts" => { "output" => true } } |       assert_equal result["collections"], "posts" => { "output" => true } | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "forces posts to output" do |     should "forces posts to output" do | ||||||
|  | @ -186,7 +182,7 @@ class TestConfiguration < JekyllUnitTest | ||||||
|       allow(SafeYAML) |       allow(SafeYAML) | ||||||
|         .to receive(:load_file) |         .to receive(:load_file) | ||||||
|         .with("not_empty.yml") |         .with("not_empty.yml") | ||||||
|         .and_return({ "foo" => "bar", "include" => "", "exclude" => "" }) |         .and_return("foo" => "bar", "include" => "", "exclude" => "") | ||||||
|       Jekyll.logger.log_level = :warn |       Jekyll.logger.log_level = :warn | ||||||
|       read_config = @config.read_config_files(["empty.yml", "not_empty.yml"]) |       read_config = @config.read_config_files(["empty.yml", "not_empty.yml"]) | ||||||
|       Jekyll.logger.log_level = :info |       Jekyll.logger.log_level = :info | ||||||
|  | @ -301,11 +297,11 @@ class TestConfiguration < JekyllUnitTest | ||||||
|       allow($stderr) |       allow($stderr) | ||||||
|         .to receive(:puts) |         .to receive(:puts) | ||||||
|         .with(Colorator.red( |         .with(Colorator.red( | ||||||
|           "Fatal: ".rjust(20) + \ |                 "Fatal: ".rjust(20) + \ | ||||||
|           "The configuration file '#{@user_config}' could not be found." |                 "The configuration file '#{@user_config}' could not be found." | ||||||
|         )) |               )) | ||||||
|       assert_raises LoadError do |       assert_raises LoadError do | ||||||
|         Jekyll.configuration({ "config" => [@user_config] }) |         Jekyll.configuration("config" => [@user_config]) | ||||||
|       end |       end | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|  | @ -334,14 +330,14 @@ class TestConfiguration < JekyllUnitTest | ||||||
|       allow(SafeYAML) |       allow(SafeYAML) | ||||||
|         .to receive(:load_file) |         .to receive(:load_file) | ||||||
|         .with(@paths[:other]) |         .with(@paths[:other]) | ||||||
|         .and_return({ "baseurl" => "http://example.com" }) |         .and_return("baseurl" => "http://example.com") | ||||||
|       allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:other]}") |       allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:other]}") | ||||||
|       assert_equal \ |       assert_equal \ | ||||||
|         site_configuration({ |         site_configuration( | ||||||
|           "baseurl" => "http://example.com", |           "baseurl" => "http://example.com", | ||||||
|           "config"  => @paths[:other], |           "config"  => @paths[:other] | ||||||
|         }), |         ), | ||||||
|         Jekyll.configuration(test_config.merge({ "config" => @paths[:other] })) |         Jekyll.configuration(test_config.merge("config" => @paths[:other])) | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "load different config if specified with symbol key" do |     should "load different config if specified with symbol key" do | ||||||
|  | @ -349,33 +345,33 @@ class TestConfiguration < JekyllUnitTest | ||||||
|       allow(SafeYAML) |       allow(SafeYAML) | ||||||
|         .to receive(:load_file) |         .to receive(:load_file) | ||||||
|         .with(@paths[:other]) |         .with(@paths[:other]) | ||||||
|         .and_return({ "baseurl" => "http://example.com" }) |         .and_return("baseurl" => "http://example.com") | ||||||
|       allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:other]}") |       allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:other]}") | ||||||
|       assert_equal \ |       assert_equal \ | ||||||
|         site_configuration({ |         site_configuration( | ||||||
|           "baseurl" => "http://example.com", |           "baseurl" => "http://example.com", | ||||||
|           "config"  => @paths[:other], |           "config"  => @paths[:other] | ||||||
|         }), |         ), | ||||||
|         Jekyll.configuration(test_config.merge({ :config => @paths[:other] })) |         Jekyll.configuration(test_config.merge(:config => @paths[:other])) | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "load default config if path passed is empty" do |     should "load default config if path passed is empty" do | ||||||
|       allow(SafeYAML).to receive(:load_file).with(@paths[:default]).and_return({}) |       allow(SafeYAML).to receive(:load_file).with(@paths[:default]).and_return({}) | ||||||
|       allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:default]}") |       allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:default]}") | ||||||
|       assert_equal \ |       assert_equal \ | ||||||
|         site_configuration({ "config" => [@paths[:empty]] }), |         site_configuration("config" => [@paths[:empty]]), | ||||||
|         Jekyll.configuration(test_config.merge({ "config" => [@paths[:empty]] })) |         Jekyll.configuration(test_config.merge("config" => [@paths[:empty]])) | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "successfully load a TOML file" do |     should "successfully load a TOML file" do | ||||||
|       Jekyll.logger.log_level = :warn |       Jekyll.logger.log_level = :warn | ||||||
|       assert_equal \ |       assert_equal \ | ||||||
|         site_configuration({ |         site_configuration( | ||||||
|           "baseurl" => "/you-beautiful-blog-you", |           "baseurl" => "/you-beautiful-blog-you", | ||||||
|           "title"   => "My magnificent site, wut", |           "title"   => "My magnificent site, wut", | ||||||
|           "config"  => [@paths[:toml]], |           "config"  => [@paths[:toml]] | ||||||
|         }), |         ), | ||||||
|         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 | ||||||
| 
 | 
 | ||||||
|  | @ -389,12 +385,12 @@ class TestConfiguration < JekyllUnitTest | ||||||
|       allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:other]}") |       allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:other]}") | ||||||
|       allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:toml]}") |       allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:toml]}") | ||||||
|       assert_equal( |       assert_equal( | ||||||
|         site_configuration({ |         site_configuration( | ||||||
|           "config" => [@paths[:default], @paths[:other], @paths[:toml]], |           "config" => [@paths[:default], @paths[:other], @paths[:toml]] | ||||||
|         }), |         ), | ||||||
|         Jekyll.configuration( |         Jekyll.configuration( | ||||||
|           test_config.merge( |           test_config.merge( | ||||||
|             { "config" => [@paths[:default], @paths[:other], @paths[:toml]] } |             "config" => [@paths[:default], @paths[:other], @paths[:toml]] | ||||||
|           ) |           ) | ||||||
|         ) |         ) | ||||||
|       ) |       ) | ||||||
|  | @ -404,11 +400,11 @@ class TestConfiguration < JekyllUnitTest | ||||||
|       allow(SafeYAML) |       allow(SafeYAML) | ||||||
|         .to receive(:load_file) |         .to receive(:load_file) | ||||||
|         .with(@paths[:default]) |         .with(@paths[:default]) | ||||||
|         .and_return({ "baseurl" => "http://example.dev" }) |         .and_return("baseurl" => "http://example.dev") | ||||||
|       allow(SafeYAML) |       allow(SafeYAML) | ||||||
|         .to receive(:load_file) |         .to receive(:load_file) | ||||||
|         .with(@paths[:other]) |         .with(@paths[:other]) | ||||||
|         .and_return({ "baseurl" => "http://example.com" }) |         .and_return("baseurl" => "http://example.com") | ||||||
|       allow($stdout) |       allow($stdout) | ||||||
|         .to receive(:puts) |         .to receive(:puts) | ||||||
|         .with("Configuration file: #{@paths[:default]}") |         .with("Configuration file: #{@paths[:default]}") | ||||||
|  | @ -416,12 +412,12 @@ class TestConfiguration < JekyllUnitTest | ||||||
|         .to receive(:puts) |         .to receive(:puts) | ||||||
|         .with("Configuration file: #{@paths[:other]}") |         .with("Configuration file: #{@paths[:other]}") | ||||||
|       assert_equal \ |       assert_equal \ | ||||||
|         site_configuration({ |         site_configuration( | ||||||
|           "baseurl" => "http://example.com", |           "baseurl" => "http://example.com", | ||||||
|           "config"  => [@paths[:default], @paths[:other]], |           "config"  => [@paths[:default], @paths[:other]] | ||||||
|         }), |         ), | ||||||
|         Jekyll.configuration( |         Jekyll.configuration( | ||||||
|           test_config.merge({ "config" => [@paths[:default], @paths[:other]] }) |           test_config.merge("config" => [@paths[:default], @paths[:other]]) | ||||||
|         ) |         ) | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
|  | @ -437,41 +433,41 @@ class TestConfiguration < JekyllUnitTest | ||||||
|       conf = Configuration[default_configuration].tap do |c| |       conf = Configuration[default_configuration].tap do |c| | ||||||
|         c["collections"] = ["docs"] |         c["collections"] = ["docs"] | ||||||
|       end |       end | ||||||
|       assert_equal conf.add_default_collections, conf.merge({ |       assert_equal conf.add_default_collections, conf.merge( | ||||||
|         "collections" => { |         "collections" => { | ||||||
|           "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 | ||||||
| 
 | 
 | ||||||
|     should "force collections.posts.output = true" do |     should "force collections.posts.output = true" do | ||||||
|       conf = Configuration[default_configuration].tap do |c| |       conf = Configuration[default_configuration].tap do |c| | ||||||
|         c["collections"] = { "posts" => { "output" => false } } |         c["collections"] = { "posts" => { "output" => false } } | ||||||
|       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" => "/:categories/:year/:month/:day/:title:output_ext", |             "permalink" => "/:categories/:year/:month/:day/:title:output_ext", | ||||||
|           }, |           }, | ||||||
|         }, |         } | ||||||
|       }) |       ) | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "set collections.posts.permalink if it's not set" do |     should "set collections.posts.permalink if it's not set" do | ||||||
|       conf = Configuration[default_configuration] |       conf = Configuration[default_configuration] | ||||||
|       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" => "/:categories/:year/:month/:day/:title:output_ext", |             "permalink" => "/:categories/:year/:month/:day/:title:output_ext", | ||||||
|           }, |           }, | ||||||
|         }, |         } | ||||||
|       }) |       ) | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "leave collections.posts.permalink alone if it is set" do |     should "leave collections.posts.permalink alone if it is set" do | ||||||
|  | @ -481,14 +477,14 @@ class TestConfiguration < JekyllUnitTest | ||||||
|           "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 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -8,8 +8,8 @@ class TestConvertible < JekyllUnitTest | ||||||
|     setup do |     setup do | ||||||
|       @convertible = OpenStruct.new( |       @convertible = OpenStruct.new( | ||||||
|         "site" => Site.new(Jekyll.configuration( |         "site" => Site.new(Jekyll.configuration( | ||||||
|           "source" => File.expand_path("fixtures", __dir__) |                              "source" => File.expand_path("fixtures", __dir__) | ||||||
|         )) |                            )) | ||||||
|       ) |       ) | ||||||
|       @convertible.extend Jekyll::Convertible |       @convertible.extend Jekyll::Convertible | ||||||
|       @base = File.expand_path("fixtures", __dir__) |       @base = File.expand_path("fixtures", __dir__) | ||||||
|  |  | ||||||
|  | @ -10,10 +10,10 @@ class TestDoctorCommand < JekyllUnitTest | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     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 | ||||||
|         ret = Jekyll::Commands::Doctor.urls_only_differ_by_case(@site) |         ret = Jekyll::Commands::Doctor.urls_only_differ_by_case(@site) | ||||||
|  | @ -23,10 +23,10 @@ class TestDoctorCommand < JekyllUnitTest | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     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 | ||||||
|         ret = Jekyll::Commands::Doctor.urls_only_differ_by_case(@site) |         ret = Jekyll::Commands::Doctor.urls_only_differ_by_case(@site) | ||||||
|  |  | ||||||
|  | @ -10,10 +10,9 @@ class TestDocument < JekyllUnitTest | ||||||
|   def setup_encoded_document(filename) |   def setup_encoded_document(filename) | ||||||
|     site = fixture_site("collections" => ["encodings"]) |     site = fixture_site("collections" => ["encodings"]) | ||||||
|     site.process |     site.process | ||||||
|     Document.new(site.in_source_dir(File.join("_encodings", filename)), { |     Document.new(site.in_source_dir(File.join("_encodings", filename)), | ||||||
|       :site       => site, |                  :site       => site, | ||||||
|       :collection => site.collections["encodings"], |                  :collection => site.collections["encodings"]).tap(&:read) | ||||||
|     }).tap(&:read) |  | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   def setup_document_with_dates(filename) |   def setup_document_with_dates(filename) | ||||||
|  | @ -21,19 +20,18 @@ class TestDocument < JekyllUnitTest | ||||||
|     site.process |     site.process | ||||||
|     docs = nil |     docs = nil | ||||||
|     with_env("TZ", "UTC") do |     with_env("TZ", "UTC") do | ||||||
|       docs = Document.new(site.in_source_dir(File.join("_dates", filename)), { |       docs = Document.new(site.in_source_dir(File.join("_dates", filename)), | ||||||
|         :site       => site, |                           :site       => site, | ||||||
|         :collection => site.collections["dates"], |                           :collection => site.collections["dates"]).tap(&:read) | ||||||
|       }).tap(&:read) |  | ||||||
|     end |     end | ||||||
|     docs |     docs | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   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| | ||||||
|         d.relative_path == "_methods/configuration.md" |         d.relative_path == "_methods/configuration.md" | ||||||
|  | @ -112,7 +110,7 @@ class TestDocument < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|     context "with YAML ending in three dots" do |     context "with YAML ending in three dots" do | ||||||
|       setup do |       setup do | ||||||
|         @site = fixture_site({ "collections" => ["methods"] }) |         @site = fixture_site("collections" => ["methods"]) | ||||||
|         @site.process |         @site.process | ||||||
|         @document = @site.collections["methods"].docs.detect do |d| |         @document = @site.collections["methods"].docs.detect do |d| | ||||||
|           d.relative_path == "_methods/yaml_with_dots.md" |           d.relative_path == "_methods/yaml_with_dots.md" | ||||||
|  | @ -136,7 +134,7 @@ class TestDocument < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "a document as part of a collection with front matter defaults" do |   context "a document as part of a collection with front matter defaults" do | ||||||
|     setup do |     setup do | ||||||
|       @site = fixture_site({ |       @site = fixture_site( | ||||||
|         "collections" => ["slides"], |         "collections" => ["slides"], | ||||||
|         "defaults"    => [{ |         "defaults"    => [{ | ||||||
|           "scope"  => { "path" => "", "type" => "slides" }, |           "scope"  => { "path" => "", "type" => "slides" }, | ||||||
|  | @ -145,8 +143,8 @@ class TestDocument < JekyllUnitTest | ||||||
|               "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 | ||||||
|     end |     end | ||||||
|  | @ -166,7 +164,7 @@ class TestDocument < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "a document as part of a collection with overridden default values" do |   context "a document as part of a collection with overridden default values" do | ||||||
|     setup do |     setup do | ||||||
|       @site = fixture_site({ |       @site = fixture_site( | ||||||
|         "collections" => ["slides"], |         "collections" => ["slides"], | ||||||
|         "defaults"    => [{ |         "defaults"    => [{ | ||||||
|           "scope"  => { "path" => "", "type" => "slides" }, |           "scope"  => { "path" => "", "type" => "slides" }, | ||||||
|  | @ -176,8 +174,8 @@ class TestDocument < JekyllUnitTest | ||||||
|               "test2" => "default1", |               "test2" => "default1", | ||||||
|             }, |             }, | ||||||
|           }, |           }, | ||||||
|         },], |         },] | ||||||
|       }) |       ) | ||||||
|       @site.process |       @site.process | ||||||
|       @document = @site.collections["slides"].docs[1] |       @document = @site.collections["slides"].docs[1] | ||||||
|     end |     end | ||||||
|  | @ -194,7 +192,7 @@ class TestDocument < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "a document as part of a collection with valid path" do |   context "a document as part of a collection with valid path" do | ||||||
|     setup do |     setup do | ||||||
|       @site = fixture_site({ |       @site = fixture_site( | ||||||
|         "collections" => ["slides"], |         "collections" => ["slides"], | ||||||
|         "defaults"    => [{ |         "defaults"    => [{ | ||||||
|           "scope"  => { "path" => "_slides", "type" => "slides" }, |           "scope"  => { "path" => "_slides", "type" => "slides" }, | ||||||
|  | @ -203,8 +201,8 @@ class TestDocument < JekyllUnitTest | ||||||
|               "key" => "value123", |               "key" => "value123", | ||||||
|             }, |             }, | ||||||
|           }, |           }, | ||||||
|         },], |         },] | ||||||
|       }) |       ) | ||||||
|       @site.process |       @site.process | ||||||
|       @document = @site.collections["slides"].docs.first |       @document = @site.collections["slides"].docs.first | ||||||
|     end |     end | ||||||
|  | @ -218,7 +216,7 @@ class TestDocument < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "a document as part of a collection with invalid path" do |   context "a document as part of a collection with invalid path" do | ||||||
|     setup do |     setup do | ||||||
|       @site = fixture_site({ |       @site = fixture_site( | ||||||
|         "collections" => ["slides"], |         "collections" => ["slides"], | ||||||
|         "defaults"    => [{ |         "defaults"    => [{ | ||||||
|           "scope"  => { "path" => "somepath", "type" => "slides" }, |           "scope"  => { "path" => "somepath", "type" => "slides" }, | ||||||
|  | @ -227,8 +225,8 @@ class TestDocument < JekyllUnitTest | ||||||
|               "key" => "myval", |               "key" => "myval", | ||||||
|             }, |             }, | ||||||
|           }, |           }, | ||||||
|         },], |         },] | ||||||
|       }) |       ) | ||||||
|       @site.process |       @site.process | ||||||
|       @document = @site.collections["slides"].docs.first |       @document = @site.collections["slides"].docs.first | ||||||
|     end |     end | ||||||
|  | @ -242,9 +240,9 @@ 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] | ||||||
|       @dest_file = dest_dir("slide/3/index.html") |       @dest_file = dest_dir("slide/3/index.html") | ||||||
|  | @ -261,15 +259,15 @@ class TestDocument < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "a document in a collection with custom filename permalinks" do |   context "a document in a collection with custom filename permalinks" do | ||||||
|     setup do |     setup do | ||||||
|       @site = fixture_site({ |       @site = fixture_site( | ||||||
|         "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] | ||||||
|       @dest_file = dest_dir("slides/test/example-slide-1.html") |       @dest_file = dest_dir("slides/test/example-slide-1.html") | ||||||
|  | @ -290,13 +288,13 @@ class TestDocument < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "a document in a collection with pretty permalink style" do |   context "a document in a collection with pretty permalink style" do | ||||||
|     setup do |     setup do | ||||||
|       @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 | ||||||
|       @document = @site.collections["slides"].docs[0] |       @document = @site.collections["slides"].docs[0] | ||||||
|  | @ -314,13 +312,13 @@ class TestDocument < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "a document in a collection with cased file name" do |   context "a document in a collection with cased file name" do | ||||||
|     setup do |     setup do | ||||||
|       @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 | ||||||
|       @document = @site.collections["slides"].docs[7] |       @document = @site.collections["slides"].docs[7] | ||||||
|  | @ -334,13 +332,13 @@ class TestDocument < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "a document in a collection with cased file name" do |   context "a document in a collection with cased file name" do | ||||||
|     setup do |     setup do | ||||||
|       @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] | ||||||
|       @dest_file = dest_dir("slides/example-slide-7.php") |       @dest_file = dest_dir("slides/example-slide-7.php") | ||||||
|  | @ -365,14 +363,14 @@ class TestDocument < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "documents in a collection with custom title permalinks" do |   context "documents in a collection with custom title permalinks" do | ||||||
|     setup do |     setup do | ||||||
|       @site = fixture_site({ |       @site = fixture_site( | ||||||
|         "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] | ||||||
|       @document_without_slug = @site.collections["slides"].docs[4] |       @document_without_slug = @site.collections["slides"].docs[4] | ||||||
|  | @ -410,9 +408,9 @@ 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") | ||||||
|  | @ -433,13 +431,13 @@ class TestDocument < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "documents in a collection" do |   context "documents in a collection" do | ||||||
|     setup do |     setup do | ||||||
|       @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 | ||||||
|     end |     end | ||||||
|  | @ -465,13 +463,13 @@ class TestDocument < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "a static file in a collection" do |   context "a static file in a collection" do | ||||||
|     setup do |     setup do | ||||||
|       @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| | ||||||
|         doc.relative_path == "_slides/octojekyll.png" |         doc.relative_path == "_slides/octojekyll.png" | ||||||
|  | @ -498,13 +496,13 @@ class TestDocument < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "a document in a collection with non-alphabetic file name" do |   context "a document in a collection with non-alphabetic file name" do | ||||||
|     setup do |     setup do | ||||||
|       @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| | ||||||
|         doc.relative_path == "_methods/escape-+ #%20[].md" |         doc.relative_path == "_methods/escape-+ #%20[].md" | ||||||
|  | @ -527,13 +525,13 @@ class TestDocument < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "a document in a collection with dash-separated numeric file name" do |   context "a document in a collection with dash-separated numeric file name" do | ||||||
|     setup do |     setup do | ||||||
|       @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| | ||||||
|         doc.relative_path == "_methods/3940394-21-9393050-fifif1323-test.md" |         doc.relative_path == "_methods/3940394-21-9393050-fifif1323-test.md" | ||||||
|  |  | ||||||
|  | @ -17,9 +17,9 @@ end | ||||||
| class TestDrop < JekyllUnitTest | class TestDrop < JekyllUnitTest | ||||||
|   context "Drops" do |   context "Drops" 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| | ||||||
|         d.relative_path == "_methods/configuration.md" |         d.relative_path == "_methods/configuration.md" | ||||||
|  |  | ||||||
|  | @ -10,7 +10,7 @@ class TestEntryFilter < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|     should "filter entries" do |     should "filter entries" do | ||||||
|       ent1 = %w(foo.markdown bar.markdown baz.markdown #baz.markdown# |       ent1 = %w(foo.markdown bar.markdown baz.markdown #baz.markdown# | ||||||
|               .baz.markdow foo.markdown~ .htaccess _posts _pages ~$benbalter.docx) |                 .baz.markdow foo.markdown~ .htaccess _posts _pages ~$benbalter.docx) | ||||||
| 
 | 
 | ||||||
|       entries = EntryFilter.new(@site).filter(ent1) |       entries = EntryFilter.new(@site).filter(ent1) | ||||||
|       assert_equal %w(foo.markdown bar.markdown baz.markdown .htaccess), entries |       assert_equal %w(foo.markdown bar.markdown baz.markdown .htaccess), entries | ||||||
|  |  | ||||||
|  | @ -4,10 +4,9 @@ require "helper" | ||||||
| 
 | 
 | ||||||
| class TestExcerpt < JekyllUnitTest | 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) | ||||||
|  | @ -81,9 +80,9 @@ class TestExcerpt < JekyllUnitTest | ||||||
|     context "#relative_path" do |     context "#relative_path" do | ||||||
|       should "return its document's relative path with '/#excerpt' appended" do |       should "return its document's relative path with '/#excerpt' appended" do | ||||||
|         assert_equal "#{@excerpt.doc.relative_path}/#excerpt", |         assert_equal "#{@excerpt.doc.relative_path}/#excerpt", | ||||||
|           @excerpt.relative_path |                      @excerpt.relative_path | ||||||
|         assert_equal "_posts/2013-07-22-post-excerpt-with-layout.markdown/#excerpt", |         assert_equal "_posts/2013-07-22-post-excerpt-with-layout.markdown/#excerpt", | ||||||
|           @excerpt.relative_path |                      @excerpt.relative_path | ||||||
|       end |       end | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -9,7 +9,7 @@ class TestFilters < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|     def initialize(opts = {}) |     def initialize(opts = {}) | ||||||
|       @site = Jekyll::Site.new(opts.merge("skip_config_files" => true)) |       @site = Jekyll::Site.new(opts.merge("skip_config_files" => true)) | ||||||
|       @context = Liquid::Context.new(@site.site_payload, {}, { :site => @site }) |       @context = Liquid::Context.new(@site.site_payload, {}, :site => @site) | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|  | @ -37,12 +37,12 @@ class TestFilters < JekyllUnitTest | ||||||
|   context "filters" do |   context "filters" do | ||||||
|     setup do |     setup do | ||||||
|       @sample_time = Time.utc(2013, 3, 27, 11, 22, 33) |       @sample_time = Time.utc(2013, 3, 27, 11, 22, 33) | ||||||
|       @filter = make_filter_mock({ |       @filter = make_filter_mock( | ||||||
|         "timezone"               => "UTC", |         "timezone"               => "UTC", | ||||||
|         "url"                    => "http://example.com", |         "url"                    => "http://example.com", | ||||||
|         "baseurl"                => "/base", |         "baseurl"                => "/base", | ||||||
|         "dont_show_posts_before" => @sample_time, |         "dont_show_posts_before" => @sample_time | ||||||
|       }) |       ) | ||||||
|       @sample_date = Date.parse("2013-03-02") |       @sample_date = Date.parse("2013-03-02") | ||||||
|       @time_as_string = "September 11, 2001 12:46:30 -0000" |       @time_as_string = "September 11, 2001 12:46:30 -0000" | ||||||
|       @time_as_numeric = 1_399_680_607 |       @time_as_numeric = 1_399_680_607 | ||||||
|  | @ -88,7 +88,7 @@ class TestFilters < JekyllUnitTest | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       should "escapes special characters when configured to do so" do |       should "escapes special characters when configured to do so" do | ||||||
|         kramdown = make_filter_mock({ :kramdown => { :entity_output => :symbolic } }) |         kramdown = make_filter_mock(:kramdown => { :entity_output => :symbolic }) | ||||||
|         assert_equal( |         assert_equal( | ||||||
|           "“This filter’s test…”", |           "“This filter’s test…”", | ||||||
|           kramdown.smartify(%q{"This filter's test..."}) |           kramdown.smartify(%q{"This filter's test..."}) | ||||||
|  | @ -406,82 +406,82 @@ class TestFilters < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|       should "ensure the leading slash for the baseurl" do |       should "ensure the leading slash for the baseurl" do | ||||||
|         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 | ||||||
| 
 | 
 | ||||||
|       should "be ok with a blank but present 'url'" do |       should "be ok with a blank but present 'url'" do | ||||||
|         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 | ||||||
| 
 | 
 | ||||||
|       should "be ok with a nil 'url'" do |       should "be ok with a nil 'url'" do | ||||||
|         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 | ||||||
| 
 | 
 | ||||||
|       should "be ok with a nil 'baseurl'" do |       should "be ok with a nil 'baseurl'" do | ||||||
|         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 | ||||||
| 
 | 
 | ||||||
|       should "not prepend a forward slash if input is empty" do |       should "not prepend a forward slash if input is empty" do | ||||||
|         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 | ||||||
| 
 | 
 | ||||||
|       should "not append a forward slash if input is '/'" do |       should "not append a forward slash if input is '/'" do | ||||||
|         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 | ||||||
| 
 | 
 | ||||||
|       should "not append a forward slash if input is '/' and nil 'baseurl'" do |       should "not append a forward slash if input is '/' and nil 'baseurl'" do | ||||||
|         page_url = "/" |         page_url = "/" | ||||||
|         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/", filter.absolute_url(page_url) |         assert_equal "http://example.com/", filter.absolute_url(page_url) | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       should "not append a forward slash if both input and baseurl are simply '/'" do |       should "not append a forward slash if both input and baseurl are simply '/'" do | ||||||
|         page_url = "/" |         page_url = "/" | ||||||
|         filter = make_filter_mock({ |         filter = make_filter_mock( | ||||||
|           "url"     => "http://example.com", |           "url"     => "http://example.com", | ||||||
|           "baseurl" => "/", |           "baseurl" => "/" | ||||||
|         }) |         ) | ||||||
|         assert_equal "http://example.com/", filter.absolute_url(page_url) |         assert_equal "http://example.com/", filter.absolute_url(page_url) | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       should "normalize international URLs" do |       should "normalize international URLs" do | ||||||
|         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 | ||||||
| 
 | 
 | ||||||
|  | @ -492,19 +492,19 @@ class TestFilters < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|       should "transform the input URL to a string" do |       should "transform the input URL to a string" do | ||||||
|         page_url = "/my-page.html" |         page_url = "/my-page.html" | ||||||
|         filter = make_filter_mock({ "url" => Value.new(proc { "http://example.org" }) }) |         filter = make_filter_mock("url" => Value.new(proc { "http://example.org" })) | ||||||
|         assert_equal "http://example.org#{page_url}", filter.absolute_url(page_url) |         assert_equal "http://example.org#{page_url}", filter.absolute_url(page_url) | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       should "not raise a TypeError when passed a hash" do |       should "not raise a TypeError when passed a hash" do | ||||||
|         assert @filter.absolute_url({ "foo" => "bar" }) |         assert @filter.absolute_url("foo" => "bar") | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       context "with a document" do |       context "with a document" 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| | ||||||
|             d.relative_path == "_methods/configuration.md" |             d.relative_path == "_methods/configuration.md" | ||||||
|  | @ -531,7 +531,7 @@ class TestFilters < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|       should "ensure the leading slash for the baseurl" do |       should "ensure the leading slash for the baseurl" do | ||||||
|         page_url = "about/my_favorite_page/" |         page_url = "about/my_favorite_page/" | ||||||
|         filter = make_filter_mock({ "baseurl" => "base" }) |         filter = make_filter_mock("baseurl" => "base") | ||||||
|         assert_equal "/base/#{page_url}", filter.relative_url(page_url) |         assert_equal "/base/#{page_url}", filter.relative_url(page_url) | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|  | @ -542,51 +542,51 @@ class TestFilters < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|       should "be ok with a nil 'baseurl'" do |       should "be ok with a nil 'baseurl'" do | ||||||
|         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 | ||||||
| 
 | 
 | ||||||
|       should "not prepend a forward slash if input is empty" do |       should "not prepend a forward slash if input is empty" do | ||||||
|         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 | ||||||
| 
 | 
 | ||||||
|       should "not prepend a forward slash if baseurl ends with a single '/'" do |       should "not prepend a forward slash if baseurl ends with a single '/'" do | ||||||
|         page_url = "/css/main.css" |         page_url = "/css/main.css" | ||||||
|         filter = make_filter_mock({ |         filter = make_filter_mock( | ||||||
|           "url"     => "http://example.com", |           "url"     => "http://example.com", | ||||||
|           "baseurl" => "/base/", |           "baseurl" => "/base/" | ||||||
|         }) |         ) | ||||||
|         assert_equal "/base/css/main.css", filter.relative_url(page_url) |         assert_equal "/base/css/main.css", filter.relative_url(page_url) | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       should "not return valid URI if baseurl ends with multiple '/'" do |       should "not return valid URI if baseurl ends with multiple '/'" do | ||||||
|         page_url = "/css/main.css" |         page_url = "/css/main.css" | ||||||
|         filter = make_filter_mock({ |         filter = make_filter_mock( | ||||||
|           "url"     => "http://example.com", |           "url"     => "http://example.com", | ||||||
|           "baseurl" => "/base//", |           "baseurl" => "/base//" | ||||||
|         }) |         ) | ||||||
|         refute_equal "/base/css/main.css", filter.relative_url(page_url) |         refute_equal "/base/css/main.css", filter.relative_url(page_url) | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       should "not prepend a forward slash if both input and baseurl are simply '/'" do |       should "not prepend a forward slash if both input and baseurl are simply '/'" do | ||||||
|         page_url = "/" |         page_url = "/" | ||||||
|         filter = make_filter_mock({ |         filter = make_filter_mock( | ||||||
|           "url"     => "http://example.com", |           "url"     => "http://example.com", | ||||||
|           "baseurl" => "/", |           "baseurl" => "/" | ||||||
|         }) |         ) | ||||||
|         assert_equal "/", filter.relative_url(page_url) |         assert_equal "/", filter.relative_url(page_url) | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       should "not return the url by reference" do |       should "not return the url by reference" do | ||||||
|         filter = make_filter_mock({ :baseurl => nil }) |         filter = make_filter_mock(:baseurl => nil) | ||||||
|         page = Page.new(filter.site, test_dir("fixtures"), "", "front_matter.erb") |         page = Page.new(filter.site, test_dir("fixtures"), "", "front_matter.erb") | ||||||
|         assert_equal "/front_matter.erb", page.url |         assert_equal "/front_matter.erb", page.url | ||||||
|         url = filter.relative_url(page.url) |         url = filter.relative_url(page.url) | ||||||
|  | @ -596,7 +596,7 @@ class TestFilters < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|       should "transform the input baseurl to a string" do |       should "transform the input baseurl to a string" do | ||||||
|         page_url = "/my-page.html" |         page_url = "/my-page.html" | ||||||
|         filter = make_filter_mock({ "baseurl" => Value.new(proc { "/baseurl/" }) }) |         filter = make_filter_mock("baseurl" => Value.new(proc { "/baseurl/" })) | ||||||
|         assert_equal "/baseurl#{page_url}", filter.relative_url(page_url) |         assert_equal "/baseurl#{page_url}", filter.relative_url(page_url) | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|  | @ -640,7 +640,7 @@ class TestFilters < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|     context "jsonify filter" do |     context "jsonify filter" do | ||||||
|       should "convert hash to json" do |       should "convert hash to json" do | ||||||
|         assert_equal "{\"age\":18}", @filter.jsonify({ :age => 18 }) |         assert_equal "{\"age\":18}", @filter.jsonify(:age => 18) | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       should "convert array to json" do |       should "convert array to json" do | ||||||
|  | @ -705,7 +705,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 | ||||||
|  | @ -973,7 +973,7 @@ class TestFilters < JekyllUnitTest | ||||||
|         @filter.site.tap(&:read) |         @filter.site.tap(&:read) | ||||||
|         posts = @filter.site.site_payload["site"]["posts"] |         posts = @filter.site.site_payload["site"]["posts"] | ||||||
|         results = @filter.where_exp(posts, "post", |         results = @filter.where_exp(posts, "post", | ||||||
|           "post.date > site.dont_show_posts_before") |                                     "post.date > site.dont_show_posts_before") | ||||||
|         assert_equal posts.select { |p| p.date > @sample_time }.count, results.length |         assert_equal posts.select { |p| p.date > @sample_time }.count, results.length | ||||||
|       end |       end | ||||||
|     end |     end | ||||||
|  | @ -1085,19 +1085,19 @@ class TestFilters < JekyllUnitTest | ||||||
|       end |       end | ||||||
|       should "return sorted by property array" do |       should "return sorted by property array" do | ||||||
|         assert_equal [{ "a" => 1 }, { "a" => 2 }, { "a" => 3 }, { "a" => 4 }], |         assert_equal [{ "a" => 1 }, { "a" => 2 }, { "a" => 3 }, { "a" => 4 }], | ||||||
|           @filter.sort([{ "a" => 4 }, { "a" => 3 }, { "a" => 1 }, { "a" => 2 }], "a") |                      @filter.sort([{ "a" => 4 }, { "a" => 3 }, { "a" => 1 }, { "a" => 2 }], "a") | ||||||
|       end |       end | ||||||
|       should "return sorted by property array with numeric strings sorted as numbers" do |       should "return sorted by property array with numeric strings sorted as numbers" do | ||||||
|         assert_equal([{ "a" => ".5" }, { "a" => "0.65" }, { "a" => "10" }], |         assert_equal([{ "a" => ".5" }, { "a" => "0.65" }, { "a" => "10" }], | ||||||
|           @filter.sort([{ "a" => "10" }, { "a" => ".5" }, { "a" => "0.65" }], "a")) |                      @filter.sort([{ "a" => "10" }, { "a" => ".5" }, { "a" => "0.65" }], "a")) | ||||||
|       end |       end | ||||||
|       should "return sorted by property array with numeric strings first" do |       should "return sorted by property array with numeric strings first" do | ||||||
|         assert_equal([{ "a" => ".5" }, { "a" => "0.6" }, { "a" => "twelve" }], |         assert_equal([{ "a" => ".5" }, { "a" => "0.6" }, { "a" => "twelve" }], | ||||||
|           @filter.sort([{ "a" => "twelve" }, { "a" => ".5" }, { "a" => "0.6" }], "a")) |                      @filter.sort([{ "a" => "twelve" }, { "a" => ".5" }, { "a" => "0.6" }], "a")) | ||||||
|       end |       end | ||||||
|       should "return sorted by property array with numbers and strings " do |       should "return sorted by property array with numbers and strings " do | ||||||
|         assert_equal([{ "a" => "1" }, { "a" => "1abc" }, { "a" => "20" }], |         assert_equal([{ "a" => "1" }, { "a" => "1abc" }, { "a" => "20" }], | ||||||
|           @filter.sort([{ "a" => "20" }, { "a" => "1" }, { "a" => "1abc" }], "a")) |                      @filter.sort([{ "a" => "20" }, { "a" => "1" }, { "a" => "1abc" }], "a")) | ||||||
|       end |       end | ||||||
|       should "return sorted by property array with nils first" do |       should "return sorted by property array with nils first" do | ||||||
|         ary = [{ "a" => 2 }, { "b" => 1 }, { "a" => 1 }] |         ary = [{ "a" => 2 }, { "b" => 1 }, { "a" => 1 }] | ||||||
|  | @ -1106,13 +1106,13 @@ class TestFilters < JekyllUnitTest | ||||||
|       end |       end | ||||||
|       should "return sorted by property array with nils last" do |       should "return sorted by property array with nils last" do | ||||||
|         assert_equal [{ "a" => 1 }, { "a" => 2 }, { "b" => 1 }], |         assert_equal [{ "a" => 1 }, { "a" => 2 }, { "b" => 1 }], | ||||||
|           @filter.sort([{ "a" => 2 }, { "b" => 1 }, { "a" => 1 }], "a", "last") |                      @filter.sort([{ "a" => 2 }, { "b" => 1 }, { "a" => 1 }], "a", "last") | ||||||
|       end |       end | ||||||
|       should "return sorted by subproperty array" do |       should "return sorted by subproperty array" do | ||||||
|         assert_equal [{ "a" => { "b" => 1 } }, { "a" => { "b" => 2 } }, |         assert_equal [{ "a" => { "b" => 1 } }, { "a" => { "b" => 2 } }, | ||||||
|                       { "a" => { "b" => 3 } },], |                       { "a" => { "b" => 3 } },], | ||||||
|           @filter.sort([{ "a" => { "b" => 2 } }, { "a" => { "b" => 1 } }, |                      @filter.sort([{ "a" => { "b" => 2 } }, { "a" => { "b" => 1 } }, | ||||||
|                         { "a" => { "b" => 3 } },], "a.b") |                                    { "a" => { "b" => 3 } },], "a.b") | ||||||
|       end |       end | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|  | @ -1140,7 +1140,7 @@ class TestFilters < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|     context "inspect filter" do |     context "inspect filter" do | ||||||
|       should "return a HTML-escaped string representation of an object" do |       should "return a HTML-escaped string representation of an object" do | ||||||
|         assert_equal "{"<a>"=>1}", @filter.inspect({ "<a>" => 1 }) |         assert_equal "{"<a>"=>1}", @filter.inspect("<a>" => 1) | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       should "quote strings" do |       should "quote strings" do | ||||||
|  |  | ||||||
|  | @ -5,7 +5,7 @@ require "helper" | ||||||
| class TestFrontMatterDefaults < JekyllUnitTest | class TestFrontMatterDefaults < JekyllUnitTest | ||||||
|   context "A site with full front matter defaults" do |   context "A site with full front matter defaults" do | ||||||
|     setup do |     setup do | ||||||
|       @site = fixture_site({ |       @site = fixture_site( | ||||||
|         "defaults" => [{ |         "defaults" => [{ | ||||||
|           "scope"  => { |           "scope"  => { | ||||||
|             "path" => "contacts", |             "path" => "contacts", | ||||||
|  | @ -14,8 +14,8 @@ class TestFrontMatterDefaults < JekyllUnitTest | ||||||
|           "values" => { |           "values" => { | ||||||
|             "key" => "val", |             "key" => "val", | ||||||
|           }, |           }, | ||||||
|         },], |         },] | ||||||
|       }) |       ) | ||||||
|       @output = capture_output { @site.process } |       @output = capture_output { @site.process } | ||||||
|       @affected = @site.pages.find { |page| page.relative_path == "contacts/bar.html" } |       @affected = @site.pages.find { |page| page.relative_path == "contacts/bar.html" } | ||||||
|       @not_affected = @site.pages.find { |page| page.relative_path == "about.html" } |       @not_affected = @site.pages.find { |page| page.relative_path == "about.html" } | ||||||
|  | @ -33,7 +33,7 @@ class TestFrontMatterDefaults < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "A site with full front matter defaults (glob)" do |   context "A site with full front matter defaults (glob)" do | ||||||
|     setup do |     setup do | ||||||
|       @site = fixture_site({ |       @site = fixture_site( | ||||||
|         "defaults" => [{ |         "defaults" => [{ | ||||||
|           "scope"  => { |           "scope"  => { | ||||||
|             "path" => "contacts/*.html", |             "path" => "contacts/*.html", | ||||||
|  | @ -42,8 +42,8 @@ class TestFrontMatterDefaults < JekyllUnitTest | ||||||
|           "values" => { |           "values" => { | ||||||
|             "key" => "val", |             "key" => "val", | ||||||
|           }, |           }, | ||||||
|         },], |         },] | ||||||
|       }) |       ) | ||||||
|       @output = capture_output { @site.process } |       @output = capture_output { @site.process } | ||||||
|       @affected = @site.pages.find { |page| page.relative_path == "contacts/bar.html" } |       @affected = @site.pages.find { |page| page.relative_path == "contacts/bar.html" } | ||||||
|       @not_affected = @site.pages.find { |page| page.relative_path == "about.html" } |       @not_affected = @site.pages.find { |page| page.relative_path == "about.html" } | ||||||
|  | @ -61,7 +61,7 @@ class TestFrontMatterDefaults < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "A site with front matter type pages and an extension" do |   context "A site with front matter type pages and an extension" do | ||||||
|     setup do |     setup do | ||||||
|       @site = fixture_site({ |       @site = fixture_site( | ||||||
|         "defaults" => [{ |         "defaults" => [{ | ||||||
|           "scope"  => { |           "scope"  => { | ||||||
|             "path" => "index.html", |             "path" => "index.html", | ||||||
|  | @ -69,8 +69,8 @@ class TestFrontMatterDefaults < JekyllUnitTest | ||||||
|           "values" => { |           "values" => { | ||||||
|             "key" => "val", |             "key" => "val", | ||||||
|           }, |           }, | ||||||
|         },], |         },] | ||||||
|       }) |       ) | ||||||
| 
 | 
 | ||||||
|       @site.process |       @site.process | ||||||
|       @affected = @site.pages.find { |page| page.relative_path == "index.html" } |       @affected = @site.pages.find { |page| page.relative_path == "index.html" } | ||||||
|  | @ -85,7 +85,7 @@ class TestFrontMatterDefaults < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "A site with front matter defaults with no type" do |   context "A site with front matter defaults with no type" do | ||||||
|     setup do |     setup do | ||||||
|       @site = fixture_site({ |       @site = fixture_site( | ||||||
|         "defaults" => [{ |         "defaults" => [{ | ||||||
|           "scope"  => { |           "scope"  => { | ||||||
|             "path" => "win", |             "path" => "win", | ||||||
|  | @ -93,8 +93,8 @@ class TestFrontMatterDefaults < JekyllUnitTest | ||||||
|           "values" => { |           "values" => { | ||||||
|             "key" => "val", |             "key" => "val", | ||||||
|           }, |           }, | ||||||
|         },], |         },] | ||||||
|       }) |       ) | ||||||
| 
 | 
 | ||||||
|       @site.process |       @site.process | ||||||
|       @affected = @site.posts.docs.find { |page| page.relative_path =~ %r!win\/! } |       @affected = @site.posts.docs.find { |page| page.relative_path =~ %r!win\/! } | ||||||
|  | @ -109,7 +109,7 @@ class TestFrontMatterDefaults < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "A site with front matter defaults with no path and a deprecated type" do |   context "A site with front matter defaults with no path and a deprecated type" do | ||||||
|     setup do |     setup do | ||||||
|       @site = fixture_site({ |       @site = fixture_site( | ||||||
|         "defaults" => [{ |         "defaults" => [{ | ||||||
|           "scope"  => { |           "scope"  => { | ||||||
|             "type" => "page", |             "type" => "page", | ||||||
|  | @ -117,8 +117,8 @@ class TestFrontMatterDefaults < JekyllUnitTest | ||||||
|           "values" => { |           "values" => { | ||||||
|             "key" => "val", |             "key" => "val", | ||||||
|           }, |           }, | ||||||
|         },], |         },] | ||||||
|       }) |       ) | ||||||
| 
 | 
 | ||||||
|       @site.process |       @site.process | ||||||
|       @affected = @site.pages |       @affected = @site.pages | ||||||
|  | @ -134,7 +134,7 @@ class TestFrontMatterDefaults < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "A site with front matter defaults with no path" do |   context "A site with front matter defaults with no path" do | ||||||
|     setup do |     setup do | ||||||
|       @site = fixture_site({ |       @site = fixture_site( | ||||||
|         "defaults" => [{ |         "defaults" => [{ | ||||||
|           "scope"  => { |           "scope"  => { | ||||||
|             "type" => "pages", |             "type" => "pages", | ||||||
|  | @ -142,8 +142,8 @@ class TestFrontMatterDefaults < JekyllUnitTest | ||||||
|           "values" => { |           "values" => { | ||||||
|             "key" => "val", |             "key" => "val", | ||||||
|           }, |           }, | ||||||
|         },], |         },] | ||||||
|       }) |       ) | ||||||
|       @site.process |       @site.process | ||||||
|       @affected = @site.pages |       @affected = @site.pages | ||||||
|       @not_affected = @site.posts.docs |       @not_affected = @site.posts.docs | ||||||
|  | @ -158,15 +158,15 @@ class TestFrontMatterDefaults < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "A site with front matter defaults with no path or type" do |   context "A site with front matter defaults with no path or type" do | ||||||
|     setup do |     setup do | ||||||
|       @site = fixture_site({ |       @site = fixture_site( | ||||||
|         "defaults" => [{ |         "defaults" => [{ | ||||||
|           "scope"  => { |           "scope"  => { | ||||||
|           }, |           }, | ||||||
|           "values" => { |           "values" => { | ||||||
|             "key" => "val", |             "key" => "val", | ||||||
|           }, |           }, | ||||||
|         },], |         },] | ||||||
|       }) |       ) | ||||||
|       @site.process |       @site.process | ||||||
|       @affected = @site.pages |       @affected = @site.pages | ||||||
|       @not_affected = @site.posts |       @not_affected = @site.posts | ||||||
|  | @ -180,13 +180,13 @@ class TestFrontMatterDefaults < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "A site with front matter defaults with no scope" do |   context "A site with front matter defaults with no scope" do | ||||||
|     setup do |     setup do | ||||||
|       @site = fixture_site({ |       @site = fixture_site( | ||||||
|         "defaults" => [{ |         "defaults" => [{ | ||||||
|           "values" => { |           "values" => { | ||||||
|             "key" => "val", |             "key" => "val", | ||||||
|           }, |           }, | ||||||
|         },], |         },] | ||||||
|       }) |       ) | ||||||
|       @site.process |       @site.process | ||||||
|       @affected = @site.pages |       @affected = @site.pages | ||||||
|       @not_affected = @site.posts |       @not_affected = @site.posts | ||||||
|  | @ -200,15 +200,15 @@ class TestFrontMatterDefaults < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "A site with front matter defaults with quoted date" do |   context "A site with front matter defaults with quoted date" do | ||||||
|     setup do |     setup do | ||||||
|       @site = Site.new(Jekyll.configuration({ |       @site = Site.new(Jekyll.configuration( | ||||||
|         "source"      => source_dir, |                          "source"      => source_dir, | ||||||
|         "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 | ||||||
| 
 | 
 | ||||||
|     should "not raise error" do |     should "not raise error" do | ||||||
|  |  | ||||||
|  | @ -70,12 +70,12 @@ class TestGeneratedSite < JekyllUnitTest | ||||||
|       time_regexp = "\\d+:\\d+" |       time_regexp = "\\d+:\\d+" | ||||||
|       # |       # | ||||||
|       # adding a pipe character at the beginning preserves formatting with newlines |       # adding a pipe character at the beginning preserves formatting with newlines | ||||||
|       expected_output = Regexp.new <<-OUTPUT |       expected_output = Regexp.new <<~OUTPUT | ||||||
| | - /css/screen.css last edited at #{time_regexp} with extname .css |         | - /css/screen.css last edited at #{time_regexp} with extname .css | ||||||
|   - /pgp.key last edited at #{time_regexp} with extname .key |           - /pgp.key last edited at #{time_regexp} with extname .key | ||||||
|   - /products.yml last edited at #{time_regexp} with extname .yml |           - /products.yml last edited at #{time_regexp} with extname .yml | ||||||
|   - /symlink-test/symlinked-dir/screen.css last edited at #{time_regexp} with extname .css |           - /symlink-test/symlinked-dir/screen.css last edited at #{time_regexp} with extname .css | ||||||
| OUTPUT |       OUTPUT | ||||||
|       assert_match expected_output, File.read(dest_dir("static_files.html")) |       assert_match expected_output, File.read(dest_dir("static_files.html")) | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
|  |  | ||||||
|  | @ -40,18 +40,18 @@ class TestKramdown < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|       @kramdown_config_keys.each do |key| |       @kramdown_config_keys.each do |key| | ||||||
|         assert kramdown_config.key?(key.to_sym), |         assert kramdown_config.key?(key.to_sym), | ||||||
|           "Expected #{kramdown_config} to include key #{key.to_sym.inspect}" |                "Expected #{kramdown_config} to include key #{key.to_sym.inspect}" | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       @syntax_highlighter_opts_config_keys.each do |key| |       @syntax_highlighter_opts_config_keys.each do |key| | ||||||
|         assert kramdown_config["syntax_highlighter_opts"].key?(key.to_sym), |         assert kramdown_config["syntax_highlighter_opts"].key?(key.to_sym), | ||||||
|           "Expected #{kramdown_config["syntax_highlighter_opts"]} to include " \ |                "Expected #{kramdown_config["syntax_highlighter_opts"]} to include " \ | ||||||
|           "key #{key.to_sym.inspect}" |                "key #{key.to_sym.inspect}" | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       assert_equal kramdown_config["smart_quotes"], kramdown_config[:smart_quotes] |       assert_equal kramdown_config["smart_quotes"], kramdown_config[:smart_quotes] | ||||||
|       assert_equal kramdown_config["syntax_highlighter_opts"]["css"], |       assert_equal kramdown_config["syntax_highlighter_opts"]["css"], | ||||||
|         kramdown_config[:syntax_highlighter_opts][:css] |                    kramdown_config[:syntax_highlighter_opts][:css] | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "run Kramdown" do |     should "run Kramdown" do | ||||||
|  | @ -82,7 +82,7 @@ class TestKramdown < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|         markdown = Converters::Markdown.new(Utils.deep_merge_hashes(@config, override)) |         markdown = Converters::Markdown.new(Utils.deep_merge_hashes(@config, override)) | ||||||
|         assert_match %r!<p>(«|«)Pit(›|›)hy(»|»)<\/p>!, \ |         assert_match %r!<p>(«|«)Pit(›|›)hy(»|»)<\/p>!, \ | ||||||
|           markdown.convert(%("Pit'hy")).strip |                      markdown.convert(%("Pit'hy")).strip | ||||||
|       end |       end | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|  | @ -142,16 +142,17 @@ class TestKramdown < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|     should "move coderay to syntax_highlighter_opts" do |     should "move coderay to syntax_highlighter_opts" do | ||||||
|       original = Kramdown::Document.method(:new) |       original = Kramdown::Document.method(:new) | ||||||
|       markdown = Converters::Markdown.new(Utils.deep_merge_hashes(@config, { |       markdown = Converters::Markdown.new( | ||||||
|         "higlighter" => nil, |         Utils.deep_merge_hashes(@config, | ||||||
|         "markdown"   => "kramdown", |                                 "higlighter" => nil, | ||||||
|         "kramdown"   => { |                                 "markdown"   => "kramdown", | ||||||
|           "syntax_highlighter" => "coderay", |                                 "kramdown"   => { | ||||||
|           "coderay"            => { |                                   "syntax_highlighter" => "coderay", | ||||||
|             "hello" => "world", |                                   "coderay"            => { | ||||||
|           }, |                                     "hello" => "world", | ||||||
|         }, |                                   }, | ||||||
|       })) |                                 }) | ||||||
|  |       ) | ||||||
| 
 | 
 | ||||||
|       expect(Kramdown::Document).to receive(:new) do |arg1, hash| |       expect(Kramdown::Document).to receive(:new) do |arg1, hash| | ||||||
|         assert_equal hash["syntax_highlighter_opts"]["hello"], "world" |         assert_equal hash["syntax_highlighter_opts"]["hello"], "world" | ||||||
|  |  | ||||||
|  | @ -5,8 +5,8 @@ require "helper" | ||||||
| class TestLayoutReader < JekyllUnitTest | 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 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -22,11 +22,11 @@ class TestLiquidExtensions < JekyllUnitTest | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "extract the var properly" do |     should "extract the var properly" do | ||||||
|       assert_equal @template.render({ "page" => { "name" => "tobi" } }), "hi tobi" |       assert_equal @template.render("page" => { "name" => "tobi" }), "hi tobi" | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "return the variable name if the value isn't there" do |     should "return the variable name if the value isn't there" do | ||||||
|       assert_equal @template.render({ "page" => { "title" => "tobi" } }), "hi page.name" |       assert_equal @template.render("page" => { "title" => "tobi" }), "hi page.name" | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| end | end | ||||||
|  |  | ||||||
|  | @ -22,11 +22,11 @@ class TestPage < JekyllUnitTest | ||||||
|   context "A Page" do |   context "A Page" do | ||||||
|     setup do |     setup do | ||||||
|       clear_dest |       clear_dest | ||||||
|       @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 | ||||||
| 
 | 
 | ||||||
|     context "processing pages" do |     context "processing pages" do | ||||||
|  |  | ||||||
|  | @ -21,11 +21,11 @@ class TestPageWithoutAFile < JekyllUnitTest | ||||||
|   context "A PageWithoutAFile" do |   context "A PageWithoutAFile" do | ||||||
|     setup do |     setup do | ||||||
|       clear_dest |       clear_dest | ||||||
|       @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 | ||||||
| 
 | 
 | ||||||
|     context "with default site configuration" do |     context "with default site configuration" do | ||||||
|  |  | ||||||
|  | @ -24,7 +24,7 @@ class TestPluginManager < JekyllUnitTest | ||||||
|     should "not require from bundler" do |     should "not require from bundler" do | ||||||
|       with_env("JEKYLL_NO_BUNDLER_REQUIRE", "true") do |       with_env("JEKYLL_NO_BUNDLER_REQUIRE", "true") do | ||||||
|         refute Jekyll::PluginManager.require_from_bundler, |         refute Jekyll::PluginManager.require_from_bundler, | ||||||
|                      "Gemfile plugins were required but shouldn't have been" |                "Gemfile plugins were required but shouldn't have been" | ||||||
|         assert ENV["JEKYLL_NO_BUNDLER_REQUIRE"] |         assert ENV["JEKYLL_NO_BUNDLER_REQUIRE"] | ||||||
|       end |       end | ||||||
|     end |     end | ||||||
|  | @ -35,7 +35,7 @@ class TestPluginManager < JekyllUnitTest | ||||||
|       with_env("JEKYLL_NO_BUNDLER_REQUIRE", nil) do |       with_env("JEKYLL_NO_BUNDLER_REQUIRE", nil) do | ||||||
|         with_no_gemfile do |         with_no_gemfile do | ||||||
|           refute Jekyll::PluginManager.require_from_bundler, |           refute Jekyll::PluginManager.require_from_bundler, | ||||||
|                        "Gemfile plugins were required but shouldn't have been" |                  "Gemfile plugins were required but shouldn't have been" | ||||||
|           assert_nil ENV["JEKYLL_NO_BUNDLER_REQUIRE"] |           assert_nil ENV["JEKYLL_NO_BUNDLER_REQUIRE"] | ||||||
|         end |         end | ||||||
|       end |       end | ||||||
|  | @ -68,9 +68,9 @@ class TestPluginManager < JekyllUnitTest | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     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) | ||||||
|  | @ -80,7 +80,7 @@ class TestPluginManager < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "site is marked as safe" do |   context "site is marked as safe" do | ||||||
|     should "allow plugins if they are whitelisted" do |     should "allow plugins if they are whitelisted" do | ||||||
|       site = double({ :safe => true, :config => { "whitelist" => ["jemoji"] } }) |       site = double(:safe => true, :config => { "whitelist" => ["jemoji"] }) | ||||||
|       plugin_manager = PluginManager.new(site) |       plugin_manager = PluginManager.new(site) | ||||||
| 
 | 
 | ||||||
|       assert plugin_manager.plugin_allowed?("jemoji") |       assert plugin_manager.plugin_allowed?("jemoji") | ||||||
|  | @ -88,7 +88,7 @@ class TestPluginManager < JekyllUnitTest | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "not require plugin files" do |     should "not require plugin files" do | ||||||
|       site = double({ :safe => true }) |       site = double(:safe => true) | ||||||
|       plugin_manager = PluginManager.new(site) |       plugin_manager = PluginManager.new(site) | ||||||
| 
 | 
 | ||||||
|       expect(Jekyll::External).to_not receive(:require_with_graceful_fail) |       expect(Jekyll::External).to_not receive(:require_with_graceful_fail) | ||||||
|  | @ -98,12 +98,12 @@ class TestPluginManager < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "plugins_dir is set to the default" do |   context "plugins_dir is set to the default" do | ||||||
|     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) | ||||||
| 
 | 
 | ||||||
|       expect(site).to receive(:in_source_dir).with("_plugins") |       expect(site).to receive(:in_source_dir).with("_plugins") | ||||||
|  | @ -113,7 +113,7 @@ class TestPluginManager < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "plugins_dir is set to a different dir" do |   context "plugins_dir is set to a different dir" do | ||||||
|     should "expand plugin path" do |     should "expand plugin path" do | ||||||
|       site = double({ :config => { "plugins_dir" => "some_other_plugins_path" } }) |       site = double(:config => { "plugins_dir" => "some_other_plugins_path" }) | ||||||
|       plugin_manager = PluginManager.new(site) |       plugin_manager = PluginManager.new(site) | ||||||
| 
 | 
 | ||||||
|       expect(File).to receive(:expand_path).with("some_other_plugins_path") |       expect(File).to receive(:expand_path).with("some_other_plugins_path") | ||||||
|  | @ -123,7 +123,7 @@ class TestPluginManager < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "`paginate` config is activated" do |   context "`paginate` config is activated" do | ||||||
|     should "print deprecation warning if jekyll-paginate is not present" do |     should "print deprecation warning if jekyll-paginate is not present" do | ||||||
|       site = double({ :config => { "paginate" => true } }) |       site = double(:config => { "paginate" => true }) | ||||||
|       plugin_manager = PluginManager.new(site) |       plugin_manager = PluginManager.new(site) | ||||||
| 
 | 
 | ||||||
|       expect(Jekyll::Deprecator).to( |       expect(Jekyll::Deprecator).to( | ||||||
|  | @ -133,9 +133,9 @@ class TestPluginManager < JekyllUnitTest | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     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, "plugins" => ["jekyll-paginate"] }, |         :config => { "paginate" => true, "plugins" => ["jekyll-paginate"] } | ||||||
|       }) |       ) | ||||||
|       plugin_manager = PluginManager.new(site) |       plugin_manager = PluginManager.new(site) | ||||||
| 
 | 
 | ||||||
|       expect(Jekyll::Deprecator).to_not receive(:deprecation_message) |       expect(Jekyll::Deprecator).to_not receive(:deprecation_message) | ||||||
|  | @ -144,10 +144,10 @@ class TestPluginManager < JekyllUnitTest | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   should "conscientious require" do |   should "conscientious require" do | ||||||
|     site = double({ |     site = double( | ||||||
|       :config      => { "theme" => "test-dependency-theme" }, |       :config      => { "theme" => "test-dependency-theme" }, | ||||||
|       :in_dest_dir => "/tmp/_site/", |       :in_dest_dir => "/tmp/_site/" | ||||||
|     }) |     ) | ||||||
|     plugin_manager = PluginManager.new(site) |     plugin_manager = PluginManager.new(site) | ||||||
| 
 | 
 | ||||||
|     expect(site).to receive(:theme).and_return(true) |     expect(site).to receive(:theme).and_return(true) | ||||||
|  |  | ||||||
|  | @ -7,14 +7,14 @@ 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( | ||||||
|         "collections" => { |         "collections" => { | ||||||
|           "methods" => { |           "methods" => { | ||||||
|             "output" => true, |             "output" => true, | ||||||
|           }, |           }, | ||||||
|         }, |         }, | ||||||
|         "incremental" => true, |         "incremental" => true | ||||||
|       }) |       ) | ||||||
| 
 | 
 | ||||||
|       @site.read |       @site.read | ||||||
|       @page = @site.pages.first |       @page = @site.pages.first | ||||||
|  | @ -93,9 +93,9 @@ class TestRegenerator < JekyllUnitTest | ||||||
|   context "The site regenerator" do |   context "The site regenerator" do | ||||||
|     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 | ||||||
|       @post = @site.posts.first |       @post = @site.posts.first | ||||||
|  | @ -128,11 +128,11 @@ class TestRegenerator < JekyllUnitTest | ||||||
|     setup do |     setup do | ||||||
|       FileUtils.rm_rf(source_dir(".jekyll-metadata")) |       FileUtils.rm_rf(source_dir(".jekyll-metadata")) | ||||||
| 
 | 
 | ||||||
|       @site = Site.new(Jekyll.configuration({ |       @site = Site.new(Jekyll.configuration( | ||||||
|         "source"      => source_dir, |                          "source"      => source_dir, | ||||||
|         "destination" => dest_dir, |                          "destination" => dest_dir, | ||||||
|         "incremental" => true, |                          "incremental" => true | ||||||
|       })) |                        )) | ||||||
| 
 | 
 | ||||||
|       @site.process |       @site.process | ||||||
|       @path = @site.in_source_dir(@site.pages.first.path) |       @path = @site.in_source_dir(@site.pages.first.path) | ||||||
|  | @ -183,7 +183,7 @@ class TestRegenerator < JekyllUnitTest | ||||||
|     should "not crash when reading corrupted marshal file" do |     should "not crash when reading corrupted marshal file" do | ||||||
|       metadata_file = source_dir(".jekyll-metadata") |       metadata_file = source_dir(".jekyll-metadata") | ||||||
|       File.open(metadata_file, "w") do |file| |       File.open(metadata_file, "w") do |file| | ||||||
|         file.puts Marshal.dump({ :foo => "bar" })[0, 5] |         file.puts Marshal.dump(:foo => "bar")[0, 5] | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       @regenerator = Regenerator.new(@site) |       @regenerator = Regenerator.new(@site) | ||||||
|  | @ -310,11 +310,11 @@ class TestRegenerator < JekyllUnitTest | ||||||
|   context "when incremental regeneration is disabled" do |   context "when incremental regeneration is disabled" do | ||||||
|     setup do |     setup do | ||||||
|       FileUtils.rm_rf(source_dir(".jekyll-metadata")) |       FileUtils.rm_rf(source_dir(".jekyll-metadata")) | ||||||
|       @site = Site.new(Jekyll.configuration({ |       @site = Site.new(Jekyll.configuration( | ||||||
|         "source"      => source_dir, |                          "source"      => source_dir, | ||||||
|         "destination" => dest_dir, |                          "destination" => dest_dir, | ||||||
|         "incremental" => false, |                          "incremental" => false | ||||||
|       })) |                        )) | ||||||
| 
 | 
 | ||||||
|       @site.process |       @site.process | ||||||
|       @path = @site.in_source_dir(@site.pages.first.path) |       @path = @site.in_source_dir(@site.pages.first.path) | ||||||
|  |  | ||||||
|  | @ -29,9 +29,9 @@ class TestRelatedPosts < JekyllUnitTest | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       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 | ||||||
|       @site.read |       @site.read | ||||||
|  |  | ||||||
|  | @ -5,10 +5,10 @@ require "helper" | ||||||
| class TestSass < JekyllUnitTest | class TestSass < JekyllUnitTest | ||||||
|   context "importing partials" do |   context "importing partials" do | ||||||
|     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") | ||||||
|     end |     end | ||||||
|  |  | ||||||
|  | @ -15,7 +15,7 @@ class TestSite < JekyllUnitTest | ||||||
|     @site.posts.docs.concat(PostReader.new(@site).read_posts("")) |     @site.posts.docs.concat(PostReader.new(@site).read_posts("")) | ||||||
|     posts = Dir[source_dir("_posts", "**", "*")] |     posts = Dir[source_dir("_posts", "**", "*")] | ||||||
|     posts.delete_if do |post| |     posts.delete_if do |post| | ||||||
|       File.directory?(post) && !(post =~ Document::DATE_FILENAME_MATCHER) |       File.directory?(post) && post !~ Document::DATE_FILENAME_MATCHER | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|  | @ -31,15 +31,15 @@ class TestSite < JekyllUnitTest | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "have an array for plugins if passed as a string" do |     should "have an array for plugins if passed as a string" do | ||||||
|       site = Site.new(site_configuration({ "plugins_dir" => "/tmp/plugins" })) |       site = Site.new(site_configuration("plugins_dir" => "/tmp/plugins")) | ||||||
|       array = Utils::Platforms.windows? ? ["C:/tmp/plugins"] : ["/tmp/plugins"] |       array = Utils::Platforms.windows? ? ["C:/tmp/plugins"] : ["/tmp/plugins"] | ||||||
|       assert_equal array, site.plugins |       assert_equal array, site.plugins | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "have an array for plugins if passed as an array" do |     should "have an array for plugins if passed as an array" do | ||||||
|       site = Site.new(site_configuration({ |       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"] | ||||||
|               else |               else | ||||||
|  | @ -49,12 +49,12 @@ class TestSite < JekyllUnitTest | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "have an empty array for plugins if nothing is passed" do |     should "have an empty array for plugins if nothing is passed" do | ||||||
|       site = Site.new(site_configuration({ "plugins_dir" => [] })) |       site = Site.new(site_configuration("plugins_dir" => [])) | ||||||
|       assert_equal [], site.plugins |       assert_equal [], site.plugins | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "have the default for plugins if nil is passed" do |     should "have the default for plugins if nil is passed" do | ||||||
|       site = Site.new(site_configuration({ "plugins_dir" => nil })) |       site = Site.new(site_configuration("plugins_dir" => nil)) | ||||||
|       assert_equal [source_dir("_plugins")], site.plugins |       assert_equal [source_dir("_plugins")], site.plugins | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|  | @ -64,19 +64,19 @@ class TestSite < JekyllUnitTest | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "expose baseurl passed in from config" do |     should "expose baseurl passed in from config" do | ||||||
|       site = Site.new(site_configuration({ "baseurl" => "/blog" })) |       site = Site.new(site_configuration("baseurl" => "/blog")) | ||||||
|       assert_equal "/blog", site.baseurl |       assert_equal "/blog", site.baseurl | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "only include theme includes_path if the path exists" do |     should "only include theme includes_path if the path exists" do | ||||||
|       site = fixture_site({ "theme" => "test-theme" }) |       site = fixture_site("theme" => "test-theme") | ||||||
|       assert_equal [source_dir("_includes"), theme_dir("_includes")], |       assert_equal [source_dir("_includes"), theme_dir("_includes")], | ||||||
|         site.includes_load_paths |                    site.includes_load_paths | ||||||
| 
 | 
 | ||||||
|       allow(File).to receive(:directory?).with(theme_dir("_sass")).and_return(true) |       allow(File).to receive(:directory?).with(theme_dir("_sass")).and_return(true) | ||||||
|       allow(File).to receive(:directory?).with(theme_dir("_layouts")).and_return(true) |       allow(File).to receive(:directory?).with(theme_dir("_layouts")).and_return(true) | ||||||
|       allow(File).to receive(:directory?).with(theme_dir("_includes")).and_return(false) |       allow(File).to receive(:directory?).with(theme_dir("_includes")).and_return(false) | ||||||
|       site = fixture_site({ "theme" => "test-theme" }) |       site = fixture_site("theme" => "test-theme") | ||||||
|       assert_equal [source_dir("_includes")], site.includes_load_paths |       assert_equal [source_dir("_includes")], site.includes_load_paths | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
|  | @ -87,9 +87,7 @@ class TestSite < JekyllUnitTest | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     teardown do |     teardown do | ||||||
|       if defined?(MyGenerator) |       self.class.send(:remove_const, :MyGenerator) if defined?(MyGenerator) | ||||||
|         self.class.send(:remove_const, :MyGenerator) |  | ||||||
|       end |  | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "have an empty tag hash by default" do |     should "have an empty tag hash by default" do | ||||||
|  | @ -279,7 +277,7 @@ class TestSite < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|       posts = Dir[source_dir("**", "_posts", "**", "*")] |       posts = Dir[source_dir("**", "_posts", "**", "*")] | ||||||
|       posts.delete_if do |post| |       posts.delete_if do |post| | ||||||
|         File.directory?(post) && !(post =~ Document::DATE_FILENAME_MATCHER) |         File.directory?(post) && post !~ Document::DATE_FILENAME_MATCHER | ||||||
|       end |       end | ||||||
|       categories = %w( |       categories = %w( | ||||||
|         2013 bar baz category foo z_category MixedCase Mixedcase publish_test win |         2013 bar baz category foo z_category MixedCase Mixedcase publish_test win | ||||||
|  | @ -305,9 +303,9 @@ class TestSite < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|       should "raise for bad frontmatter if strict_front_matter is set" do |       should "raise for bad frontmatter if strict_front_matter is set" do | ||||||
|         site = Site.new(site_configuration( |         site = Site.new(site_configuration( | ||||||
|           "collections"         => ["broken"], |                           "collections"         => ["broken"], | ||||||
|           "strict_front_matter" => true |                           "strict_front_matter" => true | ||||||
|         )) |                         )) | ||||||
|         assert_raises(Psych::SyntaxError) do |         assert_raises(Psych::SyntaxError) do | ||||||
|           site.process |           site.process | ||||||
|         end |         end | ||||||
|  | @ -315,9 +313,9 @@ class TestSite < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|       should "not raise for bad frontmatter if strict_front_matter is not set" do |       should "not raise for bad frontmatter if strict_front_matter is not set" do | ||||||
|         site = Site.new(site_configuration( |         site = Site.new(site_configuration( | ||||||
|           "collections"         => ["broken"], |                           "collections"         => ["broken"], | ||||||
|           "strict_front_matter" => false |                           "strict_front_matter" => false | ||||||
|         )) |                         )) | ||||||
|         site.process |         site.process | ||||||
|       end |       end | ||||||
|     end |     end | ||||||
|  | @ -412,9 +410,9 @@ class TestSite < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|         bad_processor = "Custom::Markdown" |         bad_processor = "Custom::Markdown" | ||||||
|         s = Site.new(site_configuration( |         s = Site.new(site_configuration( | ||||||
|           "markdown"    => bad_processor, |                        "markdown"    => bad_processor, | ||||||
|           "incremental" => false |                        "incremental" => false | ||||||
|         )) |                      )) | ||||||
|         assert_raises Jekyll::Errors::FatalException do |         assert_raises Jekyll::Errors::FatalException do | ||||||
|           s.process |           s.process | ||||||
|         end |         end | ||||||
|  | @ -433,9 +431,9 @@ class TestSite < JekyllUnitTest | ||||||
|       should "throw FatalException at process time" do |       should "throw FatalException at process time" do | ||||||
|         bad_processor = "not a processor name" |         bad_processor = "not a processor name" | ||||||
|         s = Site.new(site_configuration( |         s = Site.new(site_configuration( | ||||||
|           "markdown"    => bad_processor, |                        "markdown"    => bad_processor, | ||||||
|           "incremental" => false |                        "incremental" => false | ||||||
|         )) |                      )) | ||||||
|         assert_raises Jekyll::Errors::FatalException do |         assert_raises Jekyll::Errors::FatalException do | ||||||
|           s.process |           s.process | ||||||
|         end |         end | ||||||
|  | @ -489,8 +487,8 @@ class TestSite < JekyllUnitTest | ||||||
|         site.process |         site.process | ||||||
| 
 | 
 | ||||||
|         file_content = SafeYAML.load_file(File.join( |         file_content = SafeYAML.load_file(File.join( | ||||||
|           source_dir, "_data", "categories", "dairy.yaml" |                                             source_dir, "_data", "categories", "dairy.yaml" | ||||||
|         )) |                                           )) | ||||||
| 
 | 
 | ||||||
|         assert_equal site.data["categories"]["dairy"], file_content |         assert_equal site.data["categories"]["dairy"], file_content | ||||||
|         assert_equal( |         assert_equal( | ||||||
|  | @ -504,8 +502,8 @@ class TestSite < JekyllUnitTest | ||||||
|         site.process |         site.process | ||||||
| 
 | 
 | ||||||
|         file_content = SafeYAML.load_file(File.join( |         file_content = SafeYAML.load_file(File.join( | ||||||
|           source_dir, "_data", "categories.01", "dairy.yaml" |                                             source_dir, "_data", "categories.01", "dairy.yaml" | ||||||
|         )) |                                           )) | ||||||
| 
 | 
 | ||||||
|         assert_equal site.data["categories01"]["dairy"], file_content |         assert_equal site.data["categories01"]["dairy"], file_content | ||||||
|         assert_equal( |         assert_equal( | ||||||
|  | @ -536,9 +534,9 @@ 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" } | ||||||
|       end |       end | ||||||
|  | @ -550,9 +548,9 @@ class TestSite < JekyllUnitTest | ||||||
|       context "in production" do |       context "in production" do | ||||||
|         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" } | ||||||
|         end |         end | ||||||
|  | @ -571,13 +569,13 @@ class TestSite < JekyllUnitTest | ||||||
|       should "set no theme if config is not set" do |       should "set no theme if config is not set" do | ||||||
|         expect($stderr).not_to receive(:puts) |         expect($stderr).not_to receive(:puts) | ||||||
|         expect($stdout).not_to receive(:puts) |         expect($stdout).not_to receive(:puts) | ||||||
|         site = fixture_site({ "theme" => nil }) |         site = fixture_site("theme" => nil) | ||||||
|         assert_nil site.theme |         assert_nil site.theme | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       should "set no theme if config is a hash" do |       should "set no theme if config is a hash" do | ||||||
|         output = capture_output do |         output = capture_output do | ||||||
|           site = fixture_site({ "theme" => {} }) |           site = fixture_site("theme" => {}) | ||||||
|           assert_nil site.theme |           assert_nil site.theme | ||||||
|         end |         end | ||||||
|         expected_msg = "Theme: value of 'theme' in config should be String " \ |         expected_msg = "Theme: value of 'theme' in config should be String " \ | ||||||
|  | @ -589,7 +587,7 @@ class TestSite < JekyllUnitTest | ||||||
|         [:debug, :info, :warn, :error].each do |level| |         [:debug, :info, :warn, :error].each do |level| | ||||||
|           expect(Jekyll.logger.writer).not_to receive(level) |           expect(Jekyll.logger.writer).not_to receive(level) | ||||||
|         end |         end | ||||||
|         site = fixture_site({ "theme" => "test-theme" }) |         site = fixture_site("theme" => "test-theme") | ||||||
|         assert_instance_of Jekyll::Theme, site.theme |         assert_instance_of Jekyll::Theme, site.theme | ||||||
|         assert_equal "test-theme", site.theme.name |         assert_equal "test-theme", site.theme.name | ||||||
|       end |       end | ||||||
|  | @ -616,9 +614,9 @@ 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 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -5,9 +5,9 @@ require "helper" | ||||||
| class TestSiteDrop < JekyllUnitTest | class TestSiteDrop < JekyllUnitTest | ||||||
|   context "a site drop" do |   context "a site drop" do | ||||||
|     setup do |     setup do | ||||||
|       @site = fixture_site({ |       @site = fixture_site( | ||||||
|         "collections" => ["thanksgiving"], |         "collections" => ["thanksgiving"] | ||||||
|       }) |       ) | ||||||
|       @site.process |       @site.process | ||||||
|       @drop = @site.to_liquid.site |       @drop = @site.to_liquid.site | ||||||
|     end |     end | ||||||
|  |  | ||||||
|  | @ -70,7 +70,7 @@ class TestStaticFile < JekyllUnitTest | ||||||
|         "root", |         "root", | ||||||
|         "_foo/dir/subdir", |         "_foo/dir/subdir", | ||||||
|         "file.html", |         "file.html", | ||||||
|         { "output" => true } |         "output" => true | ||||||
|       ) |       ) | ||||||
|       assert_equal :foo, static_file.type |       assert_equal :foo, static_file.type | ||||||
|       assert_equal "/foo/dir/subdir/file.html", static_file.url |       assert_equal "/foo/dir/subdir/file.html", static_file.url | ||||||
|  | @ -82,7 +82,7 @@ class TestStaticFile < JekyllUnitTest | ||||||
|         "root", |         "root", | ||||||
|         "_foo/dir/subdir", |         "_foo/dir/subdir", | ||||||
|         "file.html", |         "file.html", | ||||||
|         { "output" => true, "permalink" => "/:path/" } |         "output" => true, "permalink" => "/:path/" | ||||||
|       ) |       ) | ||||||
|       assert_equal :foo, static_file.type |       assert_equal :foo, static_file.type | ||||||
|       assert_equal "/dir/subdir/file.html", static_file.url |       assert_equal "/dir/subdir/file.html", static_file.url | ||||||
|  | @ -92,7 +92,7 @@ class TestStaticFile < JekyllUnitTest | ||||||
|     should "be writable by default" do |     should "be writable by default" do | ||||||
|       static_file = setup_static_file("root", "dir/subdir", "file.html") |       static_file = setup_static_file("root", "dir/subdir", "file.html") | ||||||
|       assert(static_file.write?, |       assert(static_file.write?, | ||||||
|         "static_file.write? should return true by default") |              "static_file.write? should return true by default") | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "use the _config.yml defaults to determine writability" do |     should "use the _config.yml defaults to determine writability" do | ||||||
|  | @ -107,8 +107,8 @@ class TestStaticFile < JekyllUnitTest | ||||||
|         defaults |         defaults | ||||||
|       ) |       ) | ||||||
|       assert(!static_file.write?, |       assert(!static_file.write?, | ||||||
|         "static_file.write? should return false when _config.yml sets " \ |              "static_file.write? should return false when _config.yml sets " \ | ||||||
|         "`published: false`") |              "`published: false`") | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "respect front matter defaults" do |     should "respect front matter defaults" do | ||||||
|  |  | ||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							|  | @ -202,20 +202,20 @@ class TestUtils < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|     should "replace everything else but ASCII characters" do |     should "replace everything else but ASCII characters" do | ||||||
|       assert_equal "the-config-yml-file", |       assert_equal "the-config-yml-file", | ||||||
|         Utils.slugify("The _config.yml file?", :mode => "ascii") |                    Utils.slugify("The _config.yml file?", :mode => "ascii") | ||||||
|       assert_equal "f-rtive-glance", |       assert_equal "f-rtive-glance", | ||||||
|         Utils.slugify("fürtive glance!!!!", :mode => "ascii") |                    Utils.slugify("fürtive glance!!!!", :mode => "ascii") | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "map accented latin characters to ASCII characters" do |     should "map accented latin characters to ASCII characters" do | ||||||
|       assert_equal "the-config-yml-file", |       assert_equal "the-config-yml-file", | ||||||
|         Utils.slugify("The _config.yml file?", :mode => "latin") |                    Utils.slugify("The _config.yml file?", :mode => "latin") | ||||||
|       assert_equal "furtive-glance", |       assert_equal "furtive-glance", | ||||||
|         Utils.slugify("fürtive glance!!!!", :mode => "latin") |                    Utils.slugify("fürtive glance!!!!", :mode => "latin") | ||||||
|       assert_equal "aaceeiioouu", |       assert_equal "aaceeiioouu", | ||||||
|         Utils.slugify("àáçèéíïòóúü", :mode => "latin") |                    Utils.slugify("àáçèéíïòóúü", :mode => "latin") | ||||||
|       assert_equal "a-z", |       assert_equal "a-z", | ||||||
|         Utils.slugify("Aあわれ鬱господинZ", :mode => "latin") |                    Utils.slugify("Aあわれ鬱господинZ", :mode => "latin") | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "only replace whitespace if mode is raw" do |     should "only replace whitespace if mode is raw" do | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue