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
This commit is contained in:
parent
2caff755c4
commit
146d49dc8f
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'helper'
|
||||
require "helper"
|
||||
|
||||
class TestCommand < JekyllUnitTest
|
||||
context "when calling .add_build_options" do
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue