diff --git a/.rubocop.yml b/.rubocop.yml index 583e86bd..b06c9624 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -39,17 +39,6 @@ AllCops: - features/step_definitions.rb - features/support/formatter.rb - features/support/helpers.rb - - test/test_configuration.rb - - test/test_document.rb - - test/test_entry_filter.rb - - test/test_filters.rb - - test/test_kramdown.rb - - test/test_liquid_renderer.rb - - test/test_page.rb - - test/test_regenerator.rb - - test/test_site.rb - - test/test_tags.rb - - test/test_utils.rb - bin/**/* - benchmark/**/* - script/**/* @@ -66,6 +55,7 @@ Metrics/ClassLength: Max: 240 Exclude: - !ruby/regexp /features\/.*.rb$/ + - !ruby/regexp /test\/.*.rb$/ Metrics/CyclomaticComplexity: Max: 8 Metrics/LineLength: diff --git a/test/test_configuration.rb b/test/test_configuration.rb index 08cc3bd9..eddb2c96 100644 --- a/test/test_configuration.rb +++ b/test/test_configuration.rb @@ -1,8 +1,8 @@ -require 'helper' +require "helper" class TestConfiguration < JekyllUnitTest - @@test_config = { - "source" => new(nil).source_dir, + test_config = { + "source" => new(nil).source_dir, "destination" => dest_dir } @@ -12,48 +12,77 @@ class TestConfiguration < JekyllUnitTest end should "merge input over defaults" do - result = Configuration.from({"source" => "blah"}) + result = Configuration.from({ "source" => "blah" }) refute_equal result["source"], Configuration::DEFAULTS["source"] assert_equal result["source"], "blah" end should "fix common mistakes" do - result = Configuration.from({"paginate" => 0}) - assert_nil result["paginate"], "Expected 'paginate' to be corrected to 'nil', but was #{result["paginate"].inspect}" + result = Configuration.from({ "paginate" => 0 }) + assert_nil( + result["paginate"], + "Expected 'paginate' to be corrected to 'nil', " \ + "but was #{result["paginate"].inspect}" + ) end should "add default collections" do result = Configuration.from({}) - assert_equal result["collections"], {"posts" => {"output" => true, "permalink" => "/:categories/:year/:month/:day/:title:output_ext"}} + assert_equal( + result["collections"], + { + "posts" => { + "output" => true, + "permalink" => "/:categories/:year/:month/:day/:title:output_ext" + } + } + ) end should "NOT backwards-compatibilize" do - assert Configuration.from("watch" => true)["watch"], "Expected the 'watch' key to not be removed." + assert( + Configuration.from("watch" => true)["watch"], + "Expected the 'watch' key to not be removed." + ) end end context "#add_default_collections" do should "no-op if collections is nil" do - result = Configuration[{"collections" => nil}].add_default_collections + result = Configuration[{ "collections" => nil }].add_default_collections assert_nil result["collections"] end should "turn an array into a hash" do - result = Configuration[{"collections" => %w{methods}}].add_default_collections + result = Configuration[{ "collections" => %w(methods) }].add_default_collections assert_instance_of Hash, result["collections"] - assert_equal result["collections"], {"posts" => {"output" => true}, "methods" => {}} + assert_equal( + result["collections"], + { "posts" => { "output" => true }, "methods" => {} } + ) end should "only assign collections.posts.permalink if a permalink is specified" do - result = Configuration[{"permalink" => "pretty", "collections" => {}}].add_default_collections - assert_equal result["collections"], {"posts" => {"output" => true, "permalink" => "/:categories/:year/:month/:day/:title/"}} + result = Configuration[{ "permalink" => "pretty", "collections" => {} }] + .add_default_collections + assert_equal( + result["collections"], + { + "posts" => { + "output" => true, + "permalink" => "/:categories/:year/:month/:day/:title/" + } + } + ) - result = Configuration[{"permalink" => nil, "collections" => {}}].add_default_collections - assert_equal result["collections"], {"posts" => {"output" => true}} + result = Configuration[{ "permalink" => nil, "collections" => {} }] + .add_default_collections + assert_equal result["collections"], { "posts" => { "output" => true } } end should "forces posts to output" do - result = Configuration[{"collections" => {"posts" => {"output" => false}}}].add_default_collections + result = Configuration[{ "collections" => { "posts" => { "output" => false } } }] + .add_default_collections assert_equal result["collections"]["posts"]["output"], true end end @@ -61,18 +90,18 @@ class TestConfiguration < JekyllUnitTest context "#stringify_keys" do setup do @mixed_keys = Configuration[{ - 'markdown' => 'kramdown', - :permalink => 'date', - 'baseurl' => '/', - :include => ['.htaccess'], - :source => './' + "markdown" => "kramdown", + :permalink => "date", + "baseurl" => "/", + :include => [".htaccess"], + :source => "./" }] @string_keys = Configuration[{ - 'markdown' => 'kramdown', - 'permalink' => 'date', - 'baseurl' => '/', - 'include' => ['.htaccess'], - 'source' => './' + "markdown" => "kramdown", + "permalink" => "date", + "baseurl" => "/", + "include" => [".htaccess"], + "source" => "./" }] end should "stringify symbol keys" do @@ -84,10 +113,12 @@ class TestConfiguration < JekyllUnitTest end context "#config_files" do setup do - @config = Configuration[{"source" => source_dir}] + @config = Configuration[{ "source" => source_dir }] @no_override = {} - @one_config_file = {"config" => "config.yml"} - @multiple_files = {"config" => %w[config/site.yml config/deploy.toml configuration.yml]} + @one_config_file = { "config" => "config.yml" } + @multiple_files = { + "config" => %w(config/site.yml config/deploy.toml configuration.yml) + } end should "always return an array" do @@ -108,52 +139,58 @@ class TestConfiguration < JekyllUnitTest assert_equal [source_dir("_config.yml")], @config.config_files(@no_override) end should "return the config if given one config file" do - assert_equal %w[config.yml], @config.config_files(@one_config_file) + assert_equal %w(config.yml), @config.config_files(@one_config_file) end should "return an array of the config files if given many config files" do - assert_equal %w[config/site.yml config/deploy.toml configuration.yml], @config.config_files(@multiple_files) + assert_equal( + %w(config/site.yml config/deploy.toml configuration.yml), + @config.config_files(@multiple_files) + ) end end context "#read_config_file" do setup do - @config = Configuration[{"source" => source_dir('empty.yml')}] + @config = Configuration[{ "source" => source_dir("empty.yml") }] end should "not raise an error on empty files" do - allow(SafeYAML).to receive(:load_file).with('empty.yml').and_return(false) + allow(SafeYAML).to receive(:load_file).with("empty.yml").and_return(false) Jekyll.logger.log_level = :warn - @config.read_config_file('empty.yml') + @config.read_config_file("empty.yml") Jekyll.logger.log_level = :info end end context "#read_config_files" do setup do - @config = Configuration[{"source" => source_dir}] + @config = Configuration[{ "source" => source_dir }] end should "continue to read config files if one is empty" do - allow(SafeYAML).to receive(:load_file).with('empty.yml').and_return(false) - allow(SafeYAML).to receive(:load_file).with('not_empty.yml').and_return({'foo' => 'bar', 'include' => '', 'exclude' => ''}) + allow(SafeYAML).to receive(:load_file).with("empty.yml").and_return(false) + allow(SafeYAML) + .to receive(:load_file) + .with("not_empty.yml") + .and_return({ "foo" => "bar", "include" => "", "exclude" => "" }) 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 - assert_equal 'bar', read_config['foo'] + assert_equal "bar", read_config["foo"] end end context "#backwards_compatibilize" do setup do @config = Configuration[{ - "auto" => true, - "watch" => true, - "server" => true, - "exclude" => "READ-ME.md, Gemfile,CONTRIBUTING.hello.markdown", - "include" => "STOP_THE_PRESSES.txt,.heloses, .git", - "pygments" => true, - "plugins" => true, - "layouts" => true, - "data_source" => true, + "auto" => true, + "watch" => true, + "server" => true, + "exclude" => "READ-ME.md, Gemfile,CONTRIBUTING.hello.markdown", + "include" => "STOP_THE_PRESSES.txt,.heloses, .git", + "pygments" => true, + "plugins" => true, + "layouts" => true, + "data_source" => true }] end should "unset 'auto' and 'watch'" do @@ -169,12 +206,18 @@ class TestConfiguration < JekyllUnitTest should "transform string exclude into an array" do assert @config.key?("exclude") assert @config.backwards_compatibilize.key?("exclude") - assert_equal @config.backwards_compatibilize["exclude"], %w[READ-ME.md Gemfile CONTRIBUTING.hello.markdown] + assert_equal( + @config.backwards_compatibilize["exclude"], + %w(READ-ME.md Gemfile CONTRIBUTING.hello.markdown) + ) end should "transform string include into an array" do assert @config.key?("include") assert @config.backwards_compatibilize.key?("include") - assert_equal @config.backwards_compatibilize["include"], %w[STOP_THE_PRESSES.txt .heloses .git] + assert_equal( + @config.backwards_compatibilize["include"], + %w(STOP_THE_PRESSES.txt .heloses .git) + ) end should "set highlighter to pygments" do assert @config.key?("pygments") @@ -195,62 +238,79 @@ class TestConfiguration < JekyllUnitTest end context "#fix_common_issues" do setup do - @config = Proc.new do |val| + @config = proc do |val| Configuration[{ - 'paginate' => val + "paginate" => val }] end end should "sets an invalid 'paginate' value to nil" do - assert_nil @config.call(0).fix_common_issues['paginate'] - assert_nil @config.call(-1).fix_common_issues['paginate'] - assert_nil @config.call(true).fix_common_issues['paginate'] + assert_nil @config.call(0).fix_common_issues["paginate"] + assert_nil @config.call(-1).fix_common_issues["paginate"] + assert_nil @config.call(true).fix_common_issues["paginate"] end end context "loading configuration" do setup do - @path = source_dir('_config.yml') + @path = source_dir("_config.yml") @user_config = File.join(Dir.pwd, "my_config_file.yml") end should "fire warning with no _config.yml" do - allow(SafeYAML).to receive(:load_file).with(@path) { raise SystemCallError, "No such file or directory - #{@path}" } + allow(SafeYAML).to receive(:load_file).with(@path) do + raise SystemCallError, "No such file or directory - #{@path}" + end allow($stderr).to receive(:puts).with("Configuration file: none".yellow) - assert_equal site_configuration, Jekyll.configuration(@@test_config) + assert_equal site_configuration, Jekyll.configuration(test_config) end should "load configuration as hash" do - allow(SafeYAML).to receive(:load_file).with(@path).and_return(Hash.new) + allow(SafeYAML).to receive(:load_file).with(@path).and_return({}) allow($stdout).to receive(:puts).with("Configuration file: #{@path}") - assert_equal site_configuration, Jekyll.configuration(@@test_config) + assert_equal site_configuration, Jekyll.configuration(test_config) end should "fire warning with bad config" do - allow(SafeYAML).to receive(:load_file).with(@path).and_return(Array.new) - allow($stderr).to receive(:puts).and_return(("WARNING: ".rjust(20) + "Error reading configuration. Using defaults (and options).").yellow) - allow($stderr).to receive(:puts).and_return("Configuration file: (INVALID) #{@path}".yellow) - assert_equal site_configuration, Jekyll.configuration(@@test_config) + allow(SafeYAML).to receive(:load_file).with(@path).and_return([]) + allow($stderr) + .to receive(:puts) + .and_return( + ("WARNING: " + .rjust(20) + "Error reading configuration. Using defaults (and options).") + .yellow + ) + allow($stderr) + .to receive(:puts) + .and_return("Configuration file: (INVALID) #{@path}".yellow) + assert_equal site_configuration, Jekyll.configuration(test_config) end should "fire warning when user-specified config file isn't there" do - allow(SafeYAML).to receive(:load_file).with(@user_config) { raise SystemCallError, "No such file or directory - #{@user_config}" } - allow($stderr).to receive(:puts).with(("Fatal: ".rjust(20) + "The configuration file '#{@user_config}' could not be found.").red) + allow(SafeYAML).to receive(:load_file).with(@user_config) do + raise SystemCallError, "No such file or directory - #{@user_config}" + end + allow($stderr) + .to receive(:puts) + .with(( + "Fatal: ".rjust(20) + \ + "The configuration file '#{@user_config}' could not be found." + ).red) assert_raises LoadError do - Jekyll.configuration({'config' => [@user_config]}) + Jekyll.configuration({ "config" => [@user_config] }) end end should "not clobber YAML.load to the dismay of other libraries" do - assert_equal :foo, YAML.load(':foo') + assert_equal :foo, YAML.load(":foo") # as opposed to: assert_equal ':foo', SafeYAML.load(':foo') end end context "loading config from external file" do setup do @paths = { - :default => source_dir('_config.yml'), - :other => source_dir('_config.live.yml'), - :toml => source_dir('_config.dev.toml'), + :default => source_dir("_config.yml"), + :other => source_dir("_config.live.yml"), + :toml => source_dir("_config.dev.toml"), :empty => "" } end @@ -258,16 +318,19 @@ class TestConfiguration < JekyllUnitTest should "load default plus posts config if no config_file is set" do allow(SafeYAML).to receive(:load_file).with(@paths[:default]).and_return({}) allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:default]}") - assert_equal site_configuration, Jekyll.configuration(@@test_config) + assert_equal site_configuration, Jekyll.configuration(test_config) end should "load different config if specified" do - allow(SafeYAML).to receive(:load_file).with(@paths[:other]).and_return({"baseurl" => "http://wahoo.dev"}) + allow(SafeYAML) + .to receive(:load_file) + .with(@paths[:other]) + .and_return({ "baseurl" => "http://wahoo.dev" }) allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:other]}") Jekyll.configuration({ "config" => @paths[:other] }) assert_equal \ site_configuration({ "baseurl" => "http://wahoo.dev" }), - Jekyll.configuration(@@test_config.merge({ "config" => @paths[:other] })) + Jekyll.configuration(test_config.merge({ "config" => @paths[:other] })) end should "load default config if path passed is empty" do @@ -275,68 +338,94 @@ class TestConfiguration < JekyllUnitTest allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:default]}") assert_equal \ site_configuration, - Jekyll.configuration(@@test_config.merge({ "config" => [@paths[:empty]] })) + Jekyll.configuration(test_config.merge({ "config" => [@paths[:empty]] })) end should "successfully load a TOML file" do Jekyll.logger.log_level = :warn assert_equal \ - site_configuration({ "baseurl" => "/you-beautiful-blog-you", "title" => "My magnificent site, wut" }), - Jekyll.configuration(@@test_config.merge({ "config" => [@paths[:toml]] })) + site_configuration({ "baseurl" => "/you-beautiful-blog-you", + "title" => "My magnificent site, wut" }), + Jekyll.configuration(test_config.merge({ "config" => [@paths[:toml]] })) Jekyll.logger.log_level = :info end should "load multiple config files" do - External.require_with_graceful_fail('toml') + External.require_with_graceful_fail("toml") - allow(SafeYAML).to receive(:load_file).with(@paths[:default]).and_return(Hash.new) - allow(SafeYAML).to receive(:load_file).with(@paths[:other]).and_return(Hash.new) - allow(TOML).to receive(:load_file).with(@paths[:toml]).and_return(Hash.new) + allow(SafeYAML).to receive(:load_file).with(@paths[:default]).and_return({}) + allow(SafeYAML).to receive(:load_file).with(@paths[:other]).and_return({}) + allow(TOML).to receive(:load_file).with(@paths[:toml]).and_return({}) allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:default]}") allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:other]}") allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:toml]}") - assert_equal \ + assert_equal( site_configuration, - Jekyll.configuration(@@test_config.merge({ "config" => [@paths[:default], @paths[:other], @paths[:toml]] })) + Jekyll.configuration( + test_config.merge( + { "config" => [@paths[:default], @paths[:other], @paths[:toml]] } + ) + ) + ) end should "load multiple config files and last config should win" do - allow(SafeYAML).to receive(:load_file).with(@paths[:default]).and_return({"baseurl" => "http://example.dev"}) - allow(SafeYAML).to receive(:load_file).with(@paths[:other]).and_return({"baseurl" => "http://wahoo.dev"}) - allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:default]}") - allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:other]}") + allow(SafeYAML) + .to receive(:load_file) + .with(@paths[:default]) + .and_return({ "baseurl" => "http://example.dev" }) + allow(SafeYAML) + .to receive(:load_file) + .with(@paths[:other]) + .and_return({ "baseurl" => "http://wahoo.dev" }) + allow($stdout) + .to receive(:puts) + .with("Configuration file: #{@paths[:default]}") + allow($stdout) + .to receive(:puts) + .with("Configuration file: #{@paths[:other]}") assert_equal \ site_configuration({ "baseurl" => "http://wahoo.dev" }), - Jekyll.configuration(@@test_config.merge({ "config" => [@paths[:default], @paths[:other]] })) + Jekyll.configuration( + test_config.merge({ "config" => [@paths[:default], @paths[:other]] }) + ) end end context "#add_default_collections" do should "not do anything if collections is nil" do - conf = Configuration[default_configuration].tap {|c| c['collections'] = nil } + conf = Configuration[default_configuration].tap { |c| c["collections"] = nil } assert_equal conf.add_default_collections, conf - assert_nil conf.add_default_collections['collections'] + assert_nil conf.add_default_collections["collections"] end should "converts collections to a hash if an array" do - conf = Configuration[default_configuration].tap {|c| c['collections'] = ['docs'] } + conf = Configuration[default_configuration].tap do |c| + c["collections"] = ["docs"] + end assert_equal conf.add_default_collections, conf.merge({ "collections" => { - "docs" => {}, + "docs" => {}, "posts" => { - "output" => true, + "output" => true, "permalink" => "/:categories/:year/:month/:day/:title:output_ext" - }}}) + } + } + }) end should "force collections.posts.output = true" do - conf = Configuration[default_configuration].tap {|c| c['collections'] = {'posts' => {'output' => false}} } + conf = Configuration[default_configuration].tap do |c| + c["collections"] = { "posts" => { "output" => false } } + end assert_equal conf.add_default_collections, conf.merge({ "collections" => { "posts" => { - "output" => true, + "output" => true, "permalink" => "/:categories/:year/:month/:day/:title:output_ext" - }}}) + } + } + }) end should "set collections.posts.permalink if it's not set" do @@ -344,24 +433,28 @@ class TestConfiguration < JekyllUnitTest assert_equal conf.add_default_collections, conf.merge({ "collections" => { "posts" => { - "output" => true, + "output" => true, "permalink" => "/:categories/:year/:month/:day/:title:output_ext" - }}}) + } + } + }) end should "leave collections.posts.permalink alone if it is set" do posts_permalink = "/:year/:title/" conf = Configuration[default_configuration].tap do |c| - c['collections'] = { + c["collections"] = { "posts" => { "permalink" => posts_permalink } } end assert_equal conf.add_default_collections, conf.merge({ "collections" => { "posts" => { - "output" => true, + "output" => true, "permalink" => posts_permalink - }}}) + } + } + }) end end end diff --git a/test/test_document.rb b/test/test_document.rb index fb503dcc..808ef2e7 100644 --- a/test/test_document.rb +++ b/test/test_document.rb @@ -1,7 +1,6 @@ -require 'helper' +require "helper" class TestDocument < JekyllUnitTest - def assert_equal_value(key, one, other) assert_equal(one[key], other[key]) end @@ -12,7 +11,9 @@ class TestDocument < JekyllUnitTest "collections" => ["methods"] }) @site.process - @document = @site.collections["methods"].docs.detect {|d| d.relative_path == "_methods/configuration.md" } + @document = @site.collections["methods"].docs.detect do |d| + d.relative_path == "_methods/configuration.md" + end end should "exist" do @@ -86,11 +87,12 @@ class TestDocument < JekyllUnitTest end context "with YAML ending in three dots" do - setup do - @site = fixture_site({"collections" => ["methods"]}) + @site = fixture_site({ "collections" => ["methods"] }) @site.process - @document = @site.collections["methods"].docs.detect {|d| d.relative_path == "_methods/yaml_with_dots.md" } + @document = @site.collections["methods"].docs.detect do |d| + d.relative_path == "_methods/yaml_with_dots.md" + end end should "know its data" do @@ -100,36 +102,35 @@ class TestDocument < JekyllUnitTest end should "output the collection name in the #to_liquid method" do - assert_equal @document.to_liquid['collection'], "methods" + assert_equal @document.to_liquid["collection"], "methods" end should "output its relative path as path in Liquid" do - assert_equal @document.to_liquid['path'], "_methods/configuration.md" + assert_equal @document.to_liquid["path"], "_methods/configuration.md" end - end context "a document as part of a collection with frontmatter defaults" do setup do @site = fixture_site({ "collections" => ["slides"], - "defaults" => [{ - "scope"=> {"path"=>"", "type"=>"slides"}, - "values"=> { - "nested"=> { - "key"=>"myval", + "defaults" => [{ + "scope" => { "path"=>"", "type"=>"slides" }, + "values" => { + "nested" => { + "key" => "myval" } } }] }) @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 should "know the frontmatter defaults" do assert_equal "Example slide", @document.data["title"] assert_equal "slide", @document.data["layout"] - assert_equal({"key"=>"myval"}, @document.data["nested"]) + assert_equal({ "key"=>"myval" }, @document.data["nested"]) end end @@ -137,12 +138,12 @@ class TestDocument < JekyllUnitTest setup do @site = fixture_site({ "collections" => ["slides"], - "defaults" => [{ - "scope"=> {"path"=>"", "type"=>"slides"}, - "values"=> { - "nested"=> { - "test1"=>"default1", - "test2"=>"default1" + "defaults" => [{ + "scope" => { "path"=>"", "type"=>"slides" }, + "values" => { + "nested" => { + "test1" => "default1", + "test2" => "default1" } } }] @@ -154,7 +155,10 @@ class TestDocument < JekyllUnitTest should "override default values in the document frontmatter" do assert_equal "Override title", @document.data["title"] assert_equal "slide", @document.data["layout"] - assert_equal({"test1"=>"override1","test2"=>"override2"}, @document.data["nested"]) + assert_equal( + { "test1"=>"override1", "test2"=>"override2" }, + @document.data["nested"] + ) end end @@ -162,11 +166,11 @@ class TestDocument < JekyllUnitTest setup do @site = fixture_site({ "collections" => ["slides"], - "defaults" => [{ - "scope"=> {"path"=>"_slides", "type"=>"slides"}, - "values"=> { - "nested"=> { - "key"=>"value123", + "defaults" => [{ + "scope" => { "path"=>"_slides", "type"=>"slides" }, + "values" => { + "nested" => { + "key" => "value123" } } }] @@ -178,7 +182,7 @@ class TestDocument < JekyllUnitTest should "know the frontmatter defaults" do assert_equal "Example slide", @document.data["title"] assert_equal "slide", @document.data["layout"] - assert_equal({"key"=>"value123"}, @document.data["nested"]) + assert_equal({ "key"=>"value123" }, @document.data["nested"]) end end @@ -186,11 +190,11 @@ class TestDocument < JekyllUnitTest setup do @site = fixture_site({ "collections" => ["slides"], - "defaults" => [{ - "scope"=> {"path"=>"somepath", "type"=>"slides"}, - "values"=> { - "nested"=> { - "key"=>"myval", + "defaults" => [{ + "scope" => { "path"=>"somepath", "type"=>"slides" }, + "values" => { + "nested" => { + "key" => "myval" } } }] @@ -234,7 +238,7 @@ class TestDocument < JekyllUnitTest "permalink" => "/slides/test/:name" } }, - "permalink" => "pretty" + "permalink" => "pretty" }) @site.process @document = @site.collections["slides"].docs[0] @@ -259,9 +263,9 @@ class TestDocument < JekyllUnitTest @site = fixture_site({ "collections" => { "slides" => { - "output" => true, + "output" => true } - }, + } }) @site.permalink_style = :pretty @site.process @@ -283,9 +287,9 @@ class TestDocument < JekyllUnitTest @site = fixture_site({ "collections" => { "slides" => { - "output" => true, + "output" => true } - }, + } }) @site.permalink_style = :pretty @site.process @@ -337,7 +341,7 @@ class TestDocument < JekyllUnitTest "output" => true, "permalink" => "/slides/:title" } - }, + } }) @site.process @document = @site.collections["slides"].docs[3] @@ -363,7 +367,10 @@ class TestDocument < JekyllUnitTest end should "produce the right URL if they have a wild slug" do - assert_equal "/slides/Well,-so-what-is-Jekyll,-then", @document_with_strange_slug.url + assert_equal( + "/slides/Well,-so-what-is-Jekyll,-then", + @document_with_strange_slug.url + ) end should "produce the right destination file if they have a wild slug" do dest_file = dest_dir("/slides/Well,-so-what-is-Jekyll,-then.html") @@ -373,9 +380,9 @@ class TestDocument < JekyllUnitTest context "document with a permalink with dots & a trailing slash" do setup do - @site = fixture_site({"collections" => { + @site = fixture_site({ "collections" => { "with.dots" => { "output" => true } - }}) + } }) @site.process @document = @site.collections["with.dots"].docs.last @dest_file = dest_dir("with.dots", "permalink.with.slash.tho", "index.html") @@ -401,7 +408,7 @@ class TestDocument < JekyllUnitTest "slides" => { "output" => true } - }, + } }) @site.process @files = @site.collections["slides"].docs @@ -409,13 +416,17 @@ class TestDocument < JekyllUnitTest context "without output overrides" do should "be output according to collection defaults" do - refute_nil @files.find { |doc| doc.relative_path == "_slides/example-slide-4.html" } + refute_nil @files.find do |doc| + doc.relative_path == "_slides/example-slide-4.html" + end end end context "with output overrides" do should "be output according its front matter" do - assert_nil @files.find { |doc| doc.relative_path == "_slides/non-outputted-slide.html" } + assert_nil @files.find { |doc| + doc.relative_path == "_slides/non-outputted-slide.html" + } end end end @@ -430,7 +441,9 @@ class TestDocument < JekyllUnitTest } }) @site.process - @document = @site.collections["slides"].files.find { |doc| doc.relative_path == "_slides/octojekyll.png" } + @document = @site.collections["slides"].files.find do |doc| + doc.relative_path == "_slides/octojekyll.png" + end @dest_file = dest_dir("slides/octojekyll.png") end @@ -458,10 +471,12 @@ class TestDocument < JekyllUnitTest "methods" => { "output" => true } - }, + } }) @site.process - @document = @site.collections["methods"].docs.find { |doc| doc.relative_path == "_methods/escape-+ #%20[].md" } + @document = @site.collections["methods"].docs.find do |doc| + doc.relative_path == "_methods/escape-+ #%20[].md" + end @dest_file = dest_dir("methods/escape-+ #%20[].html") end @@ -476,7 +491,5 @@ class TestDocument < JekyllUnitTest should "be output in the correct place" do assert_equal true, File.file?(@dest_file) end - end - end diff --git a/test/test_entry_filter.rb b/test/test_entry_filter.rb index d9e38300..0b1d7134 100644 --- a/test/test_entry_filter.rb +++ b/test/test_entry_filter.rb @@ -1,4 +1,4 @@ -require 'helper' +require "helper" class TestEntryFilter < JekyllUnitTest context "Filtering entries" do @@ -7,16 +7,16 @@ class TestEntryFilter < JekyllUnitTest end should "filter entries" do - ent1 = %w[foo.markdown bar.markdown baz.markdown #baz.markdown# - .baz.markdow foo.markdown~ .htaccess _posts _pages ~$benbalter.docx] + ent1 = %w(foo.markdown bar.markdown baz.markdown #baz.markdown# + .baz.markdow foo.markdown~ .htaccess _posts _pages ~$benbalter.docx) 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 end should "allow regexp filtering" do files = %w(README.md) - @site.exclude = excludes = [ + @site.exclude = [ /README/ ] @@ -26,63 +26,69 @@ class TestEntryFilter < JekyllUnitTest end should "filter entries with exclude" do - excludes = %w[README TODO vendor/bundle] - files = %w[index.html site.css .htaccess vendor] + excludes = %w(README TODO vendor/bundle) + files = %w(index.html site.css .htaccess vendor) @site.exclude = excludes + ["exclude*"] assert_equal files, @site.reader.filter_entries(excludes + files + ["excludeA"]) end should "filter entries with exclude relative to site source" do - excludes = %w[README TODO css] - files = %w[index.html vendor/css .htaccess] + excludes = %w(README TODO css) + files = %w(index.html vendor/css .htaccess) @site.exclude = excludes assert_equal files, @site.reader.filter_entries(excludes + files + ["css"]) end should "filter excluded directory and contained files" do - excludes = %w[README TODO css] - files = %w[index.html .htaccess] + excludes = %w(README TODO css) + files = %w(index.html .htaccess) @site.exclude = excludes - assert_equal files, @site.reader.filter_entries(excludes + files + ["css", "css/main.css", "css/vendor.css"]) + assert_equal( + files, + @site.reader.filter_entries( + excludes + files + ["css", "css/main.css", "css/vendor.css"] + ) + ) end should "not filter entries within include" do - includes = %w[_index.html .htaccess include*] - files = %w[index.html _index.html .htaccess includeA] + includes = %w(_index.html .htaccess include*) + files = %w(index.html _index.html .htaccess includeA) @site.include = includes assert_equal files, @site.reader.filter_entries(files) end should "keep safe symlink entries when safe mode enabled" do - site = Site.new(site_configuration('safe' => true)) - allow(File).to receive(:symlink?).with('symlink.js').and_return(true) - files = %w[symlink.js] + allow(File).to receive(:symlink?).with("symlink.js").and_return(true) + files = %w(symlink.js) assert_equal files, @site.reader.filter_entries(files) end should "not filter symlink entries when safe mode disabled" do - allow(File).to receive(:symlink?).with('symlink.js').and_return(true) - files = %w[symlink.js] + allow(File).to receive(:symlink?).with("symlink.js").and_return(true) + files = %w(symlink.js) assert_equal files, @site.reader.filter_entries(files) end should "filter symlink pointing outside site source" do - ent1 = %w[_includes/tmp] + ent1 = %w(_includes/tmp) entries = EntryFilter.new(@site).filter(ent1) - assert_equal %w[], entries + assert_equal %w(), entries end + # rubocop:disable Performance/FixedSize should "include only safe symlinks in safe mode" do - site = Site.new(site_configuration('safe' => true)) - + site = Site.new(site_configuration("safe" => true)) site.reader.read_directories("symlink-test") - assert_equal %w[main.scss symlinked-file].length, site.pages.length + + assert_equal %w(main.scss symlinked-file).length, site.pages.length refute_equal [], site.static_files end + # rubocop:enable Performance/FixedSize should "include symlinks in unsafe mode" do site = Site.new(site_configuration) @@ -118,9 +124,9 @@ class TestEntryFilter < JekyllUnitTest end should "match even if there is no leading slash" do - data = ['vendor/bundle'] - assert @filter.glob_include?(data, '/vendor/bundle') - assert @filter.glob_include?(data, 'vendor/bundle') + data = ["vendor/bundle"] + assert @filter.glob_include?(data, "/vendor/bundle") + assert @filter.glob_include?(data, "vendor/bundle") end end end diff --git a/test/test_filters.rb b/test/test_filters.rb index eb8170fc..a2184c37 100644 --- a/test/test_filters.rb +++ b/test/test_filters.rb @@ -1,6 +1,6 @@ # coding: utf-8 -require 'helper' +require "helper" class TestFilters < JekyllUnitTest class JekyllFilter @@ -8,18 +8,24 @@ class TestFilters < JekyllUnitTest attr_accessor :site, :context def initialize(opts = {}) - @site = Jekyll::Site.new(Jekyll.configuration(opts.merge('skip_config_files' => true))) + @site = Jekyll::Site.new( + Jekyll.configuration(opts.merge("skip_config_files" => true)) + ) @context = Liquid::Context.new({}, {}, { :site => @site }) end end context "filters" do setup do - @filter = JekyllFilter.new({"source" => source_dir, "destination" => dest_dir, "timezone" => "UTC"}) + @filter = JekyllFilter.new({ + "source" => source_dir, + "destination" => dest_dir, + "timezone" => "UTC" + }) @sample_time = Time.utc(2013, 03, 27, 11, 22, 33) @sample_date = Date.parse("2013-03-27") @time_as_string = "September 11, 2001 12:46:30 -0000" - @time_as_numeric = 1399680607 + @time_as_numeric = 1_399_680_607 @array_of_objects = [ { "color" => "red", "size" => "large" }, { "color" => "red", "size" => "medium" }, @@ -28,18 +34,30 @@ class TestFilters < JekyllUnitTest end should "markdownify with simple string" do - assert_equal "
something really simple
\n", @filter.markdownify("something **really** simple") + assert_equal( + "something really simple
\n", + @filter.markdownify("something **really** simple") + ) end context "smartify filter" do should "convert quotes and typographic characters" do - assert_equal "SmartyPants is *not* Markdown", @filter.smartify("SmartyPants is *not* Markdown") - assert_equal "“This filter’s test…”", @filter.smartify(%q{"This filter's test..."}) + assert_equal( + "SmartyPants is *not* Markdown", + @filter.smartify("SmartyPants is *not* Markdown") + ) + assert_equal( + "“This filter’s test…”", + @filter.smartify(%q{"This filter's test..."}) + ) end should "escapes special characters when configured to do so" do - kramdown = JekyllFilter.new({:kramdown => {:entity_output => :symbolic}}) - assert_equal "“This filter’s test…”", kramdown.smartify(%q{"This filter's test..."}) + kramdown = JekyllFilter.new({ :kramdown => { :entity_output => :symbolic } }) + assert_equal( + "“This filter’s test…”", + kramdown.smartify(%q{"This filter's test..."}) + ) end should "convert HTML entities to unicode characters" do @@ -48,8 +66,14 @@ class TestFilters < JekyllUnitTest end should "allow raw HTML passthrough" do - assert_equal "Span HTML is not escaped", @filter.smartify("Span HTML is not escaped") - assert_equal "command <filename>
")
+ assert_equal(
+ "<code>command <filename></code>",
+ @filter.xml_escape("command <filename>
")
+ )
end
should "not error when xml escaping nil" do
@@ -190,37 +250,40 @@ class TestFilters < JekyllUnitTest
context "jsonify filter" do
should "convert hash to json" do
- assert_equal "{\"age\":18}", @filter.jsonify({:age => 18})
+ assert_equal "{\"age\":18}", @filter.jsonify({ :age => 18 })
end
should "convert array to json" do
assert_equal "[1,2]", @filter.jsonify([1, 2])
- assert_equal "[{\"name\":\"Jack\"},{\"name\":\"Smith\"}]", @filter.jsonify([{:name => 'Jack'}, {:name => 'Smith'}])
+ assert_equal(
+ "[{\"name\":\"Jack\"},{\"name\":\"Smith\"}]",
+ @filter.jsonify([{ :name => "Jack" }, { :name => "Smith" }])
+ )
end
should "convert drop to json" do
@filter.site.read
expected = {
- "path" => "_posts/2008-02-02-published.markdown",
- "previous" => nil,
- "output" => nil,
- "content" => "This should be published.\n",
- "id" => "/publish_test/2008/02/02/published",
- "url" => "/publish_test/2008/02/02/published.html",
+ "path" => "_posts/2008-02-02-published.markdown",
+ "previous" => nil,
+ "output" => nil,
+ "content" => "This should be published.\n",
+ "id" => "/publish_test/2008/02/02/published",
+ "url" => "/publish_test/2008/02/02/published.html",
"relative_path" => "_posts/2008-02-02-published.markdown",
- "collection" => "posts",
- "excerpt" => "This should be published.
\n", - "draft" => false, - "categories" => [ + "collection" => "posts", + "excerpt" => "This should be published.
\n", + "draft" => false, + "categories" => [ "publish_test" ], - "layout" => "default", - "title" => "Publish", - "category" => "publish_test", - "date" => "2008-02-02 00:00:00 +0000", - "slug" => "published", - "ext" => ".markdown", - "tags" => [] + "layout" => "default", + "title" => "Publish", + "category" => "publish_test", + "date" => "2008-02-02 00:00:00 +0000", + "slug" => "published", + "ext" => ".markdown", + "tags" => [] } actual = JSON.parse(@filter.jsonify(@filter.site.docs_to_write.first.to_liquid)) @@ -236,10 +299,11 @@ class TestFilters < JekyllUnitTest actual = @filter.jsonify(@filter.site.to_liquid) assert_equal JSON.parse(actual)["jekyll"], { "environment" => "development", - "version" => Jekyll::VERSION + "version" => Jekyll::VERSION } end + # rubocop:disable Style/StructInheritance class M < Struct.new(:message) def to_liquid [message] @@ -247,7 +311,12 @@ class TestFilters < JekyllUnitTest end class T < Struct.new(:name) def to_liquid - { "name" => name, :v => 1, :thing => M.new({:kay => "jewelers"}), :stuff => true } + { + "name" => name, + :v => 1, + :thing => M.new({ :kay => "jewelers" }), + :stuff => true + } end end @@ -277,6 +346,7 @@ class TestFilters < JekyllUnitTest result = @filter.jsonify([T.new("Jeremiah"), T.new("Smathers")]) assert_equal expected, JSON.parse(result) end + # rubocop:enable Style/StructInheritance should "handle hashes with all sorts of weird keys and values" do my_hash = { "posts" => Array.new(3) { |i| T.new(i) } } @@ -324,16 +394,28 @@ class TestFilters < JekyllUnitTest @filter.site.process grouping = @filter.group_by(@filter.site.pages, "layout") grouping.each do |g| - assert ["default", "nil", ""].include?(g["name"]), "#{g['name']} isn't a valid grouping." + assert( + ["default", "nil", ""].include?(g["name"]), + "#{g["name"]} isn't a valid grouping." + ) case g["name"] when "default" - assert g["items"].is_a?(Array), "The list of grouped items for 'default' is not an Array." + assert( + g["items"].is_a?(Array), + "The list of grouped items for 'default' is not an Array." + ) assert_equal 5, g["items"].size when "nil" - assert g["items"].is_a?(Array), "The list of grouped items for 'nil' is not an Array." + assert( + g["items"].is_a?(Array), + "The list of grouped items for 'nil' is not an Array." + ) assert_equal 2, g["items"].size when "" - assert g["items"].is_a?(Array), "The list of grouped items for '' is not an Array." + assert( + g["items"].is_a?(Array), + "The list of grouped items for '' is not an Array." + ) assert_equal 13, g["items"].size end end @@ -343,7 +425,11 @@ class TestFilters < JekyllUnitTest grouping = @filter.group_by(@filter.site.pages, "layout") grouping.each do |g| p g - assert_equal g["items"].size, g["size"], "The size property for '#{g["name"]}' doesn't match the size of the Array." + assert_equal( + g["items"].size, + g["size"], + "The size property for '#{g["name"]}' doesn't match the size of the Array." + ) end end end @@ -354,9 +440,9 @@ class TestFilters < JekyllUnitTest end should "filter objects in a hash appropriately" do - hash = {"a"=>{"color"=>"red"}, "b"=>{"color"=>"blue"}} + hash = { "a"=>{ "color"=>"red" }, "b"=>{ "color"=>"blue" } } assert_equal 1, @filter.where(hash, "color", "red").length - assert_equal [{"color"=>"red"}], @filter.where(hash, "color", "red") + assert_equal [{ "color"=>"red" }], @filter.where(hash, "color", "red") end should "filter objects appropriately" do @@ -364,25 +450,37 @@ class TestFilters < JekyllUnitTest end should "filter array properties appropriately" do - hash = {"a"=>{"tags"=>["x","y"]}, "b"=>{"tags"=>["x"]}, "c"=>{"tags"=>["y","z"]}} + hash = { + "a" => { "tags"=>%w(x y) }, + "b" => { "tags"=>["x"] }, + "c" => { "tags"=>%w(y z) } + } assert_equal 2, @filter.where(hash, "tags", "x").length end should "filter array properties alongside string properties" do - hash = {"a"=>{"tags"=>["x","y"]}, "b"=>{"tags"=>"x"}, "c"=>{"tags"=>["y","z"]}} + hash = { + "a" => { "tags"=>%w(x y) }, + "b" => { "tags"=>"x" }, + "c" => { "tags"=>%w(y z) } + } assert_equal 2, @filter.where(hash, "tags", "x").length end should "not match substrings" do - hash = {"a"=>{"category"=>"bear"}, "b"=>{"category"=>"wolf"}, "c"=>{"category"=>["bear","lion"]}} + hash = { + "a" => { "category"=>"bear" }, + "b" => { "category"=>"wolf" }, + "c" => { "category"=>%w(bear lion) } + } assert_equal 0, @filter.where(hash, "category", "ear").length end should "stringify during comparison for compatibility with liquid parsing" do hash = { - "The Words" => {"rating" => 1.2, "featured" => false}, - "Limitless" => {"rating" => 9.2, "featured" => true}, - "Hustle" => {"rating" => 4.7, "featured" => true}, + "The Words" => { "rating" => 1.2, "featured" => false }, + "Limitless" => { "rating" => 9.2, "featured" => true }, + "Hustle" => { "rating" => 4.7, "featured" => true } } results = @filter.where(hash, "featured", "true") @@ -402,20 +500,26 @@ class TestFilters < JekyllUnitTest end should "filter objects in a hash appropriately" do - hash = {"a"=>{"color"=>"red"}, "b"=>{"color"=>"blue"}} + hash = { "a"=>{ "color"=>"red" }, "b"=>{ "color"=>"blue" } } assert_equal 1, @filter.where_exp(hash, "item", "item.color == 'red'").length - assert_equal [{"color"=>"red"}], @filter.where_exp(hash, "item", "item.color == 'red'") + assert_equal( + [{ "color"=>"red" }], + @filter.where_exp(hash, "item", "item.color == 'red'") + ) end should "filter objects appropriately" do - assert_equal 2, @filter.where_exp(@array_of_objects, "item", "item.color == 'red'").length + assert_equal( + 2, + @filter.where_exp(@array_of_objects, "item", "item.color == 'red'").length + ) end should "stringify during comparison for compatibility with liquid parsing" do hash = { - "The Words" => {"rating" => 1.2, "featured" => false}, - "Limitless" => {"rating" => 9.2, "featured" => true}, - "Hustle" => {"rating" => 4.7, "featured" => true}, + "The Words" => { "rating" => 1.2, "featured" => false }, + "Limitless" => { "rating" => 9.2, "featured" => true }, + "Hustle" => { "rating" => 4.7, "featured" => true } } results = @filter.where_exp(hash, "item", "item.featured == true") @@ -465,28 +569,31 @@ class TestFilters < JekyllUnitTest assert_equal [1, 2, 2.2, 3], @filter.sort([3, 2.2, 2, 1]) end should "return sorted strings" do - assert_equal ["10", "2"], @filter.sort(["10", "2"]) - assert_equal [{"a" => "10"}, {"a" => "2"}], @filter.sort([{"a" => "10"}, {"a" => "2"}], "a") - assert_equal ["FOO", "Foo", "foo"], @filter.sort(["foo", "Foo", "FOO"]) - assert_equal ["_foo", "foo", "foo_"], @filter.sort(["foo_", "_foo", "foo"]) + assert_equal %w(10 2), @filter.sort(%w(10 2)) + assert_equal( + [{ "a" => "10" }, { "a" => "2" }], + @filter.sort([{ "a" => "10" }, { "a" => "2" }], "a") + ) + assert_equal %w(FOO Foo foo), @filter.sort(%w(foo Foo FOO)) + assert_equal %w(_foo foo foo_), @filter.sort(%w(foo_ _foo foo)) # Cyrillic - assert_equal ["ВУЗ", "Вуз", "вуз"], @filter.sort(["Вуз", "вуз", "ВУЗ"]) - assert_equal ["_вуз", "вуз", "вуз_"], @filter.sort(["вуз_", "_вуз", "вуз"]) + assert_equal %w(ВУЗ Вуз вуз), @filter.sort(%w(Вуз вуз ВУЗ)) + assert_equal %w(_вуз вуз вуз_), @filter.sort(%w(вуз_ _вуз вуз)) # Hebrew - assert_equal ["אלף", "בית"], @filter.sort(["בית", "אלף"]) + assert_equal %w(אלף בית), @filter.sort(%w(בית אלף)) end should "return sorted by property array" do - assert_equal [{"a" => 1}, {"a" => 2}, {"a" => 3}, {"a" => 4}], - @filter.sort([{"a" => 4}, {"a" => 3}, {"a" => 1}, {"a" => 2}], "a") + assert_equal [{ "a" => 1 }, { "a" => 2 }, { "a" => 3 }, { "a" => 4 }], + @filter.sort([{ "a" => 4 }, { "a" => 3 }, { "a" => 1 }, { "a" => 2 }], "a") end should "return sorted by property array with nils first" do - ary = [{"a" => 2}, {"b" => 1}, {"a" => 1}] - assert_equal [{"b" => 1}, {"a" => 1}, {"a" => 2}], @filter.sort(ary, "a") + ary = [{ "a" => 2 }, { "b" => 1 }, { "a" => 1 }] + assert_equal [{ "b" => 1 }, { "a" => 1 }, { "a" => 2 }], @filter.sort(ary, "a") assert_equal @filter.sort(ary, "a"), @filter.sort(ary, "a", "first") end should "return sorted by property array with nils last" do - assert_equal [{"a" => 1}, {"a" => 2}, {"b" => 1}], - @filter.sort([{"a" => 2}, {"b" => 1}, {"a" => 1}], "a", "last") + assert_equal [{ "a" => 1 }, { "a" => 2 }, { "b" => 1 }], + @filter.sort([{ "a" => 2 }, { "b" => 1 }, { "a" => 1 }], "a", "last") end end @@ -512,41 +619,41 @@ class TestFilters < JekyllUnitTest context "push filter" do should "return a new array with the element pushed to the end" do - assert_equal %w{hi there bernie}, @filter.push(%w{hi there}, "bernie") + assert_equal %w(hi there bernie), @filter.push(%w(hi there), "bernie") end end context "pop filter" do should "return a new array with the last element popped" do - assert_equal %w{hi there}, @filter.pop(%w{hi there bernie}) + assert_equal %w(hi there), @filter.pop(%w(hi there bernie)) end should "allow multiple els to be popped" do - assert_equal %w{hi there bert}, @filter.pop(%w{hi there bert and ernie}, 2) + assert_equal %w(hi there bert), @filter.pop(%w(hi there bert and ernie), 2) end should "cast string inputs for # into nums" do - assert_equal %w{hi there bert}, @filter.pop(%w{hi there bert and ernie}, "2") + assert_equal %w(hi there bert), @filter.pop(%w(hi there bert and ernie), "2") end end context "shift filter" do should "return a new array with the element removed from the front" do - assert_equal %w{a friendly greeting}, @filter.shift(%w{just a friendly greeting}) + assert_equal %w(a friendly greeting), @filter.shift(%w(just a friendly greeting)) end should "allow multiple els to be shifted" do - assert_equal %w{bert and ernie}, @filter.shift(%w{hi there bert and ernie}, 2) + assert_equal %w(bert and ernie), @filter.shift(%w(hi there bert and ernie), 2) end should "cast string inputs for # into nums" do - assert_equal %w{bert and ernie}, @filter.shift(%w{hi there bert and ernie}, "2") + assert_equal %w(bert and ernie), @filter.shift(%w(hi there bert and ernie), "2") end end context "unshift filter" do should "return a new array with the element put at the front" do - assert_equal %w{aloha there bernie}, @filter.unshift(%w{there bernie}, "aloha") + assert_equal %w(aloha there bernie), @filter.unshift(%w(there bernie), "aloha") end end @@ -563,6 +670,5 @@ class TestFilters < JekyllUnitTest end end end - end end diff --git a/test/test_kramdown.rb b/test/test_kramdown.rb index c9316936..e8d494ae 100644 --- a/test/test_kramdown.rb +++ b/test/test_kramdown.rb @@ -1,22 +1,22 @@ # encoding: UTF-8 -require 'helper' +require "helper" class TestKramdown < JekyllUnitTest context "kramdown" do setup do @config = { - 'markdown' => 'kramdown', - 'kramdown' => { - 'smart_quotes' => 'lsquo,rsquo,ldquo,rdquo', - 'entity_output' => 'as_char', - 'toc_levels' => '1..6', - 'auto_ids' => false, - 'footnote_nr' => 1, + "markdown" => "kramdown", + "kramdown" => { + "smart_quotes" => "lsquo,rsquo,ldquo,rdquo", + "entity_output" => "as_char", + "toc_levels" => "1..6", + "auto_ids" => false, + "footnote_nr" => 1, - 'syntax_highlighter' => 'rouge', - 'syntax_highlighter_opts' => { - 'bold_every' => 8, 'css' => :class + "syntax_highlighter" => "rouge", + "syntax_highlighter_opts" => { + "bold_every" => 8, "css" => :class } } } @@ -33,25 +33,28 @@ class TestKramdown < JekyllUnitTest context "when asked to convert smart quotes" do should "convert" do - assert_match %r!(“|“)Pit(’|’)hy(”|”)<\/p>!, @markdown.convert(%{"Pit'hy"}).strip + assert_match( + %r!
(“|“)Pit(’|’)hy(”|”)<\/p>!, + @markdown.convert(%("Pit'hy")).strip + ) end should "support custom types" do override = { "highlighter" => nil, - 'kramdown' => { - 'smart_quotes' => 'lsaquo,rsaquo,laquo,raquo' + "kramdown" => { + "smart_quotes" => "lsaquo,rsaquo,laquo,raquo" } } markdown = Converters::Markdown.new(Utils.deep_merge_hashes(@config, override)) assert_match %r!
(«|«)Pit(›|›)hy(»|»)<\/p>!, \
- markdown.convert(%{"Pit'hy"}).strip
+ markdown.convert(%("Pit'hy")).strip
end
end
should "render fenced code blocks with syntax highlighting" do
- result = nokogiri_fragment(@markdown.convert(Utils.strip_heredoc <<-MARKDOWN))
+ result = nokogiri_fragment(@markdown.convert(Utils.strip_heredoc(<<-MARKDOWN)))
~~~ruby
puts "Hello World"
~~~
@@ -65,14 +68,14 @@ class TestKramdown < JekyllUnitTest
should "use the chosen highlighter if it's available" do
override = {
"highlighter" => nil,
- "markdown" => "kramdown",
- "kramdown" => {
+ "markdown" => "kramdown",
+ "kramdown" => {
"syntax_highlighter" => :coderay
}
}
markdown = Converters::Markdown.new(Utils.deep_merge_hashes(@config, override))
- result = nokogiri_fragment(markdown.convert(Utils.strip_heredoc <<-MARKDOWN))
+ result = nokogiri_fragment(markdown.convert(Utils.strip_heredoc(<<-MARKDOWN)))
~~~ruby
puts "Hello World"
~~~
@@ -86,14 +89,14 @@ class TestKramdown < JekyllUnitTest
override = {
"markdown" => "kramdown",
"kramdown" => {
- "enable_coderay" => true,
+ "enable_coderay" => true
}
}
@config.delete("highlighter")
@config["kramdown"].delete("syntax_highlighter")
markdown = Converters::Markdown.new(Utils.deep_merge_hashes(@config, override))
- result = nokogiri_fragment(markdown.convert(Utils.strip_heredoc <<-MARKDOWN))
+ result = nokogiri_fragment(markdown.convert(Utils.strip_heredoc(<<-MARKDOWN)))
~~~ruby
puts "Hello World"
~~~
@@ -108,10 +111,10 @@ class TestKramdown < JekyllUnitTest
original = Kramdown::Document.method(:new)
markdown = Converters::Markdown.new(Utils.deep_merge_hashes(@config, {
"higlighter" => nil,
- "markdown" => "kramdown",
- "kramdown" => {
+ "markdown" => "kramdown",
+ "kramdown" => {
"syntax_highlighter" => "coderay",
- "coderay" => {
+ "coderay" => {
"hello" => "world"
}
}
diff --git a/test/test_liquid_renderer.rb b/test/test_liquid_renderer.rb
index d727fac0..f6ab34d2 100644
--- a/test/test_liquid_renderer.rb
+++ b/test/test_liquid_renderer.rb
@@ -1,4 +1,4 @@
-require 'helper'
+require "helper"
class TestLiquidRenderer < JekyllUnitTest
context "profiler" do
@@ -12,11 +12,13 @@ class TestLiquidRenderer < JekyllUnitTest
output = @renderer.stats_table
+ # rubocop:disable Metrics/LineLength
expected = [
/^Filename\s+|\s+Count\s+|\s+Bytes\s+|\s+Time$/,
/^-+\++-+\++-+\++-+$/,
- /^_posts\/2010-01-09-date-override\.markdown\s+|\s+\d+\s+|\s+\d+\.\d{2}K\s+|\s+\d+\.\d{3}$/,
+ %r!^_posts/2010-01-09-date-override\.markdown\s+|\s+\d+\s+|\s+\d+\.\d{2}K\s+|\s+\d+\.\d{3}$!
]
+ # rubocop:enable Metrics/LineLength
expected.each do |regexp|
assert_match regexp, output
diff --git a/test/test_page.rb b/test/test_page.rb
index 8930095d..5b4aabeb 100644
--- a/test/test_page.rb
+++ b/test/test_page.rb
@@ -1,15 +1,18 @@
-require 'helper'
+require "helper"
class TestPage < JekyllUnitTest
def setup_page(*args)
dir, file = args
- dir, file = ['', dir] if file.nil?
+ if file.nil?
+ file = dir
+ dir = ""
+ end
@page = Page.new(@site, source_dir, dir, file)
end
def do_render(page)
layouts = {
- "default" => Layout.new(@site, source_dir('_layouts'), "simple.html")
+ "default" => Layout.new(@site, source_dir("_layouts"), "simple.html")
}
page.render(layouts, @site.site_payload)
end
@@ -18,15 +21,15 @@ class TestPage < JekyllUnitTest
setup do
clear_dest
@site = Site.new(Jekyll.configuration({
- "source" => source_dir,
- "destination" => dest_dir,
+ "source" => source_dir,
+ "destination" => dest_dir,
"skip_config_files" => true
}))
end
context "processing pages" do
should "create url based on filename" do
- @page = setup_page('contacts.html')
+ @page = setup_page("contacts.html")
assert_equal "/contacts.html", @page.url
end
@@ -36,29 +39,29 @@ class TestPage < JekyllUnitTest
end
should "create url with non-alphabetic characters" do
- @page = setup_page('+', '%# +.md')
+ @page = setup_page("+", '%# +.md')
assert_equal "/+/%25%23%20+.html", @page.url
end
context "in a directory hierarchy" do
should "create url based on filename" do
- @page = setup_page('/contacts', 'bar.html')
+ @page = setup_page("/contacts", "bar.html")
assert_equal "/contacts/bar.html", @page.url
end
should "create index url based on filename" do
- @page = setup_page('/contacts', 'index.html')
+ @page = setup_page("/contacts", "index.html")
assert_equal "/contacts/", @page.url
end
end
should "deal properly with extensions" do
- @page = setup_page('deal.with.dots.html')
+ @page = setup_page("deal.with.dots.html")
assert_equal ".html", @page.ext
end
should "deal properly with non-html extensions" do
- @page = setup_page('dynamic_page.php')
+ @page = setup_page("dynamic_page.php")
@dest_file = dest_dir("dynamic_page.php")
assert_equal ".php", @page.ext
assert_equal "dynamic_page", @page.basename
@@ -67,7 +70,7 @@ class TestPage < JekyllUnitTest
end
should "deal properly with dots" do
- @page = setup_page('deal.with.dots.html')
+ @page = setup_page("deal.with.dots.html")
@dest_file = dest_dir("deal.with.dots.html")
assert_equal "deal.with.dots", @page.basename
@@ -75,19 +78,19 @@ class TestPage < JekyllUnitTest
end
should "make properties accessible through #[]" do
- page = setup_page('properties.html')
+ page = setup_page("properties.html")
attrs = {
- content: "All the properties.\n",
- dir: "/properties/",
- excerpt: nil,
- foo: 'bar',
- layout: 'default',
- name: "properties.html",
- path: "properties.html",
- permalink: '/properties/',
- published: nil,
- title: 'Properties Page',
- url: "/properties/"
+ :content => "All the properties.\n",
+ :dir => "/properties/",
+ :excerpt => nil,
+ :foo => "bar",
+ :layout => "default",
+ :name => "properties.html",
+ :path => "properties.html",
+ :permalink => "/properties/",
+ :published => nil,
+ :title => "Properties Page",
+ :url => "/properties/"
}
attrs.each do |attr, val|
@@ -103,38 +106,38 @@ class TestPage < JekyllUnitTest
end
should "return dir, url, and destination correctly" do
- @page = setup_page('contacts.html')
+ @page = setup_page("contacts.html")
@dest_file = dest_dir("contacts/index.html")
- assert_equal '/contacts/', @page.dir
- assert_equal '/contacts/', @page.url
+ assert_equal "/contacts/", @page.dir
+ assert_equal "/contacts/", @page.url
assert_equal @dest_file, @page.destination(dest_dir)
end
should "return dir correctly for index page" do
- @page = setup_page('index.html')
- assert_equal '/', @page.dir
+ @page = setup_page("index.html")
+ assert_equal "/", @page.dir
end
context "in a directory hierarchy" do
should "create url based on filename" do
- @page = setup_page('/contacts', 'bar.html')
+ @page = setup_page("/contacts", "bar.html")
assert_equal "/contacts/bar/", @page.url
end
should "create index url based on filename" do
- @page = setup_page('/contacts', 'index.html')
+ @page = setup_page("/contacts", "index.html")
assert_equal "/contacts/", @page.url
end
should "return dir correctly" do
- @page = setup_page('/contacts', 'bar.html')
- assert_equal '/contacts/bar/', @page.dir
+ @page = setup_page("/contacts", "bar.html")
+ assert_equal "/contacts/bar/", @page.dir
end
should "return dir correctly for index page" do
- @page = setup_page('/contacts', 'index.html')
- assert_equal '/contacts/', @page.dir
+ @page = setup_page("/contacts", "index.html")
+ assert_equal "/contacts/", @page.dir
end
end
end
@@ -145,16 +148,16 @@ class TestPage < JekyllUnitTest
end
should "return url and destination correctly" do
- @page = setup_page('contacts.html')
+ @page = setup_page("contacts.html")
@dest_file = dest_dir("contacts.html")
- assert_equal '/contacts.html', @page.url
+ assert_equal "/contacts.html", @page.url
assert_equal @dest_file, @page.destination(dest_dir)
end
should "return dir correctly" do
- assert_equal '/', setup_page('contacts.html').dir
- assert_equal '/contacts/', setup_page('contacts/bar.html').dir
- assert_equal '/contacts/', setup_page('contacts/index.html').dir
+ assert_equal "/", setup_page("contacts.html").dir
+ assert_equal "/contacts/", setup_page("contacts/bar.html").dir
+ assert_equal "/contacts/", setup_page("contacts/index.html").dir
end
end
@@ -164,9 +167,9 @@ class TestPage < JekyllUnitTest
end
should "return url and destination correctly" do
- @page = setup_page('contacts.html')
+ @page = setup_page("contacts.html")
@dest_file = dest_dir("contacts/index.html")
- assert_equal '/contacts/', @page.url
+ assert_equal "/contacts/", @page.url
assert_equal @dest_file, @page.destination(dest_dir)
end
end
@@ -177,9 +180,9 @@ class TestPage < JekyllUnitTest
end
should "return url and destination correctly" do
- @page = setup_page('contacts.html')
+ @page = setup_page("contacts.html")
@dest_file = dest_dir("contacts.html")
- assert_equal '/contacts.html', @page.url
+ assert_equal "/contacts.html", @page.url
assert_equal @dest_file, @page.destination(dest_dir)
end
end
@@ -190,9 +193,9 @@ class TestPage < JekyllUnitTest
end
should "return url and destination correctly" do
- @page = setup_page('contacts.html')
+ @page = setup_page("contacts.html")
@dest_file = dest_dir("contacts.html")
- assert_equal '/contacts', @page.url
+ assert_equal "/contacts", @page.url
assert_equal @dest_file, @page.destination(dest_dir)
end
end
@@ -200,9 +203,9 @@ class TestPage < JekyllUnitTest
context "with any other permalink style" do
should "return dir correctly" do
@site.permalink_style = nil
- assert_equal '/', setup_page('contacts.html').dir
- assert_equal '/contacts/', setup_page('contacts/index.html').dir
- assert_equal '/contacts/', setup_page('contacts/bar.html').dir
+ assert_equal "/", setup_page("contacts.html").dir
+ assert_equal "/contacts/", setup_page("contacts/index.html").dir
+ assert_equal "/contacts/", setup_page("contacts/bar.html").dir
end
end
@@ -216,7 +219,7 @@ class TestPage < JekyllUnitTest
end
should "return nil permalink if no permalink exists" do
- @page = setup_page('')
+ @page = setup_page("")
assert_equal nil, @page.permalink
end
@@ -233,7 +236,7 @@ class TestPage < JekyllUnitTest
context "with specified layout of nil" do
setup do
- @page = setup_page('sitemap.xml')
+ @page = setup_page("sitemap.xml")
end
should "layout of nil is respected" do
@@ -247,60 +250,60 @@ class TestPage < JekyllUnitTest
end
should "write properly" do
- page = setup_page('contacts.html')
+ page = setup_page("contacts.html")
do_render(page)
page.write(dest_dir)
assert File.directory?(dest_dir)
- assert_exist dest_dir('contacts.html')
+ assert_exist dest_dir("contacts.html")
end
should "write even when the folder name is plus and permalink has +" do
- page = setup_page('+', 'foo.md')
+ page = setup_page("+", "foo.md")
do_render(page)
page.write(dest_dir)
assert File.directory?(dest_dir), "#{dest_dir} should be a directory"
- assert_exist dest_dir('+', 'plus+in+url.html')
+ assert_exist dest_dir("+", "plus+in+url.html")
end
should "write even when permalink has '%# +'" do
- page = setup_page('+', '%# +.md')
+ page = setup_page("+", '%# +.md')
do_render(page)
page.write(dest_dir)
assert File.directory?(dest_dir)
- assert_exist dest_dir('+', '%# +.html')
+ assert_exist dest_dir("+", '%# +.html')
end
should "write properly without html extension" do
- page = setup_page('contacts.html')
+ page = setup_page("contacts.html")
page.site.permalink_style = :pretty
do_render(page)
page.write(dest_dir)
assert File.directory?(dest_dir)
- assert_exist dest_dir('contacts', 'index.html')
+ assert_exist dest_dir("contacts", "index.html")
end
should "support .htm extension and respects that" do
- page = setup_page('contacts.htm')
+ page = setup_page("contacts.htm")
page.site.permalink_style = :pretty
do_render(page)
page.write(dest_dir)
assert File.directory?(dest_dir)
- assert_exist dest_dir('contacts', 'index.htm')
+ assert_exist dest_dir("contacts", "index.htm")
end
should "support .xhtml extension and respects that" do
- page = setup_page('contacts.xhtml')
+ page = setup_page("contacts.xhtml")
page.site.permalink_style = :pretty
do_render(page)
page.write(dest_dir)
assert File.directory?(dest_dir)
- assert_exist dest_dir('contacts', 'index.xhtml')
+ assert_exist dest_dir("contacts", "index.xhtml")
end
should "write properly with extension different from html" do
@@ -312,48 +315,47 @@ class TestPage < JekyllUnitTest
assert_equal "/sitemap.xml", page.url
assert_nil page.url[/\.html$/]
assert File.directory?(dest_dir)
- assert_exist dest_dir('sitemap.xml')
+ assert_exist dest_dir("sitemap.xml")
end
should "write dotfiles properly" do
- page = setup_page('.htaccess')
+ page = setup_page(".htaccess")
do_render(page)
page.write(dest_dir)
assert File.directory?(dest_dir)
- assert_exist dest_dir('.htaccess')
+ assert_exist dest_dir(".htaccess")
end
context "in a directory hierarchy" do
should "write properly the index" do
- page = setup_page('/contacts', 'index.html')
+ page = setup_page("/contacts", "index.html")
do_render(page)
page.write(dest_dir)
assert File.directory?(dest_dir)
- assert_exist dest_dir('contacts', 'index.html')
+ assert_exist dest_dir("contacts", "index.html")
end
should "write properly" do
- page = setup_page('/contacts', 'bar.html')
+ page = setup_page("/contacts", "bar.html")
do_render(page)
page.write(dest_dir)
assert File.directory?(dest_dir)
- assert_exist dest_dir('contacts', 'bar.html')
+ assert_exist dest_dir("contacts", "bar.html")
end
should "write properly without html extension" do
- page = setup_page('/contacts', 'bar.html')
+ page = setup_page("/contacts", "bar.html")
page.site.permalink_style = :pretty
do_render(page)
page.write(dest_dir)
assert File.directory?(dest_dir)
- assert_exist dest_dir('contacts', 'bar', 'index.html')
+ assert_exist dest_dir("contacts", "bar", "index.html")
end
end
end
-
end
end
diff --git a/test/test_regenerator.rb b/test/test_regenerator.rb
index 1ed21211..36b15949 100644
--- a/test/test_regenerator.rb
+++ b/test/test_regenerator.rb
@@ -1,4 +1,4 @@
-require 'helper'
+require "helper"
class TestRegenerator < JekyllUnitTest
context "The site regenerator" do
@@ -39,11 +39,10 @@ class TestRegenerator < JekyllUnitTest
# we need to create the destinations for these files,
# because regenerate? checks if the destination exists
[@page, @post, @document, @asset_file].each do |item|
- if item.respond_to?(:destination)
- dest = item.destination(@site.dest)
- FileUtils.mkdir_p(File.dirname(dest))
- FileUtils.touch(dest)
- end
+ next unless item.respond_to?(:destination)
+ dest = item.destination(@site.dest)
+ FileUtils.mkdir_p(File.dirname(dest))
+ FileUtils.touch(dest)
end
@regenerator.write_metadata
@regenerator = Regenerator.new(@site)
@@ -69,7 +68,7 @@ class TestRegenerator < JekyllUnitTest
[@page, @post, @document, @asset_file].each do |item|
if item.respond_to?(:destination)
dest = item.destination(@site.dest)
- File.unlink(dest) unless !File.exist?(dest)
+ File.unlink(dest) if File.exist?(dest)
end
end
@@ -128,7 +127,7 @@ class TestRegenerator < JekyllUnitTest
FileUtils.rm_rf(source_dir(".jekyll-metadata"))
@site = Site.new(Jekyll.configuration({
- "source" => source_dir,
+ "source" => source_dir,
"destination" => dest_dir,
"incremental" => true
}))
@@ -152,7 +151,7 @@ class TestRegenerator < JekyllUnitTest
assert @regenerator.cache[@path]
@regenerator.clear_cache
- assert_equal @regenerator.cache, {}
+ assert_equal @regenerator.cache, {}
end
should "write to the metadata file" do
@@ -171,7 +170,7 @@ class TestRegenerator < JekyllUnitTest
metadata_file = source_dir(".jekyll-metadata")
@regenerator = Regenerator.new(@site)
- File.open(metadata_file, 'w') do |f|
+ File.open(metadata_file, "w") do |f|
f.write(@regenerator.metadata.to_yaml)
end
@@ -182,7 +181,7 @@ class TestRegenerator < JekyllUnitTest
should "not crash when reading corrupted marshal file" do
metadata_file = source_dir(".jekyll-metadata")
File.open(metadata_file, "w") do |file|
- file.puts Marshal.dump({ foo: 'bar' })[0,5]
+ file.puts Marshal.dump({ :foo => "bar" })[0, 5]
end
@regenerator = Regenerator.new(@site)
@@ -282,7 +281,7 @@ class TestRegenerator < JekyllUnitTest
end
should "not regenerate again if multiple dependencies" do
- multi_deps = @regenerator.metadata.select {|k,v| v['deps'].length > 2}
+ multi_deps = @regenerator.metadata.select { |_k, v| v["deps"].length > 2 }
multi_dep_path = multi_deps.keys.first
assert @regenerator.metadata[multi_dep_path]["deps"].length > 2
@@ -310,7 +309,7 @@ class TestRegenerator < JekyllUnitTest
setup do
FileUtils.rm_rf(source_dir(".jekyll-metadata"))
@site = Site.new(Jekyll.configuration({
- "source" => source_dir,
+ "source" => source_dir,
"destination" => dest_dir,
"incremental" => false
}))
diff --git a/test/test_site.rb b/test/test_site.rb
index 5e52a7c9..4e9e18a5 100644
--- a/test/test_site.rb
+++ b/test/test_site.rb
@@ -1,45 +1,47 @@
-require 'helper'
+require "helper"
class TestSite < JekyllUnitTest
context "configuring sites" do
should "have an array for plugins by default" do
site = Site.new default_configuration
- assert_equal [File.join(Dir.pwd, '_plugins')], site.plugins
+ assert_equal [File.join(Dir.pwd, "_plugins")], site.plugins
end
should "look for plugins under the site directory by default" do
site = Site.new(site_configuration)
- assert_equal [source_dir('_plugins')], site.plugins
+ assert_equal [source_dir("_plugins")], site.plugins
end
should "have an array for plugins if passed as a string" do
- site = Site.new(site_configuration({ 'plugins_dir' => '/tmp/plugins' }))
- assert_equal ['/tmp/plugins'], site.plugins
+ site = Site.new(site_configuration({ "plugins_dir" => "/tmp/plugins" }))
+ assert_equal ["/tmp/plugins"], site.plugins
end
should "have an array for plugins if passed as an array" do
- site = Site.new(site_configuration({ 'plugins_dir' => ['/tmp/plugins', '/tmp/otherplugins'] }))
- assert_equal ['/tmp/plugins', '/tmp/otherplugins'], site.plugins
+ site = Site.new(site_configuration({
+ "plugins_dir" => ["/tmp/plugins", "/tmp/otherplugins"]
+ }))
+ assert_equal ["/tmp/plugins", "/tmp/otherplugins"], site.plugins
end
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
end
should "have the default for plugins if nil is passed" do
- site = Site.new(site_configuration({ 'plugins_dir' => nil }))
- assert_equal [source_dir('_plugins')], site.plugins
+ site = Site.new(site_configuration({ "plugins_dir" => nil }))
+ assert_equal [source_dir("_plugins")], site.plugins
end
should "expose default baseurl" do
site = Site.new(default_configuration)
- assert_equal Jekyll::Configuration::DEFAULTS['baseurl'], site.baseurl
+ assert_equal Jekyll::Configuration::DEFAULTS["baseurl"], site.baseurl
end
should "expose baseurl passed in from config" do
- site = Site.new(site_configuration({ 'baseurl' => '/blog' }))
- assert_equal '/blog', site.baseurl
+ site = Site.new(site_configuration({ "baseurl" => "/blog" }))
+ assert_equal "/blog", site.baseurl
end
end
context "creating sites" do
@@ -55,7 +57,7 @@ class TestSite < JekyllUnitTest
end
should "have an empty tag hash by default" do
- assert_equal Hash.new, @site.tags
+ assert_equal({}, @site.tags)
end
should "give site with parsed pages and posts to generators" do
@@ -65,14 +67,14 @@ class TestSite < JekyllUnitTest
raise "#{page} isn't a page" unless page.is_a?(Page)
raise "#{page} doesn't respond to :name" unless page.respond_to?(:name)
end
- site.file_read_opts[:secret_message] = 'hi'
+ site.file_read_opts[:secret_message] = "hi"
end
end
@site = Site.new(site_configuration)
@site.read
@site.generate
refute_equal 0, @site.pages.size
- assert_equal 'hi', @site.file_read_opts[:secret_message]
+ assert_equal "hi", @site.file_read_opts[:secret_message]
end
should "reset data before processing" do
@@ -157,13 +159,21 @@ class TestSite < JekyllUnitTest
end
should "setup plugins in priority order" do
- assert_equal @site.converters.sort_by(&:class).map{|c|c.class.priority}, @site.converters.map{|c|c.class.priority}
- assert_equal @site.generators.sort_by(&:class).map{|g|g.class.priority}, @site.generators.map{|g|g.class.priority}
+ assert_equal(
+ @site.converters.sort_by(&:class).map { |c| c.class.priority },
+ @site.converters.map { |c| c.class.priority }
+ )
+ assert_equal(
+ @site.generators.sort_by(&:class).map { |g| g.class.priority },
+ @site.generators.map { |g| g.class.priority }
+ )
end
should "sort pages alphabetically" do
method = Dir.method(:entries)
- allow(Dir).to receive(:entries) { |*args, &block| method.call(*args, &block).reverse }
+ allow(Dir).to receive(:entries) do |*args, &block|
+ method.call(*args, &block).reverse
+ end
@site.process
# files in symlinked directories may appear twice
sorted_pages = %w(
@@ -192,9 +202,11 @@ class TestSite < JekyllUnitTest
end
should "read posts" do
- @site.posts.docs.concat(PostReader.new(@site).read_posts(''))
- posts = Dir[source_dir('_posts', '**', '*')]
- posts.delete_if { |post| File.directory?(post) && !(post =~ Document::DATE_FILENAME_MATCHER) }
+ @site.posts.docs.concat(PostReader.new(@site).read_posts(""))
+ posts = Dir[source_dir("_posts", "**", "*")]
+ posts.delete_if do |post|
+ File.directory?(post) && !(post =~ Document::DATE_FILENAME_MATCHER)
+ end
assert_equal posts.size - @num_invalid_posts, @site.posts.size
end
@@ -209,11 +221,11 @@ class TestSite < JekyllUnitTest
end
should "expose jekyll version to site payload" do
- assert_equal Jekyll::VERSION, @site.site_payload['jekyll']['version']
+ assert_equal Jekyll::VERSION, @site.site_payload["jekyll"]["version"]
end
should "expose list of static files to site payload" do
- assert_equal @site.static_files, @site.site_payload['site']['static_files']
+ assert_equal @site.static_files, @site.site_payload["site"]["static_files"]
end
should "deploy payload" do
@@ -221,118 +233,125 @@ class TestSite < JekyllUnitTest
@site.process
posts = Dir[source_dir("**", "_posts", "**", "*")]
- posts.delete_if { |post| File.directory?(post) && !(post =~ Document::DATE_FILENAME_MATCHER) }
- categories = %w(2013 bar baz category foo z_category MixedCase Mixedcase publish_test win).sort
+ posts.delete_if do |post|
+ File.directory?(post) && !(post =~ Document::DATE_FILENAME_MATCHER)
+ end
+ categories = %w(
+ 2013 bar baz category foo z_category MixedCase Mixedcase publish_test win
+ ).sort
assert_equal posts.size - @num_invalid_posts, @site.posts.size
assert_equal categories, @site.categories.keys.sort
- assert_equal 5, @site.categories['foo'].size
+ assert_equal 5, @site.categories["foo"].size
end
- context 'error handling' do
+ context "error handling" do
should "raise if destination is included in source" do
assert_raises Jekyll::Errors::FatalException do
- Site.new(site_configuration('destination' => source_dir))
+ Site.new(site_configuration("destination" => source_dir))
end
end
should "raise if destination is source" do
assert_raises Jekyll::Errors::FatalException do
- Site.new(site_configuration('destination' => File.join(source_dir, "..")))
+ Site.new(site_configuration("destination" => File.join(source_dir, "..")))
end
end
end
- context 'with orphaned files in destination' do
+ context "with orphaned files in destination" do
setup do
clear_dest
@site.regenerator.clear
@site.process
# generate some orphaned files:
# single file
- File.open(dest_dir('obsolete.html'), 'w')
+ File.open(dest_dir("obsolete.html"), "w")
# single file in sub directory
- FileUtils.mkdir(dest_dir('qux'))
- File.open(dest_dir('qux/obsolete.html'), 'w')
+ FileUtils.mkdir(dest_dir("qux"))
+ File.open(dest_dir("qux/obsolete.html"), "w")
# empty directory
- FileUtils.mkdir(dest_dir('quux'))
- FileUtils.mkdir(dest_dir('.git'))
- FileUtils.mkdir(dest_dir('.svn'))
- FileUtils.mkdir(dest_dir('.hg'))
+ FileUtils.mkdir(dest_dir("quux"))
+ FileUtils.mkdir(dest_dir(".git"))
+ FileUtils.mkdir(dest_dir(".svn"))
+ FileUtils.mkdir(dest_dir(".hg"))
# single file in repository
- File.open(dest_dir('.git/HEAD'), 'w')
- File.open(dest_dir('.svn/HEAD'), 'w')
- File.open(dest_dir('.hg/HEAD'), 'w')
+ File.open(dest_dir(".git/HEAD"), "w")
+ File.open(dest_dir(".svn/HEAD"), "w")
+ File.open(dest_dir(".hg/HEAD"), "w")
end
teardown do
- FileUtils.rm_f(dest_dir('obsolete.html'))
- FileUtils.rm_rf(dest_dir('qux'))
- FileUtils.rm_f(dest_dir('quux'))
- FileUtils.rm_rf(dest_dir('.git'))
- FileUtils.rm_rf(dest_dir('.svn'))
- FileUtils.rm_rf(dest_dir('.hg'))
+ FileUtils.rm_f(dest_dir("obsolete.html"))
+ FileUtils.rm_rf(dest_dir("qux"))
+ FileUtils.rm_f(dest_dir("quux"))
+ FileUtils.rm_rf(dest_dir(".git"))
+ FileUtils.rm_rf(dest_dir(".svn"))
+ FileUtils.rm_rf(dest_dir(".hg"))
end
- should 'remove orphaned files in destination' do
+ should "remove orphaned files in destination" do
@site.process
- refute_exist dest_dir('obsolete.html')
- refute_exist dest_dir('qux')
- refute_exist dest_dir('quux')
- assert_exist dest_dir('.git')
- assert_exist dest_dir('.git', 'HEAD')
+ refute_exist dest_dir("obsolete.html")
+ refute_exist dest_dir("qux")
+ refute_exist dest_dir("quux")
+ assert_exist dest_dir(".git")
+ assert_exist dest_dir(".git", "HEAD")
end
- should 'remove orphaned files in destination - keep_files .svn' do
- config = site_configuration('keep_files' => %w{.svn})
+ should "remove orphaned files in destination - keep_files .svn" do
+ config = site_configuration("keep_files" => %w(.svn))
@site = Site.new(config)
@site.process
- refute_exist dest_dir('.htpasswd')
- refute_exist dest_dir('obsolete.html')
- refute_exist dest_dir('qux')
- refute_exist dest_dir('quux')
- refute_exist dest_dir('.git')
- refute_exist dest_dir('.git', 'HEAD')
- assert_exist dest_dir('.svn')
- assert_exist dest_dir('.svn', 'HEAD')
+ refute_exist dest_dir(".htpasswd")
+ refute_exist dest_dir("obsolete.html")
+ refute_exist dest_dir("qux")
+ refute_exist dest_dir("quux")
+ refute_exist dest_dir(".git")
+ refute_exist dest_dir(".git", "HEAD")
+ assert_exist dest_dir(".svn")
+ assert_exist dest_dir(".svn", "HEAD")
end
end
- context 'using a non-default markdown processor in the configuration' do
- should 'use the non-default markdown processor' do
+ context "using a non-default markdown processor in the configuration" do
+ should "use the non-default markdown processor" do
class Jekyll::Converters::Markdown::CustomMarkdown
def initialize(*args)
@args = args
end
- def convert(*args)
+ def convert(*_args)
""
end
end
custom_processor = "CustomMarkdown"
- s = Site.new(site_configuration('markdown' => custom_processor))
+ s = Site.new(site_configuration("markdown" => custom_processor))
s.process
# Do some cleanup, we don't like straggling stuff's.
Jekyll::Converters::Markdown.send(:remove_const, :CustomMarkdown)
end
- should 'ignore, if there are any bad characters in the class name' do
+ should "ignore, if there are any bad characters in the class name" do
module Jekyll::Converters::Markdown::Custom
class Markdown
def initialize(*args)
@args = args
end
- def convert(*args)
+ def convert(*_args)
""
end
end
end
bad_processor = "Custom::Markdown"
- s = Site.new(site_configuration('markdown' => bad_processor, 'incremental' => false))
+ s = Site.new(site_configuration(
+ "markdown" => bad_processor,
+ "incremental" => false
+ ))
assert_raises Jekyll::Errors::FatalException do
s.process
end
@@ -342,96 +361,105 @@ class TestSite < JekyllUnitTest
end
end
- context 'with an invalid markdown processor in the configuration' do
- should 'not throw an error at initialization time' do
- bad_processor = 'not a processor name'
- assert Site.new(site_configuration('markdown' => bad_processor))
+ context "with an invalid markdown processor in the configuration" do
+ should "not throw an error at initialization time" do
+ bad_processor = "not a processor name"
+ assert Site.new(site_configuration("markdown" => bad_processor))
end
- should 'throw FatalException at process time' do
- bad_processor = 'not a processor name'
- s = Site.new(site_configuration('markdown' => bad_processor, 'incremental' => false))
+ should "throw FatalException at process time" do
+ bad_processor = "not a processor name"
+ s = Site.new(site_configuration(
+ "markdown" => bad_processor,
+ "incremental" => false
+ ))
assert_raises Jekyll::Errors::FatalException do
s.process
end
end
end
- context 'data directory' do
- should 'auto load yaml files' do
+ context "data directory" do
+ should "auto load yaml files" do
site = Site.new(site_configuration)
site.process
- file_content = SafeYAML.load_file(File.join(source_dir, '_data', 'members.yaml'))
+ file_content = SafeYAML.load_file(File.join(source_dir, "_data", "members.yaml"))
- assert_equal site.data['members'], file_content
- assert_equal site.site_payload['site']['data']['members'], file_content
+ assert_equal site.data["members"], file_content
+ assert_equal site.site_payload["site"]["data"]["members"], file_content
end
- should 'load yaml files from extracted method' do
+ should "load yaml files from extracted method" do
site = Site.new(site_configuration)
site.process
- file_content = DataReader.new(site).read_data_file(source_dir('_data', 'members.yaml'))
+ file_content = DataReader.new(site)
+ .read_data_file(source_dir("_data", "members.yaml"))
- assert_equal site.data['members'], file_content
- assert_equal site.site_payload['site']['data']['members'], file_content
+ assert_equal site.data["members"], file_content
+ assert_equal site.site_payload["site"]["data"]["members"], file_content
end
- should 'auto load yml files' do
+ should "auto load yml files" do
site = Site.new(site_configuration)
site.process
- file_content = SafeYAML.load_file(File.join(source_dir, '_data', 'languages.yml'))
+ file_content = SafeYAML.load_file(File.join(source_dir, "_data", "languages.yml"))
- assert_equal site.data['languages'], file_content
- assert_equal site.site_payload['site']['data']['languages'], file_content
+ assert_equal site.data["languages"], file_content
+ assert_equal site.site_payload["site"]["data"]["languages"], file_content
end
- should 'auto load json files' do
+ should "auto load json files" do
site = Site.new(site_configuration)
site.process
- file_content = SafeYAML.load_file(File.join(source_dir, '_data', 'members.json'))
+ file_content = SafeYAML.load_file(File.join(source_dir, "_data", "members.json"))
- assert_equal site.data['members'], file_content
- assert_equal site.site_payload['site']['data']['members'], file_content
+ assert_equal site.data["members"], file_content
+ assert_equal site.site_payload["site"]["data"]["members"], file_content
end
- should 'auto load yaml files in subdirectory' do
+ should "auto load yaml files in subdirectory" do
site = Site.new(site_configuration)
site.process
- file_content = SafeYAML.load_file(File.join(source_dir, '_data', 'categories', 'dairy.yaml'))
+ file_content = SafeYAML.load_file(File.join(
+ source_dir, "_data", "categories", "dairy.yaml"
+ ))
- assert_equal site.data['categories']['dairy'], file_content
- assert_equal site.site_payload['site']['data']['categories']['dairy'], file_content
+ assert_equal site.data["categories"]["dairy"], file_content
+ assert_equal(
+ site.site_payload["site"]["data"]["categories"]["dairy"],
+ file_content
+ )
end
should "load symlink files in unsafe mode" do
- site = Site.new(site_configuration('safe' => false))
+ site = Site.new(site_configuration("safe" => false))
site.process
- file_content = SafeYAML.load_file(File.join(source_dir, '_data', 'products.yml'))
+ file_content = SafeYAML.load_file(File.join(source_dir, "_data", "products.yml"))
- assert_equal site.data['products'], file_content
- assert_equal site.site_payload['site']['data']['products'], file_content
+ assert_equal site.data["products"], file_content
+ assert_equal site.site_payload["site"]["data"]["products"], file_content
end
- should "load the symlink files in safe mode, as they resolve to inside site.source" do
- site = Site.new(site_configuration('safe' => true))
+ should "load the symlink files in safe mode, " \
+ "as they resolve to inside site.source" do
+ site = Site.new(site_configuration("safe" => true))
site.process
- file_content = SafeYAML.load_file(File.join(source_dir, '_data', 'products.yml'))
- assert_equal site.data['products'], file_content
- assert_equal site.site_payload['site']['data']['products'], file_content
+ file_content = SafeYAML.load_file(File.join(source_dir, "_data", "products.yml"))
+ assert_equal site.data["products"], file_content
+ assert_equal site.site_payload["site"]["data"]["products"], file_content
end
-
end
context "manipulating the Jekyll environment" do
setup do
@site = Site.new(site_configuration({
- 'incremental' => false
+ "incremental" => false
}))
@site.process
@page = @site.pages.find { |p| p.name == "environment.html" }
@@ -445,7 +473,7 @@ class TestSite < JekyllUnitTest
setup do
ENV["JEKYLL_ENV"] = "production"
@site = Site.new(site_configuration({
- 'incremental' => false
+ "incremental" => false
}))
@site.process
@page = @site.pages.find { |p| p.name == "environment.html" }
@@ -463,7 +491,7 @@ class TestSite < JekyllUnitTest
context "with liquid profiling" do
setup do
- @site = Site.new(site_configuration('profile' => true))
+ @site = Site.new(site_configuration("profile" => true))
end
# Suppress output while testing
@@ -483,7 +511,7 @@ class TestSite < JekyllUnitTest
context "incremental build" do
setup do
@site = Site.new(site_configuration({
- 'incremental' => true
+ "incremental" => true
}))
@site.read
end
@@ -533,8 +561,6 @@ class TestSite < JekyllUnitTest
mtime2 = File.stat(dest).mtime.to_i
refute_equal mtime1, mtime2 # must be regenerated
end
-
end
-
end
end
diff --git a/test/test_tags.rb b/test/test_tags.rb
index 1dab0feb..736d60d6 100644
--- a/test/test_tags.rb
+++ b/test/test_tags.rb
@@ -1,18 +1,17 @@
# coding: utf-8
-
-require 'helper'
+require "helper"
class TestTags < JekyllUnitTest
-
def setup
FileUtils.mkdir_p("tmp")
end
+ # rubocop:disable Metrics/AbcSize
def create_post(content, override = {}, converter_class = Jekyll::Converters::Markdown)
- site = fixture_site({"highlighter" => "rouge"}.merge(override))
+ site = fixture_site({ "highlighter" => "rouge" }.merge(override))
- site.posts.docs.concat(PostReader.new(site).read_posts('')) if override['read_posts']
- CollectionReader.new(site).read if override['read_collections']
+ site.posts.docs.concat(PostReader.new(site).read_posts("")) if override["read_posts"]
+ CollectionReader.new(site).read if override["read_collections"]
info = { :filters => [Jekyll::Filters], :registers => { :site => site } }
@converter = site.converters.find { |c| c.class == converter_class }
@@ -22,6 +21,7 @@ class TestTags < JekyllUnitTest
@result = Liquid::Template.parse(content).render!(payload, info)
@result = @converter.convert(@result)
end
+ # rubocop:enable Metrics/AbcSize
def fill_post(code, override = {})
content = < This is not yet highlighted This should not be highlighted, right? This is not yet highlighted This should not be highlighted, right?
}, @result
+ assert_match(
+ %(test
),
+ @result
+ )
end
should "render markdown with pygments with line numbers" do
- assert_match %{test
}, @result
+ assert_match(
+ %(1 test
),
+ @result
+ )
end
end
context "post content has highlight with file reference" do
setup do
- fill_post("./jekyll.gemspec", {'highlighter' => 'pygments'})
+ fill_post("./jekyll.gemspec", { "highlighter" => "pygments" })
end
should "not embed the file" do
- assert_match %{) +
+ %(1 test
}, @result
+ assert_match(
+ %(./jekyll.gemspec
),
+ @result
+ )
end
end
context "post content has highlight tag with UTF character" do
setup do
- fill_post("Æ", {'highlighter' => 'pygments'})
+ fill_post("Æ", { "highlighter" => "pygments" })
end
should "render markdown with pygments line handling" do
- assert_match %{) +
+ %(./jekyll.gemspec
}, @result
+ assert_match(
+ %(Æ
),
+ @result
+ )
end
end
@@ -190,15 +232,19 @@ CONTENT
[1,] FALSE TRUE
[2,] FALSE TRUE
EOS
- fill_post(code, {'highlighter' => 'pygments'})
+ fill_post(code, { "highlighter" => "pygments" })
end
should "only strip the preceding newlines" do
- assert_match %{Æ
[,1] [,2]}, @result
+ assert_match(
+ %(
[,1] [,2]),
+ @result
+ )
end
end
- context "post content has highlight tag with preceding spaces & lines in several places" do
+ context "post content has highlight tag " \
+ "with preceding spaces & lines in several places" do
setup do
code = <<-EOS
@@ -211,21 +257,29 @@ EOS
EOS
- fill_post(code, {'highlighter' => 'pygments'})
+ fill_post(code, { "highlighter" => "pygments" })
end
should "only strip the newlines which precede and succeed the entire block" do
- assert_match "
", @result
+ assert_match(
+ " [,1] [,2]\n\n\n[1,] FALSE TRUE\n[2,] FALSE TRUE
",
+ @result
+ )
end
end
- context "post content has highlight tag with preceding spaces & Windows-style newlines" do
+ context "post content has highlight tag with " \
+ "preceding spaces & Windows-style newlines" do
setup do
- fill_post "\r\n\r\n\r\n [,1] [,2]", {'highlighter' => 'pygments'}
+ fill_post "\r\n\r\n\r\n [,1] [,2]", { "highlighter" => "pygments" }
end
should "only strip the preceding newlines" do
- assert_match %{" \
+ " [,1] [,2]\n\n\n[1,] FALSE TRUE\n[2,] FALSE TRUE
[,1] [,2]}, @result
+ assert_match(
+ %(
[,1] [,2]),
+ @result
+ )
end
end
@@ -236,11 +290,14 @@ EOS
[1,] FALSE TRUE
[2,] FALSE TRUE
EOS
- fill_post(code, {'highlighter' => 'pygments'})
+ fill_post(code, { "highlighter" => "pygments" })
end
should "only strip the preceding newlines" do
- assert_match %{
[,1] [,2]}, @result
+ assert_match(
+ %(
[,1] [,2]),
+ @result
+ )
end
end
end
@@ -252,11 +309,21 @@ EOS
end
should "render markdown with rouge" do
- assert_match %{
}, @result
+ assert_match(
+ %(test
),
+ @result
+ )
end
should "render markdown with rouge with line numbers" do
- assert_match %{test
}, @result
+ assert_match(
+ %(1
test\n
) +
+ %(
),
+ @result
+ )
end
end
@@ -266,7 +333,11 @@ EOS
end
should "not embed the file" do
- assert_match %{ ) +
+ %() +
+ %( ) +
+ %(1
test\n
}, @result
+ assert_match(
+ './jekyll.gemspec
",
+ @result
+ )
end
end
@@ -276,7 +347,10 @@ EOS
end
should "render markdown with pygments line handling" do
- assert_match %{' \
+ "./jekyll.gemspec
}, @result
+ assert_match(
+ 'Æ
',
+ @result
+ )
end
end
@@ -292,11 +366,15 @@ EOS
end
should "only strip the preceding newlines" do
- assert_match %{Æ
[,1] [,2]}, @result
+ assert_match(
+ '
[,1] [,2]',
+ @result
+ )
end
end
- context "post content has highlight tag with preceding spaces & lines in several places" do
+ context "post content has highlight tag with " \
+ "preceding spaces & lines in several places" do
setup do
fill_post <<-EOS
@@ -312,7 +390,11 @@ EOS
end
should "only strip the newlines which precede and succeed the entire block" do
- assert_match "
", @result
+ assert_match(
+ " [,1] [,2]\n\n\n[1,] FALSE TRUE\n[2,] FALSE TRUE
",
+ @result
+ )
end
end
@@ -333,17 +415,29 @@ EOS
end
should "should stop highlighting at boundary" do
- assert_match " [,1] [,2]\n\n\n" \
+ "[1,] FALSE TRUE\n[2,] FALSE TRUE
1
test\n
1
test
+
[,1] [,2]}, @result
+ assert_match(
+ '
[,1] [,2]',
+ @result
+ )
end
end
@@ -357,7 +451,10 @@ EOS
end
should "only strip the preceding newlines" do
- assert_match %{
[,1] [,2]}, @result
+ assert_match(
+ '
[,1] [,2]',
+ @result
+ )
end
end
end
@@ -388,24 +485,24 @@ CONTENT
end
create_post(@content, {
- 'markdown' => 'rdiscount'
+ "markdown" => "rdiscount"
})
end
should "parse correctly" do
assert_match %r{FIGHT!}, @result
- assert_match %r{FINISH HIM}, @result
+ assert_match %r!FINISH HIM!, @result
end
end
context "using Kramdown" do
setup do
- create_post(@content, 'markdown' => 'kramdown')
+ create_post(@content, "markdown" => "kramdown")
end
should "parse correctly" do
assert_match %r{FIGHT!}, @result
- assert_match %r{FINISH HIM}, @result
+ assert_match %r!FINISH HIM!, @result
end
end
@@ -418,13 +515,13 @@ CONTENT
end
create_post(@content, {
- 'markdown' => 'redcarpet'
+ "markdown" => "redcarpet"
})
end
should "parse correctly" do
assert_match %r{FIGHT!}, @result
- assert_match %r{FINISH HIM}, @result
+ assert_match %r!FINISH HIM!, @result
end
end
end
@@ -438,7 +535,12 @@ title: Post linking
{% post_url 2008-11-21-complex %}
CONTENT
- create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
+ create_post(content, {
+ "permalink" => "pretty",
+ "source" => source_dir,
+ "destination" => dest_dir,
+ "read_posts" => true
+ })
end
should "not cause an error" do
@@ -446,7 +548,7 @@ CONTENT
end
should "have the url to the \"complex\" post from 2008-11-21" do
- assert_match %r{/2008/11/21/complex/}, @result
+ assert_match %r!/2008/11/21/complex/!, @result
end
end
@@ -462,7 +564,12 @@ title: Post linking
- 3 {% post_url es/2008-11-21-nested %}
- 4 {% post_url /es/2008-11-21-nested %}
CONTENT
- create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
+ create_post(content, {
+ "permalink" => "pretty",
+ "source" => source_dir,
+ "destination" => dest_dir,
+ "read_posts" => true
+ })
end
should "not cause an error" do
@@ -470,13 +577,13 @@ CONTENT
end
should "have the url to the \"complex\" post from 2008-11-21" do
- assert_match %r{1\s/2008/11/21/complex/}, @result
- assert_match %r{2\s/2008/11/21/complex/}, @result
+ assert_match %r!1\s/2008/11/21/complex/!, @result
+ assert_match %r!2\s/2008/11/21/complex/!, @result
end
should "have the url to the \"nested\" post from 2008-11-21" do
- assert_match %r{3\s/2008/11/21/nested/}, @result
- assert_match %r{4\s/2008/11/21/nested/}, @result
+ assert_match %r!3\s/2008/11/21/nested/!, @result
+ assert_match %r!4\s/2008/11/21/nested/!, @result
end
end
@@ -492,10 +599,10 @@ CONTENT
assert_raises Jekyll::Errors::PostURLError do
create_post(content, {
- 'permalink' => 'pretty',
- 'source' => source_dir,
- 'destination' => dest_dir,
- 'read_posts' => true
+ "permalink" => "pretty",
+ "source" => source_dir,
+ "destination" => dest_dir,
+ "read_posts" => true
})
end
end
@@ -511,10 +618,10 @@ CONTENT
assert_raises Jekyll::Errors::InvalidDateError do
create_post(content, {
- 'permalink' => 'pretty',
- 'source' => source_dir,
- 'destination' => dest_dir,
- 'read_posts' => true
+ "permalink" => "pretty",
+ "source" => source_dir,
+ "destination" => dest_dir,
+ "read_posts" => true
})
end
end
@@ -529,15 +636,20 @@ title: linking
{% link _methods/yaml_with_dots.md %}
CONTENT
- create_post(content, {'source' => source_dir, 'destination' => dest_dir, 'collections' => { 'methods' => { 'output' => true }}, 'read_collections' => true})
+ create_post(content, {
+ "source" => source_dir,
+ "destination" => dest_dir,
+ "collections" => { "methods" => { "output" => true } },
+ "read_collections" => true
+ })
end
should "not cause an error" do
- refute_match /markdown\-html\-error/, @result
+ refute_match(/markdown\-html\-error/, @result)
end
should "have the url to the \"yaml_with_dots\" item" do
- assert_match %r{/methods/yaml_with_dots\.html}, @result
+ assert_match(%r!/methods/yaml_with_dots\.html!, @result)
end
end
@@ -551,19 +663,24 @@ title: linking
- 1 {% link _methods/sanitized_path.md %}
- 2 {% link _methods/site/generate.md %}
CONTENT
- create_post(content, {'source' => source_dir, 'destination' => dest_dir, 'collections' => { 'methods' => { 'output' => true }}, 'read_collections' => true})
+ create_post(content, {
+ "source" => source_dir,
+ "destination" => dest_dir,
+ "collections" => { "methods" => { "output" => true } },
+ "read_collections" => true
+ })
end
should "not cause an error" do
- refute_match /markdown\-html\-error/, @result
+ refute_match(/markdown\-html\-error/, @result)
end
should "have the url to the \"sanitized_path\" item" do
- assert_match %r{1\s/methods/sanitized_path\.html}, @result
+ assert_match %r!1\s/methods/sanitized_path\.html!, @result
end
should "have the url to the \"site/generate\" item" do
- assert_match %r{2\s/methods/site/generate\.html}, @result
+ assert_match %r!2\s/methods/site/generate\.html!, @result
end
end
@@ -578,17 +695,20 @@ title: Invalid linking
CONTENT
assert_raises ArgumentError do
- create_post(content, {'source' => source_dir, 'destination' => dest_dir, 'collections' => { 'methods' => { 'output' => true }}, 'read_collections' => true})
+ create_post(content, {
+ "source" => source_dir,
+ "destination" => dest_dir,
+ "collections" => { "methods" => { "output" => true } },
+ "read_collections" => true
+ })
end
end
end
context "include tag with parameters" do
-
context "with symlink'd include" do
-
should "not allow symlink includes" do
- File.open("tmp/pages-test", 'w') { |file| file.write("SYMLINK TEST") }
+ File.open("tmp/pages-test", "w") { |file| file.write("SYMLINK TEST") }
assert_raises IOError do
content = <