From 146d49dc8f1eb3a7d903e7af2d8d2a9ddb3243cf Mon Sep 17 00:00:00 2001 From: Brint O'Hearn Date: Sun, 15 May 2016 16:51:06 -0500 Subject: [PATCH 01/22] Rubocop test cleanups for #4885 This commit cleans up rubocop violations for the following files: test/test_ansi.rb test/test_cleaner.rb test/test_coffeescript.rb test/test_collections.rb test/test_command.rb test/test_commands_serve.rb --- .rubocop.yml | 6 ---- test/test_ansi.rb | 2 +- test/test_cleaner.rb | 57 +++++++++++++++++++------------------ test/test_coffeescript.rb | 7 +++-- test/test_collections.rb | 31 +++++++++++--------- test/test_command.rb | 2 +- test/test_commands_serve.rb | 5 ++-- 7 files changed, 55 insertions(+), 55 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 2ceac7c4..acdd1022 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -72,12 +72,6 @@ AllCops: - features/support/helpers.rb - test/helper.rb - test/simplecov_custom_profile.rb - - test/test_ansi.rb - - test/test_cleaner.rb - - test/test_coffeescript.rb - - test/test_collections.rb - - test/test_command.rb - - test/test_commands_serve.rb - test/test_configuration.rb - test/test_convertible.rb - test/test_doctor_command.rb diff --git a/test/test_ansi.rb b/test/test_ansi.rb index b209e237..8f18f56e 100644 --- a/test/test_ansi.rb +++ b/test/test_ansi.rb @@ -6,7 +6,7 @@ class TestAnsi < JekyllUnitTest @subject = Jekyll::Utils::Ansi end - Jekyll::Utils::Ansi::COLORS.each do |color, val| + Jekyll::Utils::Ansi::COLORS.each do |color, _val| should "respond_to? #{color}" do assert @subject.respond_to?(color) end diff --git a/test/test_cleaner.rb b/test/test_cleaner.rb index 2118c4f4..5e421c07 100644 --- a/test/test_cleaner.rb +++ b/test/test_cleaner.rb @@ -1,73 +1,74 @@ -require 'helper' +require "helper" class TestCleaner < JekyllUnitTest context "directory in keep_files" do setup do clear_dest - FileUtils.mkdir_p(dest_dir('to_keep/child_dir')) - FileUtils.touch(File.join(dest_dir('to_keep'), 'index.html')) - FileUtils.touch(File.join(dest_dir('to_keep/child_dir'), 'index.html')) + FileUtils.mkdir_p(dest_dir("to_keep/child_dir")) + FileUtils.touch(File.join(dest_dir("to_keep"), "index.html")) + FileUtils.touch(File.join(dest_dir("to_keep/child_dir"), "index.html")) @site = fixture_site - @site.keep_files = ['to_keep/child_dir'] + @site.keep_files = ["to_keep/child_dir"] @cleaner = Cleaner.new(@site) @cleaner.cleanup! end teardown do - FileUtils.rm_rf(dest_dir('to_keep')) + FileUtils.rm_rf(dest_dir("to_keep")) end should "keep the parent directory" do - assert_exist dest_dir('to_keep') + assert_exist dest_dir("to_keep") end should "keep the child directory" do - assert_exist dest_dir('to_keep', 'child_dir') + assert_exist dest_dir("to_keep", "child_dir") end should "keep the file in the directory in keep_files" do - assert_exist dest_dir('to_keep', 'child_dir', 'index.html') + assert_exist dest_dir("to_keep", "child_dir", "index.html") end should "delete the file in the directory not in keep_files" do - refute_exist dest_dir('to_keep', 'index.html') + refute_exist dest_dir("to_keep", "index.html") end end - context "not-nested directory in keep_files and similary named directory not in keep_files" do + context "not-nested directory in keep_files and similary named directory not "\ + "in keep_files" do setup do clear_dest - FileUtils.mkdir_p(dest_dir('.git/child_dir')) - FileUtils.mkdir_p(dest_dir('username.github.io')) - FileUtils.touch(File.join(dest_dir('.git'), 'index.html')) - FileUtils.touch(File.join(dest_dir('username.github.io'), 'index.html')) + FileUtils.mkdir_p(dest_dir(".git/child_dir")) + FileUtils.mkdir_p(dest_dir("username.github.io")) + FileUtils.touch(File.join(dest_dir(".git"), "index.html")) + FileUtils.touch(File.join(dest_dir("username.github.io"), "index.html")) @site = fixture_site - @site.keep_files = ['.git'] + @site.keep_files = [".git"] @cleaner = Cleaner.new(@site) @cleaner.cleanup! end teardown do - FileUtils.rm_rf(dest_dir('.git')) - FileUtils.rm_rf(dest_dir('username.github.io')) + FileUtils.rm_rf(dest_dir(".git")) + FileUtils.rm_rf(dest_dir("username.github.io")) end should "keep the file in the directory in keep_files" do - assert File.exist?(File.join(dest_dir('.git'), 'index.html')) + assert File.exist?(File.join(dest_dir(".git"), "index.html")) end should "delete the file in the directory not in keep_files" do - assert !File.exist?(File.join(dest_dir('username.github.io'), 'index.html')) + assert !File.exist?(File.join(dest_dir("username.github.io"), "index.html")) end should "delete the directory not in keep_files" do - assert !File.exist?(dest_dir('username.github.io')) + assert !File.exist?(dest_dir("username.github.io")) end end @@ -75,8 +76,8 @@ class TestCleaner < JekyllUnitTest setup do clear_dest - FileUtils.mkdir_p(source_dir('no_files_inside', 'child_dir')) - FileUtils.touch(source_dir('no_files_inside', 'child_dir', 'index.html')) + FileUtils.mkdir_p(source_dir("no_files_inside", "child_dir")) + FileUtils.touch(source_dir("no_files_inside", "child_dir", "index.html")) @site = fixture_site @site.process @@ -86,20 +87,20 @@ class TestCleaner < JekyllUnitTest end teardown do - FileUtils.rm_rf(source_dir('no_files_inside')) - FileUtils.rm_rf(dest_dir('no_files_inside')) + FileUtils.rm_rf(source_dir("no_files_inside")) + FileUtils.rm_rf(dest_dir("no_files_inside")) end should "keep the parent directory" do - assert_exist dest_dir('no_files_inside') + assert_exist dest_dir("no_files_inside") end should "keep the child directory" do - assert_exist dest_dir('no_files_inside', 'child_dir') + assert_exist dest_dir("no_files_inside", "child_dir") end should "keep the file" do - assert_exist source_dir('no_files_inside', 'child_dir', 'index.html') + assert_exist source_dir("no_files_inside", "child_dir", "index.html") end end end diff --git a/test/test_coffeescript.rb b/test/test_coffeescript.rb index 09c9b0a8..95c06db8 100644 --- a/test/test_coffeescript.rb +++ b/test/test_coffeescript.rb @@ -1,9 +1,9 @@ -require 'helper' +require "helper" class TestCoffeeScript < JekyllUnitTest context "converting CoffeeScript" do setup do - External.require_with_graceful_fail('jekyll-coffeescript') + External.require_with_graceful_fail("jekyll-coffeescript") @site = fixture_site @site.process @test_coffeescript_file = dest_dir("js/coffeescript.js") @@ -37,7 +37,8 @@ JS end should "write a JS file in place" do - assert_exist @test_coffeescript_file, "Can't find the converted CoffeeScript file in the dest_dir." + assert_exist @test_coffeescript_file, "Can't find the converted CoffeeScript file "\ + "in the dest_dir." end should "produce JS" do diff --git a/test/test_collections.rb b/test/test_collections.rb index 82175bc5..4c0b8379 100644 --- a/test/test_collections.rb +++ b/test/test_collections.rb @@ -1,4 +1,4 @@ -require 'helper' +require "helper" class TestCollections < JekyllUnitTest context "an evil collection" do @@ -50,7 +50,7 @@ class TestCollections < JekyllUnitTest end should "have a docs attribute" do - assert_equal @collection.to_liquid["docs"], Array.new + assert_equal @collection.to_liquid["docs"], [] end should "have a directory attribute" do @@ -68,9 +68,9 @@ class TestCollections < JekyllUnitTest should "know whether it should be written or not" do assert_equal @collection.write?, false - @collection.metadata['output'] = true + @collection.metadata["output"] = true assert_equal @collection.write?, true - @collection.metadata.delete 'output' + @collection.metadata.delete "output" end end @@ -80,8 +80,8 @@ class TestCollections < JekyllUnitTest @site.process end - should "contain only the defaul collections" do - refute_equal Hash.new, @site.collections + should "contain only the default collections" do + refute_equal @site.collections, {} refute_nil @site.collections end end @@ -113,7 +113,8 @@ class TestCollections < JekyllUnitTest @collection = @site.collections["methods"] end - should "create a Hash on Site with the label mapped to the instance of the Collection" do + should "create a Hash on Site with the label mapped to the instance of the "\ + "Collection" do assert @site.collections.is_a?(Hash) refute_nil @site.collections["methods"] assert @site.collections["methods"].is_a? Jekyll::Collection @@ -123,7 +124,7 @@ class TestCollections < JekyllUnitTest assert @site.collections["methods"].docs.is_a? Array @site.collections["methods"].docs.each do |doc| assert doc.is_a? Jekyll::Document - assert_includes %w[ + assert_includes %w( _methods/configuration.md _methods/sanitized_path.md _methods/collection/entries @@ -132,11 +133,12 @@ class TestCollections < JekyllUnitTest _methods/um_hi.md _methods/escape-+\ #%20[].md _methods/yaml_with_dots.md - ], doc.relative_path + ), doc.relative_path end end - should "not include files which start with an underscore in the base collection directory" do + should "not include files which start with an underscore in the base collection "\ + "directory" do refute_includes @collection.filtered_entries, "_do_not_read_me.md" end @@ -146,7 +148,8 @@ class TestCollections < JekyllUnitTest 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/site/_dont_include_me_either.md" + refute_includes @collection.docs.map(&:relative_path), + "_methods/site/_dont_include_me_either.md" end end @@ -165,7 +168,7 @@ class TestCollections < JekyllUnitTest end 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 @@ -184,7 +187,8 @@ class TestCollections < JekyllUnitTest refute_includes @collection.filtered_entries, "/um_hi.md" end - should "include the symlinked file in the list of docs as it resolves to inside site.source" do + should "include the symlinked file in the list of docs as it resolves to inside "\ + "site.source" do assert_includes @collection.docs.map(&:relative_path), "_methods/um_hi.md" end end @@ -215,5 +219,4 @@ class TestCollections < JekyllUnitTest assert @collection.docs.any? { |d| d.path.include?("all.dots") } end end - end diff --git a/test/test_command.rb b/test/test_command.rb index 7d1211e8..90767013 100644 --- a/test/test_command.rb +++ b/test/test_command.rb @@ -1,4 +1,4 @@ -require 'helper' +require "helper" class TestCommand < JekyllUnitTest context "when calling .add_build_options" do diff --git a/test/test_commands_serve.rb b/test/test_commands_serve.rb index 0db8bdf9..b02232b9 100644 --- a/test/test_commands_serve.rb +++ b/test/test_commands_serve.rb @@ -11,7 +11,8 @@ class TestCommandsServe < JekyllUnitTest context "with a program" do setup do - @merc, @cmd = nil, Jekyll::Commands::Serve + @merc = nil + @cmd = Jekyll::Commands::Serve Mercenary.program(:jekyll) do |p| @merc = @cmd.init_with_program( p @@ -63,7 +64,7 @@ class TestCommandsServe < JekyllUnitTest should "use user port" do # WHAT?!?!1 Over 9000? That's impossible. - assert_equal 9001, custom_opts( { "port" => 9001 })[ + assert_equal 9001, custom_opts({ "port" => 9001 })[ :Port ] end From aad587ca2f924895bd434c6c8bcc53110d9cb5be Mon Sep 17 00:00:00 2001 From: Brint O'Hearn Date: Sun, 15 May 2016 19:20:29 -0500 Subject: [PATCH 02/22] Rubocop fixes for test/helper.rb --- .rubocop.yml | 1 - test/helper.rb | 44 ++++++++++++++++++++------------------------ 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index acdd1022..fc8fcb6c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -70,7 +70,6 @@ AllCops: - features/step_definitions.rb - features/support/formatter.rb - features/support/helpers.rb - - test/helper.rb - test/simplecov_custom_profile.rb - test/test_configuration.rb - test/test_convertible.rb diff --git a/test/helper.rb b/test/helper.rb index ade8b77d..3a3dafa2 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -6,7 +6,7 @@ $stdout.puts "# -------------------------------------------------------------" $VERBOSE = nil def jruby? - defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby' + defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby" end if ENV["CI"] @@ -22,23 +22,23 @@ else end require "nokogiri" -require 'rubygems' -require 'ostruct' -require 'minitest/autorun' -require 'minitest/reporters' -require 'minitest/profile' -require 'rspec/mocks' -require 'jekyll' +require "rubygems" +require "ostruct" +require "minitest/autorun" +require "minitest/reporters" +require "minitest/profile" +require "rspec/mocks" +require "jekyll" Jekyll.logger = Logger.new(StringIO.new) unless jruby? - require 'rdiscount' - require 'redcarpet' + require "rdiscount" + require "redcarpet" end -require 'kramdown' -require 'shoulda' +require "kramdown" +require "shoulda" include Jekyll @@ -51,16 +51,12 @@ Minitest::Reporters.use! [ module Minitest::Assertions def assert_exist(filename, msg = nil) - msg = message(msg) { - "Expected '#{filename}' to exist" - } + msg = message(msg) { "Expected '#{filename}' to exist" } assert File.exist?(filename), msg end def refute_exist(filename, msg = nil) - msg = message(msg) { - "Expected '#{filename}' not to exist" - } + msg = message(msg) { "Expected '#{filename}' not to exist" } refute File.exist?(filename), msg end end @@ -69,8 +65,8 @@ class JekyllUnitTest < Minitest::Test include ::RSpec::Mocks::ExampleMethods def mocks_expect(*args) - RSpec::Mocks::ExampleMethods::ExpectHost.instance_method(:expect).\ - bind(self).call(*args) + RSpec::Mocks::ExampleMethods::ExpectHost.instance_method(:expect)\ + .bind(self).call(*args) end def before_setup @@ -105,16 +101,16 @@ class JekyllUnitTest < Minitest::Test end def dest_dir(*subdirs) - test_dir('dest', *subdirs) + test_dir("dest", *subdirs) end def source_dir(*subdirs) - test_dir('source', *subdirs) + test_dir("source", *subdirs) end def clear_dest FileUtils.rm_rf(dest_dir) - FileUtils.rm_rf(source_dir('.jekyll-metadata')) + FileUtils.rm_rf(source_dir(".jekyll-metadata")) end def test_dir(*subdirs) @@ -124,7 +120,7 @@ class JekyllUnitTest < Minitest::Test def directory_with_contents(path) FileUtils.rm_rf(path) FileUtils.mkdir(path) - File.open("#{path}/index.html", "w"){ |f| f.write("I was previously generated.") } + File.open("#{path}/index.html", "w") { |f| f.write("I was previously generated.") } end def with_env(key, value) From 5034cc377a86f884aa3466aff71ccac730193d57 Mon Sep 17 00:00:00 2001 From: Brint O'Hearn Date: Sun, 15 May 2016 19:22:52 -0500 Subject: [PATCH 03/22] Rubocop fixes for test/simplecov_custom_profile.rb --- .rubocop.yml | 1 - test/simplecov_custom_profile.rb | 14 +++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index fc8fcb6c..588e630c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -70,7 +70,6 @@ AllCops: - features/step_definitions.rb - features/support/formatter.rb - features/support/helpers.rb - - test/simplecov_custom_profile.rb - test/test_configuration.rb - test/test_convertible.rb - test/test_doctor_command.rb diff --git a/test/simplecov_custom_profile.rb b/test/simplecov_custom_profile.rb index d7f4914c..0aaec88a 100644 --- a/test/simplecov_custom_profile.rb +++ b/test/simplecov_custom_profile.rb @@ -1,10 +1,10 @@ -require 'simplecov' +require "simplecov" -SimpleCov.profiles.define 'gem' do - add_filter '/test/' - add_filter '/features/' - add_filter '/autotest/' +SimpleCov.profiles.define "gem" do + add_filter "/test/" + add_filter "/features/" + add_filter "/autotest/" - add_group 'Binaries', '/bin/' - add_group 'Libraries', '/lib/' + add_group "Binaries", "/bin/" + add_group "Libraries", "/lib/" end From 454a1e415cd822d02922f7c70afe736c5aec9907 Mon Sep 17 00:00:00 2001 From: Brint O'Hearn Date: Sun, 15 May 2016 19:36:00 -0500 Subject: [PATCH 04/22] Rubocop fixes for test/test_convertible.rb --- .rubocop.yml | 1 - test/test_convertible.rb | 28 ++++++++++++++-------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 588e630c..b6e5b25a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -71,7 +71,6 @@ AllCops: - features/support/formatter.rb - features/support/helpers.rb - test/test_configuration.rb - - test/test_convertible.rb - test/test_doctor_command.rb - test/test_document.rb - test/test_entry_filter.rb diff --git a/test/test_convertible.rb b/test/test_convertible.rb index 517f5c3b..4509ed36 100644 --- a/test/test_convertible.rb +++ b/test/test_convertible.rb @@ -1,30 +1,30 @@ -require 'helper' -require 'ostruct' +require "helper" +require "ostruct" class TestConvertible < JekyllUnitTest context "yaml front-matter" do setup do @convertible = OpenStruct.new( "site" => Site.new(Jekyll.configuration( - "source" => File.expand_path('../fixtures', __FILE__) + "source" => File.expand_path("../fixtures", __FILE__) )) ) @convertible.extend Jekyll::Convertible - @base = File.expand_path('../fixtures', __FILE__) + @base = File.expand_path("../fixtures", __FILE__) end should "parse the front-matter correctly" do - ret = @convertible.read_yaml(@base, 'front_matter.erb') - assert_equal({'test' => 'good'}, ret) + ret = @convertible.read_yaml(@base, "front_matter.erb") + assert_equal({ "test" => "good" }, ret) end should "not parse if the front-matter is not at the start of the file" do - ret = @convertible.read_yaml(@base, 'broken_front_matter1.erb') + ret = @convertible.read_yaml(@base, "broken_front_matter1.erb") assert_equal({}, ret) end should "not parse if there is syntax error in front-matter" do - name = 'broken_front_matter2.erb' + name = "broken_front_matter2.erb" out = capture_stderr do ret = @convertible.read_yaml(@base, name) assert_equal({}, ret) @@ -35,15 +35,15 @@ class TestConvertible < JekyllUnitTest should "not allow ruby objects in yaml" do out = capture_stderr do - @convertible.read_yaml(@base, 'exploit_front_matter.erb') + @convertible.read_yaml(@base, "exploit_front_matter.erb") end - refute_match(/undefined class\/module DoesNotExist/, out) + refute_match(%r!undefined class\/module DoesNotExist!, out) end should "not parse if there is encoding error in file" do - name = 'broken_front_matter3.erb' + name = "broken_front_matter3.erb" out = capture_stderr do - ret = @convertible.read_yaml(@base, name, :encoding => 'utf-8') + ret = @convertible.read_yaml(@base, name, :encoding => "utf-8") assert_equal({}, ret) end assert_match(/invalid byte sequence in UTF-8/, out) @@ -51,7 +51,7 @@ class TestConvertible < JekyllUnitTest end should "parse the front-matter but show an error if permalink is empty" do - name = 'empty_permalink.erb' + name = "empty_permalink.erb" assert_raises(Errors::InvalidPermalinkError) do @convertible.read_yaml(@base, name) end @@ -59,7 +59,7 @@ class TestConvertible < JekyllUnitTest should "parse the front-matter correctly whitout permalink" do out = capture_stderr do - @convertible.read_yaml(@base, 'front_matter.erb') + @convertible.read_yaml(@base, "front_matter.erb") end refute_match(/Invalid permalink/, out) end From cfe6cf7ca1874488d15b88cbd5a2ea5d1a7855f8 Mon Sep 17 00:00:00 2001 From: Brint O'Hearn Date: Sun, 15 May 2016 20:54:54 -0500 Subject: [PATCH 05/22] Rubocop fixes for test/test_doctor_command.rb --- .rubocop.yml | 1 - test/test_doctor_command.rb | 26 ++++++++++++++------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index b6e5b25a..d14330d5 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -71,7 +71,6 @@ AllCops: - features/support/formatter.rb - features/support/helpers.rb - test/test_configuration.rb - - test/test_doctor_command.rb - test/test_document.rb - test/test_entry_filter.rb - test/test_excerpt.rb diff --git a/test/test_doctor_command.rb b/test/test_doctor_command.rb index dee50ac2..aa6cf125 100644 --- a/test/test_doctor_command.rb +++ b/test/test_doctor_command.rb @@ -1,36 +1,38 @@ -require 'helper' -require 'jekyll/commands/doctor' +require "helper" +require "jekyll/commands/doctor" class TestDoctorCommand < JekyllUnitTest - context 'urls only differ by case' do + context "urls only differ by case" do setup do clear_dest end - should 'return success on a valid site/page' do + should "return success on a valid site/page" do @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 })) @site.process output = capture_stderr do - ret = Jekyll::Commands::Doctor.urls_only_differ_by_case(@site) - assert_equal false, ret + ret = Jekyll::Commands::Doctor.urls_only_differ_by_case(@site) + assert_equal false, ret end assert_equal "", output 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({ - "source" => File.join(source_dir, '/_urls_differ_by_case_invalid'), + "source" => File.join(source_dir, "/_urls_differ_by_case_invalid"), "destination" => dest_dir })) @site.process output = capture_stderr do - ret = Jekyll::Commands::Doctor.urls_only_differ_by_case(@site) - assert_equal true, ret + ret = Jekyll::Commands::Doctor.urls_only_differ_by_case(@site) + assert_equal true, ret end - assert_includes output, "Warning: The following URLs only differ by case. On a case-insensitive file system one of the URLs will be overwritten by the other: #{dest_dir}/about/index.html, #{dest_dir}/About/index.html" + assert_includes output, "Warning: The following URLs only differ by case. "\ + "On a case-insensitive file system one of the URLs will be overwritten by the "\ + "other: #{dest_dir}/about/index.html, #{dest_dir}/About/index.html" end end end From c8cae38da6d8fbbc5d6e085904088032e2ebec8a Mon Sep 17 00:00:00 2001 From: Brint O'Hearn Date: Sun, 15 May 2016 21:59:00 -0500 Subject: [PATCH 06/22] Rubocop fixes for test/test_excerpt.rb --- .rubocop.yml | 1 - test/test_excerpt.rb | 37 ++++++++++++++++++++----------------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index d14330d5..5195d933 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -73,7 +73,6 @@ AllCops: - test/test_configuration.rb - test/test_document.rb - test/test_entry_filter.rb - - test/test_excerpt.rb - test/test_filters.rb - test/test_front_matter_defaults.rb - test/test_generated_site.rb diff --git a/test/test_excerpt.rb b/test/test_excerpt.rb index 61ffded3..23144313 100644 --- a/test/test_excerpt.rb +++ b/test/test_excerpt.rb @@ -1,22 +1,23 @@ -require 'helper' +require "helper" class TestExcerpt < JekyllUnitTest def setup_post(file) - Document.new(@site.in_source_dir(File.join('_posts', file)), { - site: @site, - collection: @site.posts + Document.new(@site.in_source_dir(File.join("_posts", file)), { + :site => @site, + :collection => @site.posts }).tap(&:read) end def do_render(document) - @site.layouts = { "default" => Layout.new(@site, source_dir('_layouts'), "simple.html")} + @site.layouts = { "default" => Layout.new(@site, source_dir("_layouts"), + "simple.html") } document.output = Jekyll::Renderer.new(@site, document, @site.site_payload).run end context "With extraction disabled" do setup do clear_dest - @site = fixture_site('excerpt_separator' => '') + @site = fixture_site("excerpt_separator" => "") @post = setup_post("2013-07-22-post-excerpt-with-layout.markdown") end @@ -30,11 +31,10 @@ class TestExcerpt < JekyllUnitTest clear_dest @site = fixture_site @post = setup_post("2013-07-22-post-excerpt-with-layout.markdown") - @excerpt = @post.data['excerpt'] + @excerpt = @post.data["excerpt"] end context "#include(string)" do - setup do @excerpt.output = "Here is a fake output stub" end @@ -78,19 +78,21 @@ class TestExcerpt < JekyllUnitTest context "#to_liquid" do should "contain the proper page data to mimick the post liquid" do assert_equal "Post Excerpt with Layout", @excerpt.to_liquid["title"] - assert_equal "/bar/baz/z_category/mixedcase/2013/07/22/post-excerpt-with-layout.html", @excerpt.to_liquid["url"] + assert_equal "/bar/baz/z_category/mixedcase/2013/07/22/"\ + "post-excerpt-with-layout.html", @excerpt.to_liquid["url"] assert_equal Time.parse("2013-07-22"), @excerpt.to_liquid["date"] - assert_equal %w[bar baz z_category MixedCase], @excerpt.to_liquid["categories"] - assert_equal %w[first second third jekyllrb.com], @excerpt.to_liquid["tags"] - assert_equal "_posts/2013-07-22-post-excerpt-with-layout.markdown", @excerpt.to_liquid["path"] + assert_equal %w(bar baz z_category MixedCase), @excerpt.to_liquid["categories"] + assert_equal %w(first second third jekyllrb.com), @excerpt.to_liquid["tags"] + assert_equal "_posts/2013-07-22-post-excerpt-with-layout.markdown", + @excerpt.to_liquid["path"] end end context "#content" do - context "before render" do should "be the first paragraph of the page" do - assert_equal "First paragraph with [link ref][link].\n\n[link]: http://www.jekyllrb.com/", @excerpt.content + assert_equal "First paragraph with [link ref][link].\n\n[link]:"\ + " http://www.jekyllrb.com/", @excerpt.content end should "contain any refs at the bottom of the page" do @@ -102,11 +104,12 @@ class TestExcerpt < JekyllUnitTest setup do @rendered_post = @post.dup do_render(@rendered_post) - @extracted_excerpt = @rendered_post.data['excerpt'] + @extracted_excerpt = @rendered_post.data["excerpt"] end should "be the first paragraph of the page" do - assert_equal "

First paragraph with link ref.

\n\n", @extracted_excerpt.output + assert_equal "

First paragraph with "\ + "link ref.

\n\n", @extracted_excerpt.output end should "link properly" do @@ -121,7 +124,7 @@ class TestExcerpt < JekyllUnitTest clear_dest @site = fixture_site @post = setup_post("2008-02-02-published.markdown") - @excerpt = @post.data['excerpt'] + @excerpt = @post.data["excerpt"] end should "be generated" do From 555b2fbe72a2bbcba173205f465ad287dc44114c Mon Sep 17 00:00:00 2001 From: Brint O'Hearn Date: Sun, 15 May 2016 22:05:28 -0500 Subject: [PATCH 07/22] Rubocop fixes for test/test_front_matter_defaults.rb --- .rubocop.yml | 1 - test/test_front_matter_defaults.rb | 12 ++++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 5195d933..4a1b4fea 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -74,7 +74,6 @@ AllCops: - test/test_document.rb - test/test_entry_filter.rb - test/test_filters.rb - - test/test_front_matter_defaults.rb - test/test_generated_site.rb - test/test_kramdown.rb - test/test_layout_reader.rb diff --git a/test/test_front_matter_defaults.rb b/test/test_front_matter_defaults.rb index 8eeed7f3..4be4ce2f 100644 --- a/test/test_front_matter_defaults.rb +++ b/test/test_front_matter_defaults.rb @@ -1,7 +1,6 @@ -require 'helper' +require "helper" class TestFrontMatterDefaults < JekyllUnitTest - context "A site with full front matter defaults" do setup do @site = Site.new(Jekyll.configuration({ @@ -69,7 +68,7 @@ class TestFrontMatterDefaults < JekyllUnitTest }] })) @site.process - @affected = @site.posts.docs.find { |page| page.relative_path =~ /win\// } + @affected = @site.posts.docs.find { |page| page.relative_path =~ %r!win\/! } @not_affected = @site.pages.find { |page| page.relative_path == "about.html" } end @@ -100,7 +99,8 @@ class TestFrontMatterDefaults < JekyllUnitTest should "affect only the specified type and all paths" do assert_equal @affected.reject { |page| page.data["key"] == "val" }, [] - assert_equal @not_affected.reject { |page| page.data["key"] == "val" }, @not_affected + assert_equal @not_affected.reject { |page| page.data["key"] == "val" }, + @not_affected end end @@ -125,7 +125,8 @@ class TestFrontMatterDefaults < JekyllUnitTest should "affect only the specified type and all paths" do assert_equal @affected.reject { |page| page.data["key"] == "val" }, [] - assert_equal @not_affected.reject { |page| page.data["key"] == "val" }, @not_affected + assert_equal @not_affected.reject { |page| page.data["key"] == "val" }, + @not_affected end end @@ -199,5 +200,4 @@ class TestFrontMatterDefaults < JekyllUnitTest assert @site.posts.find { |page| page.data["date"] == date } end end - end From 0635bbba0602a4f674ba7fc9fb9ec93923935912 Mon Sep 17 00:00:00 2001 From: Brint O'Hearn Date: Sun, 15 May 2016 22:14:17 -0500 Subject: [PATCH 08/22] Rubocop fixes for test/test_generated_site.rb --- .rubocop.yml | 1 - test/test_generated_site.rb | 45 ++++++++++++++++++++----------------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 4a1b4fea..bb0f2381 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -74,7 +74,6 @@ AllCops: - test/test_document.rb - test/test_entry_filter.rb - test/test_filters.rb - - test/test_generated_site.rb - test/test_kramdown.rb - test/test_layout_reader.rb - test/test_liquid_extensions.rb diff --git a/test/test_generated_site.rb b/test/test_generated_site.rb index 301cd8f8..46374862 100644 --- a/test/test_generated_site.rb +++ b/test/test_generated_site.rb @@ -1,14 +1,15 @@ -require 'helper' +require "helper" class TestGeneratedSite < JekyllUnitTest context "generated sites" do setup do clear_dest - config = Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir}) + config = Jekyll::Configuration::DEFAULTS.merge({ "source" => source_dir, + "destination" => dest_dir }) @site = fixture_site(config) @site.process - @index = File.read(dest_dir('index.html')) + @index = File.read(dest_dir("index.html")) end should "ensure post count is as expected" do @@ -24,29 +25,29 @@ class TestGeneratedSite < JekyllUnitTest end should "hide unpublished posts" do - published = Dir[dest_dir('publish_test/2008/02/02/*.html')].map {|f| File.basename(f)} - + published = Dir[dest_dir("publish_test/2008/02/02/*.html")].map \ + { |f| File.basename(f) } assert_equal 1, published.size assert_equal "published.html", published.first end should "hide unpublished page" do - refute_exist dest_dir('/unpublished.html') + refute_exist dest_dir("/unpublished.html") end should "not copy _posts directory" do - refute_exist dest_dir('_posts') + refute_exist dest_dir("_posts") end should "process a page with a folder permalink properly" do - about = @site.pages.find {|page| page.name == 'about.html' } - assert_equal dest_dir('about', 'index.html'), about.destination(dest_dir) - assert_exist dest_dir('about', 'index.html') + about = @site.pages.find { |page| page.name == "about.html" } + assert_equal dest_dir("about", "index.html"), about.destination(dest_dir) + assert_exist dest_dir("about", "index.html") end should "process other static files and generate correct permalinks" do - assert_exist dest_dir('contacts.html') - assert_exist dest_dir('dynamic_file.php') + assert_exist dest_dir("contacts.html") + assert_exist dest_dir("dynamic_file.php") end should "print a nice list of static files" do @@ -57,17 +58,19 @@ class TestGeneratedSite < JekyllUnitTest - /products.yml last edited at #{time_regexp} with extname .yml - /symlink-test/symlinked-dir/screen.css last edited at #{time_regexp} with extname .css OUTPUT - assert_match expected_output, File.read(dest_dir('static_files.html')) + assert_match expected_output, File.read(dest_dir("static_files.html")) end end context "generating limited posts" do setup do clear_dest - config = Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir, 'limit_posts' => 5}) + config = Jekyll::Configuration::DEFAULTS.merge({ "source" => source_dir, + "destination" => dest_dir, + "limit_posts" => 5 }) @site = fixture_site(config) @site.process - @index = File.read(dest_dir('index.html')) + @index = File.read(dest_dir("index.html")) end should "generate only the specified number of posts" do @@ -78,9 +81,9 @@ OUTPUT assert_raises ArgumentError do clear_dest config = Jekyll::Configuration::DEFAULTS.merge({ - 'source' => source_dir, - 'destination' => dest_dir, - 'limit_posts' => -1 + "source" => source_dir, + "destination" => dest_dir, + "limit_posts" => -1 }) @site = fixture_site(config) end @@ -89,9 +92,9 @@ OUTPUT should "acceptable limit post is 0" do clear_dest config = Jekyll::Configuration::DEFAULTS.merge({ - 'source' => source_dir, - 'destination' => dest_dir, - 'limit_posts' => 0 + "source" => source_dir, + "destination" => dest_dir, + "limit_posts" => 0 }) assert Site.new(config), "Couldn't create a site with the given limit_posts." From 271a8aebfb80c18bc02869c11840a57ae38ab78c Mon Sep 17 00:00:00 2001 From: Brint O'Hearn Date: Sun, 15 May 2016 22:47:38 -0500 Subject: [PATCH 09/22] Rubocop fixes for test/test_layout_reader.rb --- .rubocop.yml | 1 - test/test_layout_reader.rb | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index bb0f2381..bd088278 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -75,7 +75,6 @@ AllCops: - test/test_entry_filter.rb - test/test_filters.rb - test/test_kramdown.rb - - test/test_layout_reader.rb - test/test_liquid_extensions.rb - test/test_liquid_renderer.rb - test/test_log_adapter.rb diff --git a/test/test_layout_reader.rb b/test/test_layout_reader.rb index 11acdb31..dabe29c0 100644 --- a/test/test_layout_reader.rb +++ b/test/test_layout_reader.rb @@ -1,9 +1,10 @@ -require 'helper' +require "helper" class TestLayoutReader < JekyllUnitTest context "reading layouts" do setup do - config = Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir}) + config = Jekyll::Configuration::DEFAULTS.merge({ "source" => source_dir, + "destination" => dest_dir }) @site = fixture_site(config) end From 5a1a8c9c82adad67137a7787bb0ac365e7369aec Mon Sep 17 00:00:00 2001 From: Brint O'Hearn Date: Sun, 15 May 2016 22:58:06 -0500 Subject: [PATCH 10/22] Rubocop fixes for test/test_liquid_extensions.rb --- .rubocop.yml | 1 - test/test_liquid_extensions.rb | 15 +++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index bd088278..66b68f47 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -75,7 +75,6 @@ AllCops: - test/test_entry_filter.rb - test/test_filters.rb - test/test_kramdown.rb - - test/test_liquid_extensions.rb - test/test_liquid_renderer.rb - test/test_log_adapter.rb - test/test_new_command.rb diff --git a/test/test_liquid_extensions.rb b/test/test_liquid_extensions.rb index 0ab95e94..a76f3786 100644 --- a/test/test_liquid_extensions.rb +++ b/test/test_liquid_extensions.rb @@ -1,12 +1,11 @@ -require 'helper' +require "helper" class TestLiquidExtensions < JekyllUnitTest - context "looking up a variable in a Liquid context" do class SayHi < Liquid::Tag include Jekyll::LiquidExtensions - def initialize(tag_name, markup, tokens) + def initialize(_tag_name, markup, _tokens) @markup = markup.strip end @@ -14,18 +13,18 @@ class TestLiquidExtensions < JekyllUnitTest "hi #{lookup_variable(context, @markup)}" end end - Liquid::Template.register_tag('say_hi', SayHi) + Liquid::Template.register_tag("say_hi", SayHi) setup do - @template = Liquid::Template.parse("{% say_hi page.name %}") # Parses and compiles the template + # Parses and compiles the template + @template = Liquid::Template.parse("{% say_hi page.name %}") end 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 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 From ad988838435de085cd90ca3a8ff285a74ef5eee2 Mon Sep 17 00:00:00 2001 From: Brint O'Hearn Date: Sun, 15 May 2016 23:16:28 -0500 Subject: [PATCH 11/22] Rubocop fixes for test/test_log_adapter.rb --- .rubocop.yml | 1 - test/test_log_adapter.rb | 31 +++++++++++++++++++------------ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 66b68f47..e8b11102 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -76,7 +76,6 @@ AllCops: - test/test_filters.rb - test/test_kramdown.rb - test/test_liquid_renderer.rb - - test/test_log_adapter.rb - test/test_new_command.rb - test/test_page.rb - test/test_path_sanitization.rb diff --git a/test/test_log_adapter.rb b/test/test_log_adapter.rb index 0160d821..f34be99d 100644 --- a/test/test_log_adapter.rb +++ b/test/test_log_adapter.rb @@ -1,12 +1,15 @@ -require 'helper' +require "helper" class TestLogAdapter < JekyllUnitTest class LoggerDouble attr_accessor :level def debug(*); end + def info(*); end + def warn(*); end + def error(*); end end @@ -58,8 +61,9 @@ class TestLogAdapter < JekyllUnitTest should "call #debug on writer return true" do writer = LoggerDouble.new logger = Jekyll::LogAdapter.new(writer) - allow(writer).to receive(:debug).with('topic '.rjust(20) + 'log message').and_return(true) - assert logger.debug('topic', 'log message') + allow(writer).to receive(:debug).with("topic ".rjust(20) + + "log message").and_return(true) + assert logger.debug("topic", "log message") end end @@ -67,8 +71,9 @@ class TestLogAdapter < JekyllUnitTest should "call #info on writer return true" do writer = LoggerDouble.new logger = Jekyll::LogAdapter.new(writer) - allow(writer).to receive(:info).with('topic '.rjust(20) + 'log message').and_return(true) - assert logger.info('topic', 'log message') + allow(writer).to receive(:info).with("topic ".rjust(20) + + "log message").and_return(true) + assert logger.info("topic", "log message") end end @@ -76,8 +81,9 @@ class TestLogAdapter < JekyllUnitTest should "call #warn on writer return true" do writer = LoggerDouble.new logger = Jekyll::LogAdapter.new(writer) - allow(writer).to receive(:warn).with('topic '.rjust(20) + 'log message').and_return(true) - assert logger.warn('topic', 'log message') + allow(writer).to receive(:warn).with("topic ".rjust(20) + + "log message").and_return(true) + assert logger.warn("topic", "log message") end end @@ -85,16 +91,17 @@ class TestLogAdapter < JekyllUnitTest should "call #error on writer return true" do writer = LoggerDouble.new logger = Jekyll::LogAdapter.new(writer) - allow(writer).to receive(:error).with('topic '.rjust(20) + 'log message').and_return(true) - assert logger.error('topic', 'log message') + allow(writer).to receive(:error).with("topic ".rjust(20) + + "log message").and_return(true) + assert logger.error("topic", "log message") end end context "#abort_with" do should "call #error and abort" do logger = Jekyll::LogAdapter.new(LoggerDouble.new) - allow(logger).to receive(:error).with('topic', 'log message').and_return(true) - assert_raises(SystemExit) { logger.abort_with('topic', 'log message') } + allow(logger).to receive(:error).with("topic", "log message").and_return(true) + assert_raises(SystemExit) { logger.abort_with("topic", "log message") } end end @@ -105,7 +112,7 @@ class TestLogAdapter < JekyllUnitTest should "store each log value in the array" do logger = Jekyll::LogAdapter.new(LoggerDouble.new) - values = %w{one two three four} + values = %w(one two three four) logger.debug(values[0]) logger.info(values[1]) logger.warn(values[2]) From c76b458dd5cdb8162edfefe23775699c475210f8 Mon Sep 17 00:00:00 2001 From: Brint O'Hearn Date: Sun, 15 May 2016 23:20:48 -0500 Subject: [PATCH 12/22] Rubocop fixes for test/test_new_command.rb --- .rubocop.yml | 1 - test/test_new_command.rb | 54 ++++++++++++++++++++-------------------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index e8b11102..e63fa50b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -76,7 +76,6 @@ AllCops: - test/test_filters.rb - test/test_kramdown.rb - test/test_liquid_renderer.rb - - test/test_new_command.rb - test/test_page.rb - test/test_path_sanitization.rb - test/test_plugin_manager.rb diff --git a/test/test_new_command.rb b/test/test_new_command.rb index 451b525d..e0209400 100644 --- a/test/test_new_command.rb +++ b/test/test_new_command.rb @@ -1,10 +1,10 @@ -require 'helper' -require 'jekyll/commands/new' +require "helper" +require "jekyll/commands/new" class TestNewCommand < JekyllUnitTest def dir_contents(path) Dir["#{path}/**/*"].each do |file| - file.gsub! path, '' + file.gsub! path, "" end end @@ -12,9 +12,9 @@ class TestNewCommand < JekyllUnitTest File.expand_path("../lib/site_template", File.dirname(__FILE__)) end - context 'when args contains a path' do + context "when args contains a path" do setup do - @path = 'new-site' + @path = "new-site" @args = [@path] @full_path = File.expand_path(@path, Dir.pwd) end @@ -23,7 +23,7 @@ class TestNewCommand < JekyllUnitTest FileUtils.rm_r @full_path end - should 'create a new directory' do + should "create a new directory" do refute_exist @full_path Jekyll::Commands::New.process(@args) assert_exist @full_path @@ -34,43 +34,43 @@ class TestNewCommand < JekyllUnitTest refute_exist @full_path capture_stdout { Jekyll::Commands::New.process(@args) } assert_exist gemfile - assert_match /gem "jekyll", "#{Jekyll::VERSION}"/, File.read(gemfile) - assert_match /gem "github-pages"/, File.read(gemfile) + assert_match(/gem "jekyll", "#{Jekyll::VERSION}"/, File.read(gemfile)) + assert_match(/gem "github-pages"/, File.read(gemfile)) end - should 'display a success message' do + should "display a success message" do Jekyll::Commands::New.process(@args) output = Jekyll.logger.messages.last success_message = "New jekyll site installed in #{@full_path}." assert_includes output, success_message end - should 'copy the static files in site template to the new directory' do + should "copy the static files in site template to the new directory" do static_template_files = dir_contents(site_template).reject do |f| - File.extname(f) == '.erb' + File.extname(f) == ".erb" end static_template_files << "/Gemfile" capture_stdout { Jekyll::Commands::New.process(@args) } new_site_files = dir_contents(@full_path).reject do |f| - File.extname(f) == '.markdown' + File.extname(f) == ".markdown" end assert_same_elements static_template_files, new_site_files end - should 'process any ERB files' do + should "process any ERB files" do erb_template_files = dir_contents(site_template).select do |f| - File.extname(f) == '.erb' + File.extname(f) == ".erb" end - stubbed_date = '2013-01-01' + stubbed_date = "2013-01-01" allow_any_instance_of(Time).to receive(:strftime) { stubbed_date } erb_template_files.each do |f| - f.chomp! '.erb' - f.gsub! '0000-00-00', stubbed_date + f.chomp! ".erb" + f.gsub! "0000-00-00", stubbed_date end capture_stdout { Jekyll::Commands::New.process(@args) } @@ -82,22 +82,22 @@ class TestNewCommand < JekyllUnitTest assert_same_elements erb_template_files, new_site_files end - should 'create blank project' do + should "create blank project" do blank_contents = %w(/_drafts /_layouts /_posts /index.html) - capture_stdout { Jekyll::Commands::New.process(@args, '--blank') } + capture_stdout { Jekyll::Commands::New.process(@args, "--blank") } assert_same_elements blank_contents, dir_contents(@full_path) end - should 'force created folder' do + should "force created folder" do capture_stdout { Jekyll::Commands::New.process(@args) } - output = capture_stdout { Jekyll::Commands::New.process(@args, '--force') } + output = capture_stdout { Jekyll::Commands::New.process(@args, "--force") } assert_match(/New jekyll site installed in/, output) end end - context 'when multiple args are given' do + context "when multiple args are given" do setup do - @site_name_with_spaces = 'new site name' + @site_name_with_spaces = "new site name" @multiple_args = @site_name_with_spaces.split end @@ -105,23 +105,23 @@ class TestNewCommand < JekyllUnitTest FileUtils.rm_r File.expand_path(@site_name_with_spaces, Dir.pwd) end - should 'create a new directory' do + should "create a new directory" do refute_exist @site_name_with_spaces capture_stdout { Jekyll::Commands::New.process(@multiple_args) } assert_exist @site_name_with_spaces end end - context 'when no args are given' do + context "when no args are given" do setup do @empty_args = [] end - should 'raise an ArgumentError' do + should "raise an ArgumentError" do exception = assert_raises ArgumentError do Jekyll::Commands::New.process(@empty_args) end - assert_equal 'You must specify a path.', exception.message + assert_equal "You must specify a path.", exception.message end end end From df01b6825e731a357f7d5886be615a9b67c3c2c3 Mon Sep 17 00:00:00 2001 From: Brint O'Hearn Date: Sun, 15 May 2016 23:25:40 -0500 Subject: [PATCH 13/22] Rubocop fixes for test/test_path_sanitization.rb --- .rubocop.yml | 1 - test/test_path_sanitization.rb | 14 +++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index e63fa50b..36819553 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -77,7 +77,6 @@ AllCops: - test/test_kramdown.rb - test/test_liquid_renderer.rb - test/test_page.rb - - test/test_path_sanitization.rb - test/test_plugin_manager.rb - test/test_rdiscount.rb - test/test_redcarpet.rb diff --git a/test/test_path_sanitization.rb b/test/test_path_sanitization.rb index 148103ea..df7ef172 100644 --- a/test/test_path_sanitization.rb +++ b/test/test_path_sanitization.rb @@ -1,4 +1,4 @@ -require 'helper' +require "helper" class TestPathSanitization < JekyllUnitTest context "on Windows with absolute source" do @@ -8,20 +8,24 @@ class TestPathSanitization < JekyllUnitTest allow(Dir).to receive(:pwd).and_return("C:/Users/xmr/Desktop/mpc-hc.org") end should "strip drive name from path" do - assert_equal "C:/Users/xmr/Desktop/mpc-hc.org/_site", Jekyll.sanitized_path(@source, @dest) + assert_equal "C:/Users/xmr/Desktop/mpc-hc.org/_site", + Jekyll.sanitized_path(@source, @dest) end should "strip just the initial drive name" do - assert_equal "/tmp/foobar/jail/..c:/..c:/..c:/etc/passwd", Jekyll.sanitized_path("/tmp/foobar/jail", "..c:/..c:/..c:/etc/passwd") + assert_equal "/tmp/foobar/jail/..c:/..c:/..c:/etc/passwd", + Jekyll.sanitized_path("/tmp/foobar/jail", "..c:/..c:/..c:/etc/passwd") end end should "escape tilde" do assert_equal source_dir("~hi.txt"), Jekyll.sanitized_path(source_dir, "~hi.txt") - assert_equal source_dir("files", "~hi.txt"), Jekyll.sanitized_path(source_dir, "files/../files/~hi.txt") + assert_equal source_dir("files", "~hi.txt"), + Jekyll.sanitized_path(source_dir, "files/../files/~hi.txt") end should "remove path traversals" do - assert_equal source_dir("files", "hi.txt"), Jekyll.sanitized_path(source_dir, "f./../../../../../../files/hi.txt") + assert_equal source_dir("files", "hi.txt"), + Jekyll.sanitized_path(source_dir, "f./../../../../../../files/hi.txt") end end From df7992c62601f5514b13f446799a2ec8afa82481 Mon Sep 17 00:00:00 2001 From: Brint O'Hearn Date: Sun, 15 May 2016 23:31:08 -0500 Subject: [PATCH 14/22] Rubocop fixes for test/test_plugin_manager.rb --- .rubocop.yml | 1 - test/test_plugin_manager.rb | 13 ++++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 36819553..4fb11302 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -77,7 +77,6 @@ AllCops: - test/test_kramdown.rb - test/test_liquid_renderer.rb - test/test_page.rb - - test/test_plugin_manager.rb - test/test_rdiscount.rb - test/test_redcarpet.rb - test/test_regenerator.rb diff --git a/test/test_plugin_manager.rb b/test/test_plugin_manager.rb index 9cdb45d8..22ad617f 100644 --- a/test/test_plugin_manager.rb +++ b/test/test_plugin_manager.rb @@ -1,4 +1,4 @@ -require 'helper' +require "helper" class TestPluginManager < JekyllUnitTest def with_no_gemfile @@ -10,14 +10,16 @@ class TestPluginManager < JekyllUnitTest def test_requiring_from_bundler with_env("JEKYLL_NO_BUNDLER_REQUIRE", nil) do - assert Jekyll::PluginManager.require_from_bundler, 'require_from_bundler should return true.' - assert ENV["JEKYLL_NO_BUNDLER_REQUIRE"], 'Gemfile plugins were not required.' + assert Jekyll::PluginManager.require_from_bundler, + "require_from_bundler should return true." + assert ENV["JEKYLL_NO_BUNDLER_REQUIRE"], "Gemfile plugins were not required." end end def test_blocking_requiring_from_bundler with_env("JEKYLL_NO_BUNDLER_REQUIRE", "true") do - assert_equal false, Jekyll::PluginManager.require_from_bundler, "Gemfile plugins were required but shouldn't have been" + assert_equal false, Jekyll::PluginManager.require_from_bundler, + "Gemfile plugins were required but shouldn't have been" assert ENV["JEKYLL_NO_BUNDLER_REQUIRE"] end end @@ -25,7 +27,8 @@ class TestPluginManager < JekyllUnitTest def test_no_gemfile with_env("JEKYLL_NO_BUNDLER_REQUIRE", nil) do with_no_gemfile do - assert_equal false, Jekyll::PluginManager.require_from_bundler, "Gemfile plugins were required but shouldn't have been" + assert_equal false, Jekyll::PluginManager.require_from_bundler, + "Gemfile plugins were required but shouldn't have been" assert_nil ENV["JEKYLL_NO_BUNDLER_REQUIRE"] end end From de5d773a6abde68e451ed4adc7965f2b17cd3fc7 Mon Sep 17 00:00:00 2001 From: Brint O'Hearn Date: Sun, 15 May 2016 23:36:47 -0500 Subject: [PATCH 15/22] Rubocop fixes for test/test_rdiscount.rb --- .rubocop.yml | 1 - test/test_rdiscount.rb | 16 +++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 4fb11302..fcb1726e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -77,7 +77,6 @@ AllCops: - test/test_kramdown.rb - test/test_liquid_renderer.rb - test/test_page.rb - - test/test_rdiscount.rb - test/test_redcarpet.rb - test/test_regenerator.rb - test/test_related_posts.rb diff --git a/test/test_rdiscount.rb b/test/test_rdiscount.rb index 96446404..889f9659 100644 --- a/test/test_rdiscount.rb +++ b/test/test_rdiscount.rb @@ -1,7 +1,6 @@ -require 'helper' +require "helper" class TestRdiscount < JekyllUnitTest - context "rdiscount" do setup do if jruby? @@ -11,12 +10,10 @@ class TestRdiscount < JekyllUnitTest end config = { - 'markdown' => 'rdiscount', - 'rdiscount' => { - 'toc_token' => '{:toc}', - 'extensions' => [ - 'smart', 'generate_toc' - ], + "markdown" => "rdiscount", + "rdiscount" => { + "toc_token" => "{:toc}", + "extensions" => %w(smart generate_toc) } } @@ -45,7 +42,8 @@ class TestRdiscount < JekyllUnitTest

TOC - assert_equal toc.strip, @markdown.convert("# Header 1\n\n## Header 2\n\n{:toc}").strip + assert_equal toc.strip, + @markdown.convert("# Header 1\n\n## Header 2\n\n{:toc}").strip end end end From 6ef54393c2b180fdfaf9842b54fcc7c676c7e33f Mon Sep 17 00:00:00 2001 From: Brint O'Hearn Date: Sun, 15 May 2016 23:46:44 -0500 Subject: [PATCH 16/22] Rubocop fixes for test/test_redcarpet.rb --- .rubocop.yml | 1 - test/test_redcarpet.rb | 54 +++++++++++++++++++++++++----------------- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index fcb1726e..ac3c8300 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -77,7 +77,6 @@ AllCops: - test/test_kramdown.rb - test/test_liquid_renderer.rb - test/test_page.rb - - test/test_redcarpet.rb - test/test_regenerator.rb - test/test_related_posts.rb - test/test_sass.rb diff --git a/test/test_redcarpet.rb b/test/test_redcarpet.rb index 528bc8a3..7231cff9 100644 --- a/test/test_redcarpet.rb +++ b/test/test_redcarpet.rb @@ -1,4 +1,4 @@ -require 'helper' +require "helper" class TestRedcarpet < JekyllUnitTest context "redcarpet" do @@ -10,11 +10,9 @@ class TestRedcarpet < JekyllUnitTest end @config = { - 'markdown' => 'redcarpet', - 'redcarpet' => { - 'extensions' => [ - 'smart', 'strikethrough', 'filter_html' - ] + "markdown" => "redcarpet", + "redcarpet" => { + "extensions" => %w(smart strikethrough filter_html) } } @@ -22,7 +20,7 @@ class TestRedcarpet < JekyllUnitTest end should "pass redcarpet options" do - assert_equal "

Some Header

", @markdown.convert('# Some Header #').strip + assert_equal "

Some Header

", @markdown.convert("# Some Header #").strip end should "pass redcarpet SmartyPants options" do @@ -30,58 +28,70 @@ class TestRedcarpet < JekyllUnitTest end should "pass redcarpet extensions" do - assert_equal "

deleted

", @markdown.convert('~~deleted~~').strip + assert_equal "

deleted

", @markdown.convert("~~deleted~~").strip end should "pass redcarpet render options" do - assert_equal "

bad code not here: i am bad

", @markdown.convert('**bad code not here**: ').strip + assert_equal "

bad code not here: i am bad

", + @markdown.convert("**bad code not here**: ").strip end context "with pygments enabled" do setup do - @markdown = Converters::Markdown.new @config.merge({ 'highlighter' => 'pygments' }) + @markdown = Converters::Markdown.new @config.merge( + { "highlighter" => "pygments" } + ) end should "render fenced code blocks with syntax highlighting" do - assert_equal "
puts "Hello world"\n
", @markdown.convert( - <<-EOS + assert_equal "
puts "Hello world"\n
", + @markdown.convert( + <<-EOS ```ruby puts "Hello world" ``` - EOS - ).strip +EOS + ).strip end end context "with rouge enabled" do setup do - @markdown = Converters::Markdown.new @config.merge({ 'highlighter' => 'rouge' }) + @markdown = Converters::Markdown.new @config.merge({ "highlighter" => "rouge" }) end should "render fenced code blocks with syntax highlighting" do - assert_equal "
puts \"Hello world\"\n
", @markdown.convert( - <<-EOS + assert_equal "
puts \"Hello world\"\n
", + @markdown.convert( + <<-EOS ```ruby puts "Hello world" ``` EOS - ).strip + ).strip end end context "without any highlighter" do setup do - @markdown = Converters::Markdown.new @config.merge({ 'highlighter' => nil }) + @markdown = Converters::Markdown.new @config.merge({ "highlighter" => nil }) end should "render fenced code blocks without syntax highlighting" do - assert_equal "
puts "Hello world"\n
", @markdown.convert( - <<-EOS + assert_equal "
puts "Hello world"\n
"\ + "
", + @markdown.convert( + <<-EOS ```ruby puts "Hello world" ``` EOS - ).strip + ).strip end end end From bc16d13d7926ad92a911763ffe825b2f71b630a5 Mon Sep 17 00:00:00 2001 From: Brint O'Hearn Date: Mon, 16 May 2016 19:31:43 -0500 Subject: [PATCH 17/22] Shortening messages to keep things down to one line where possible --- test/test_cleaner.rb | 3 +-- test/test_coffeescript.rb | 3 +-- test/test_collections.rb | 9 +++------ 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/test/test_cleaner.rb b/test/test_cleaner.rb index 5e421c07..d3072e54 100644 --- a/test/test_cleaner.rb +++ b/test/test_cleaner.rb @@ -37,8 +37,7 @@ class TestCleaner < JekyllUnitTest end end - context "not-nested directory in keep_files and similary named directory not "\ - "in keep_files" do + context "non-nested directory & similarly-named directory *not* in keep_files" do setup do clear_dest diff --git a/test/test_coffeescript.rb b/test/test_coffeescript.rb index 95c06db8..189ce05d 100644 --- a/test/test_coffeescript.rb +++ b/test/test_coffeescript.rb @@ -37,8 +37,7 @@ JS end should "write a JS file in place" do - assert_exist @test_coffeescript_file, "Can't find the converted CoffeeScript file "\ - "in the dest_dir." + assert_exist @test_coffeescript_file end should "produce JS" do diff --git a/test/test_collections.rb b/test/test_collections.rb index 4c0b8379..795c0d8b 100644 --- a/test/test_collections.rb +++ b/test/test_collections.rb @@ -113,8 +113,7 @@ class TestCollections < JekyllUnitTest @collection = @site.collections["methods"] end - should "create a Hash on Site with the label mapped to the instance of the "\ - "Collection" do + should "create a Hash mapping label to Collection instance" do assert @site.collections.is_a?(Hash) refute_nil @site.collections["methods"] assert @site.collections["methods"].is_a? Jekyll::Collection @@ -137,8 +136,7 @@ class TestCollections < JekyllUnitTest end end - should "not include files which start with an underscore in the base collection "\ - "directory" do + should "not include files from base dir which start with an underscore" do refute_includes @collection.filtered_entries, "_do_not_read_me.md" end @@ -187,8 +185,7 @@ class TestCollections < JekyllUnitTest refute_includes @collection.filtered_entries, "/um_hi.md" end - should "include the symlinked file in the list of docs as it resolves to inside "\ - "site.source" do + should "include the symlinked file from site.source in the list of docs" do assert_includes @collection.docs.map(&:relative_path), "_methods/um_hi.md" end end From 211c16003e0b7064deabd659b3e6ac4c2ba12e68 Mon Sep 17 00:00:00 2001 From: Brint O'Hearn Date: Mon, 16 May 2016 19:39:43 -0500 Subject: [PATCH 18/22] test/test_exerpt.rb variable assignment cleanup --- test/test_excerpt.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/test_excerpt.rb b/test/test_excerpt.rb index 23144313..8b29f6fd 100644 --- a/test/test_excerpt.rb +++ b/test/test_excerpt.rb @@ -9,8 +9,9 @@ class TestExcerpt < JekyllUnitTest end def do_render(document) - @site.layouts = { "default" => Layout.new(@site, source_dir("_layouts"), - "simple.html") } + @site.layouts = { + "default" => Layout.new(@site, source_dir("_layouts"), "simple.html") + } document.output = Jekyll::Renderer.new(@site, document, @site.site_payload).run end From 98eef8af95c3d1ad8566215cf2a31fa5c8ff7792 Mon Sep 17 00:00:00 2001 From: Brint O'Hearn Date: Mon, 16 May 2016 19:48:04 -0500 Subject: [PATCH 19/22] Aligning hashes per 2caff75 --- test/test_commands_serve.rb | 6 +++--- test/test_doctor_command.rb | 4 ++-- test/test_excerpt.rb | 2 +- test/test_front_matter_defaults.rb | 28 ++++++++++++++-------------- test/test_generated_site.rb | 8 ++++---- test/test_layout_reader.rb | 2 +- test/test_rdiscount.rb | 4 ++-- test/test_redcarpet.rb | 2 +- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/test/test_commands_serve.rb b/test/test_commands_serve.rb index b02232b9..7ffd0a57 100644 --- a/test/test_commands_serve.rb +++ b/test/test_commands_serve.rb @@ -105,10 +105,10 @@ class TestCommandsServe < JekyllUnitTest allow(File).to receive(:read).and_return("foo") result = custom_opts({ - "ssl_cert" => "foo", - "source" => "bar", + "ssl_cert" => "foo", + "source" => "bar", "enable_ssl" => true, - "ssl_key" => "bar" + "ssl_key" => "bar" }) assert result[:SSLEnable] diff --git a/test/test_doctor_command.rb b/test/test_doctor_command.rb index aa6cf125..7280b287 100644 --- a/test/test_doctor_command.rb +++ b/test/test_doctor_command.rb @@ -9,7 +9,7 @@ class TestDoctorCommand < JekyllUnitTest should "return success on a valid site/page" do @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 })) @site.process @@ -22,7 +22,7 @@ class TestDoctorCommand < JekyllUnitTest should "return warning for pages only differing by case" do @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 })) @site.process diff --git a/test/test_excerpt.rb b/test/test_excerpt.rb index 8b29f6fd..e91fb7c0 100644 --- a/test/test_excerpt.rb +++ b/test/test_excerpt.rb @@ -3,7 +3,7 @@ require "helper" class TestExcerpt < JekyllUnitTest def setup_post(file) Document.new(@site.in_source_dir(File.join("_posts", file)), { - :site => @site, + :site => @site, :collection => @site.posts }).tap(&:read) end diff --git a/test/test_front_matter_defaults.rb b/test/test_front_matter_defaults.rb index 4be4ce2f..f1b55ac1 100644 --- a/test/test_front_matter_defaults.rb +++ b/test/test_front_matter_defaults.rb @@ -6,8 +6,8 @@ class TestFrontMatterDefaults < JekyllUnitTest @site = Site.new(Jekyll.configuration({ "source" => source_dir, "destination" => dest_dir, - "defaults" => [{ - "scope" => { + "defaults" => [{ + "scope" => { "path" => "contacts", "type" => "page" }, @@ -32,8 +32,8 @@ class TestFrontMatterDefaults < JekyllUnitTest @site = Site.new(Jekyll.configuration({ "source" => source_dir, "destination" => dest_dir, - "defaults" => [{ - "scope" => { + "defaults" => [{ + "scope" => { "path" => "index.html" }, "values" => { @@ -58,8 +58,8 @@ class TestFrontMatterDefaults < JekyllUnitTest @site = Site.new(Jekyll.configuration({ "source" => source_dir, "destination" => dest_dir, - "defaults" => [{ - "scope" => { + "defaults" => [{ + "scope" => { "path" => "win" }, "values" => { @@ -83,8 +83,8 @@ class TestFrontMatterDefaults < JekyllUnitTest @site = Site.new(Jekyll.configuration({ "source" => source_dir, "destination" => dest_dir, - "defaults" => [{ - "scope" => { + "defaults" => [{ + "scope" => { "type" => "page" }, "values" => { @@ -109,8 +109,8 @@ class TestFrontMatterDefaults < JekyllUnitTest @site = Site.new(Jekyll.configuration({ "source" => source_dir, "destination" => dest_dir, - "defaults" => [{ - "scope" => { + "defaults" => [{ + "scope" => { "type" => "pages" }, "values" => { @@ -135,8 +135,8 @@ class TestFrontMatterDefaults < JekyllUnitTest @site = Site.new(Jekyll.configuration({ "source" => source_dir, "destination" => dest_dir, - "defaults" => [{ - "scope" => { + "defaults" => [{ + "scope" => { }, "values" => { "key" => "val" @@ -159,7 +159,7 @@ class TestFrontMatterDefaults < JekyllUnitTest @site = Site.new(Jekyll.configuration({ "source" => source_dir, "destination" => dest_dir, - "defaults" => [{ + "defaults" => [{ "values" => { "key" => "val" } @@ -181,7 +181,7 @@ class TestFrontMatterDefaults < JekyllUnitTest @site = Site.new(Jekyll.configuration({ "source" => source_dir, "destination" => dest_dir, - "defaults" => [{ + "defaults" => [{ "values" => { "date" => "2015-01-01 00:00:01" } diff --git a/test/test_generated_site.rb b/test/test_generated_site.rb index 46374862..0a24172c 100644 --- a/test/test_generated_site.rb +++ b/test/test_generated_site.rb @@ -4,7 +4,7 @@ class TestGeneratedSite < JekyllUnitTest context "generated sites" do setup do clear_dest - config = Jekyll::Configuration::DEFAULTS.merge({ "source" => source_dir, + config = Jekyll::Configuration::DEFAULTS.merge({ "source" => source_dir, "destination" => dest_dir }) @site = fixture_site(config) @@ -65,7 +65,7 @@ OUTPUT context "generating limited posts" do setup do clear_dest - config = Jekyll::Configuration::DEFAULTS.merge({ "source" => source_dir, + config = Jekyll::Configuration::DEFAULTS.merge({ "source" => source_dir, "destination" => dest_dir, "limit_posts" => 5 }) @site = fixture_site(config) @@ -81,7 +81,7 @@ OUTPUT assert_raises ArgumentError do clear_dest config = Jekyll::Configuration::DEFAULTS.merge({ - "source" => source_dir, + "source" => source_dir, "destination" => dest_dir, "limit_posts" => -1 }) @@ -92,7 +92,7 @@ OUTPUT should "acceptable limit post is 0" do clear_dest config = Jekyll::Configuration::DEFAULTS.merge({ - "source" => source_dir, + "source" => source_dir, "destination" => dest_dir, "limit_posts" => 0 }) diff --git a/test/test_layout_reader.rb b/test/test_layout_reader.rb index dabe29c0..133cd6f2 100644 --- a/test/test_layout_reader.rb +++ b/test/test_layout_reader.rb @@ -3,7 +3,7 @@ require "helper" class TestLayoutReader < JekyllUnitTest context "reading layouts" do setup do - config = Jekyll::Configuration::DEFAULTS.merge({ "source" => source_dir, + config = Jekyll::Configuration::DEFAULTS.merge({ "source" => source_dir, "destination" => dest_dir }) @site = fixture_site(config) end diff --git a/test/test_rdiscount.rb b/test/test_rdiscount.rb index 889f9659..9390aaed 100644 --- a/test/test_rdiscount.rb +++ b/test/test_rdiscount.rb @@ -10,9 +10,9 @@ class TestRdiscount < JekyllUnitTest end config = { - "markdown" => "rdiscount", + "markdown" => "rdiscount", "rdiscount" => { - "toc_token" => "{:toc}", + "toc_token" => "{:toc}", "extensions" => %w(smart generate_toc) } } diff --git a/test/test_redcarpet.rb b/test/test_redcarpet.rb index 7231cff9..140fabbe 100644 --- a/test/test_redcarpet.rb +++ b/test/test_redcarpet.rb @@ -10,7 +10,7 @@ class TestRedcarpet < JekyllUnitTest end @config = { - "markdown" => "redcarpet", + "markdown" => "redcarpet", "redcarpet" => { "extensions" => %w(smart strikethrough filter_html) } From b006810f172a94e9bd5aa9cad8440e5cd1bacac1 Mon Sep 17 00:00:00 2001 From: Brint O'Hearn Date: Mon, 16 May 2016 19:59:13 -0500 Subject: [PATCH 20/22] Moving .with down one line 4x times --- test/test_log_adapter.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/test_log_adapter.rb b/test/test_log_adapter.rb index f34be99d..7e0873ca 100644 --- a/test/test_log_adapter.rb +++ b/test/test_log_adapter.rb @@ -61,8 +61,8 @@ class TestLogAdapter < JekyllUnitTest should "call #debug on writer return true" do writer = LoggerDouble.new logger = Jekyll::LogAdapter.new(writer) - allow(writer).to receive(:debug).with("topic ".rjust(20) + - "log message").and_return(true) + allow(writer).to receive(:debug) + .with("topic ".rjust(20) + "log message").and_return(true) assert logger.debug("topic", "log message") end end @@ -71,8 +71,8 @@ class TestLogAdapter < JekyllUnitTest should "call #info on writer return true" do writer = LoggerDouble.new logger = Jekyll::LogAdapter.new(writer) - allow(writer).to receive(:info).with("topic ".rjust(20) + - "log message").and_return(true) + allow(writer).to receive(:info) + .with("topic ".rjust(20) + "log message").and_return(true) assert logger.info("topic", "log message") end end @@ -81,8 +81,8 @@ class TestLogAdapter < JekyllUnitTest should "call #warn on writer return true" do writer = LoggerDouble.new logger = Jekyll::LogAdapter.new(writer) - allow(writer).to receive(:warn).with("topic ".rjust(20) + - "log message").and_return(true) + allow(writer).to receive(:warn) + .with("topic ".rjust(20) + "log message").and_return(true) assert logger.warn("topic", "log message") end end @@ -91,8 +91,8 @@ class TestLogAdapter < JekyllUnitTest should "call #error on writer return true" do writer = LoggerDouble.new logger = Jekyll::LogAdapter.new(writer) - allow(writer).to receive(:error).with("topic ".rjust(20) + - "log message").and_return(true) + allow(writer).to receive(:error) + .with("topic ".rjust(20) + "log message").and_return(true) assert logger.error("topic", "log message") end end From df585aa5c61c5e9552e32e473617be19474293e9 Mon Sep 17 00:00:00 2001 From: Brint O'Hearn Date: Mon, 16 May 2016 20:13:50 -0500 Subject: [PATCH 21/22] Moving expected output into variable to make asserts more readable --- test/test_excerpt.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/test_excerpt.rb b/test/test_excerpt.rb index e91fb7c0..6e4b8cbf 100644 --- a/test/test_excerpt.rb +++ b/test/test_excerpt.rb @@ -92,8 +92,9 @@ class TestExcerpt < JekyllUnitTest context "#content" do context "before render" do should "be the first paragraph of the page" do - assert_equal "First paragraph with [link ref][link].\n\n[link]:"\ - " http://www.jekyllrb.com/", @excerpt.content + expected = "First paragraph with [link ref][link].\n\n[link]: "\ + "http://www.jekyllrb.com/" + assert_equal expected, @excerpt.content end should "contain any refs at the bottom of the page" do @@ -109,8 +110,9 @@ class TestExcerpt < JekyllUnitTest end should "be the first paragraph of the page" do - assert_equal "

First paragraph with "\ - "link ref.

\n\n", @extracted_excerpt.output + expected = "

First paragraph with link "\ + "ref.

\n\n" + assert_equal expected, @extracted_excerpt.output end should "link properly" do From ce9a8cb0f2a1dbfd4a416ad12f4c3f104cdb7e11 Mon Sep 17 00:00:00 2001 From: Brint O'Hearn Date: Mon, 16 May 2016 20:42:59 -0500 Subject: [PATCH 22/22] Moving url to local var for better readability --- test/test_excerpt.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_excerpt.rb b/test/test_excerpt.rb index 6e4b8cbf..060323fe 100644 --- a/test/test_excerpt.rb +++ b/test/test_excerpt.rb @@ -79,8 +79,8 @@ class TestExcerpt < JekyllUnitTest context "#to_liquid" do should "contain the proper page data to mimick the post liquid" do assert_equal "Post Excerpt with Layout", @excerpt.to_liquid["title"] - assert_equal "/bar/baz/z_category/mixedcase/2013/07/22/"\ - "post-excerpt-with-layout.html", @excerpt.to_liquid["url"] + url = "/bar/baz/z_category/mixedcase/2013/07/22/post-excerpt-with-layout.html" + assert_equal url, @excerpt.to_liquid["url"] assert_equal Time.parse("2013-07-22"), @excerpt.to_liquid["date"] assert_equal %w(bar baz z_category MixedCase), @excerpt.to_liquid["categories"] assert_equal %w(first second third jekyllrb.com), @excerpt.to_liquid["tags"]