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:
Brint O'Hearn 2016-05-15 16:51:06 -05:00
parent 2caff755c4
commit 146d49dc8f
7 changed files with 55 additions and 55 deletions

View File

@ -72,12 +72,6 @@ AllCops:
- features/support/helpers.rb - features/support/helpers.rb
- test/helper.rb - test/helper.rb
- test/simplecov_custom_profile.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_configuration.rb
- test/test_convertible.rb - test/test_convertible.rb
- test/test_doctor_command.rb - test/test_doctor_command.rb

View File

@ -6,7 +6,7 @@ class TestAnsi < JekyllUnitTest
@subject = Jekyll::Utils::Ansi @subject = Jekyll::Utils::Ansi
end end
Jekyll::Utils::Ansi::COLORS.each do |color, val| Jekyll::Utils::Ansi::COLORS.each do |color, _val|
should "respond_to? #{color}" do should "respond_to? #{color}" do
assert @subject.respond_to?(color) assert @subject.respond_to?(color)
end end

View File

@ -1,73 +1,74 @@
require 'helper' require "helper"
class TestCleaner < JekyllUnitTest class TestCleaner < JekyllUnitTest
context "directory in keep_files" do context "directory in keep_files" do
setup do setup do
clear_dest clear_dest
FileUtils.mkdir_p(dest_dir('to_keep/child_dir')) 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"), "index.html"))
FileUtils.touch(File.join(dest_dir('to_keep/child_dir'), 'index.html')) FileUtils.touch(File.join(dest_dir("to_keep/child_dir"), "index.html"))
@site = fixture_site @site = fixture_site
@site.keep_files = ['to_keep/child_dir'] @site.keep_files = ["to_keep/child_dir"]
@cleaner = Cleaner.new(@site) @cleaner = Cleaner.new(@site)
@cleaner.cleanup! @cleaner.cleanup!
end end
teardown do teardown do
FileUtils.rm_rf(dest_dir('to_keep')) FileUtils.rm_rf(dest_dir("to_keep"))
end end
should "keep the parent directory" do should "keep the parent directory" do
assert_exist dest_dir('to_keep') assert_exist dest_dir("to_keep")
end end
should "keep the child directory" do should "keep the child directory" do
assert_exist dest_dir('to_keep', 'child_dir') assert_exist dest_dir("to_keep", "child_dir")
end end
should "keep the file in the directory in keep_files" do 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 end
should "delete the file in the directory not in keep_files" do 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
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 setup do
clear_dest clear_dest
FileUtils.mkdir_p(dest_dir('.git/child_dir')) FileUtils.mkdir_p(dest_dir(".git/child_dir"))
FileUtils.mkdir_p(dest_dir('username.github.io')) FileUtils.mkdir_p(dest_dir("username.github.io"))
FileUtils.touch(File.join(dest_dir('.git'), 'index.html')) FileUtils.touch(File.join(dest_dir(".git"), "index.html"))
FileUtils.touch(File.join(dest_dir('username.github.io'), 'index.html')) FileUtils.touch(File.join(dest_dir("username.github.io"), "index.html"))
@site = fixture_site @site = fixture_site
@site.keep_files = ['.git'] @site.keep_files = [".git"]
@cleaner = Cleaner.new(@site) @cleaner = Cleaner.new(@site)
@cleaner.cleanup! @cleaner.cleanup!
end end
teardown do teardown do
FileUtils.rm_rf(dest_dir('.git')) FileUtils.rm_rf(dest_dir(".git"))
FileUtils.rm_rf(dest_dir('username.github.io')) FileUtils.rm_rf(dest_dir("username.github.io"))
end end
should "keep the file in the directory in keep_files" do 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 end
should "delete the file in the directory not in keep_files" do 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 end
should "delete the directory not in keep_files" do 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
end end
@ -75,8 +76,8 @@ class TestCleaner < JekyllUnitTest
setup do setup do
clear_dest clear_dest
FileUtils.mkdir_p(source_dir('no_files_inside', 'child_dir')) FileUtils.mkdir_p(source_dir("no_files_inside", "child_dir"))
FileUtils.touch(source_dir('no_files_inside', 'child_dir', 'index.html')) FileUtils.touch(source_dir("no_files_inside", "child_dir", "index.html"))
@site = fixture_site @site = fixture_site
@site.process @site.process
@ -86,20 +87,20 @@ class TestCleaner < JekyllUnitTest
end end
teardown do teardown do
FileUtils.rm_rf(source_dir('no_files_inside')) FileUtils.rm_rf(source_dir("no_files_inside"))
FileUtils.rm_rf(dest_dir('no_files_inside')) FileUtils.rm_rf(dest_dir("no_files_inside"))
end end
should "keep the parent directory" do should "keep the parent directory" do
assert_exist dest_dir('no_files_inside') assert_exist dest_dir("no_files_inside")
end end
should "keep the child directory" do 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 end
should "keep the file" do 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 end
end end

View File

@ -1,9 +1,9 @@
require 'helper' require "helper"
class TestCoffeeScript < JekyllUnitTest class TestCoffeeScript < JekyllUnitTest
context "converting CoffeeScript" do context "converting CoffeeScript" do
setup do setup do
External.require_with_graceful_fail('jekyll-coffeescript') External.require_with_graceful_fail("jekyll-coffeescript")
@site = fixture_site @site = fixture_site
@site.process @site.process
@test_coffeescript_file = dest_dir("js/coffeescript.js") @test_coffeescript_file = dest_dir("js/coffeescript.js")
@ -37,7 +37,8 @@ JS
end end
should "write a JS file in place" do 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 end
should "produce JS" do should "produce JS" do

View File

@ -1,4 +1,4 @@
require 'helper' require "helper"
class TestCollections < JekyllUnitTest class TestCollections < JekyllUnitTest
context "an evil collection" do context "an evil collection" do
@ -50,7 +50,7 @@ class TestCollections < JekyllUnitTest
end end
should "have a docs attribute" do should "have a docs attribute" do
assert_equal @collection.to_liquid["docs"], Array.new assert_equal @collection.to_liquid["docs"], []
end end
should "have a directory attribute" do should "have a directory attribute" do
@ -68,9 +68,9 @@ class TestCollections < JekyllUnitTest
should "know whether it should be written or not" do should "know whether it should be written or not" do
assert_equal @collection.write?, false assert_equal @collection.write?, false
@collection.metadata['output'] = true @collection.metadata["output"] = true
assert_equal @collection.write?, true assert_equal @collection.write?, true
@collection.metadata.delete 'output' @collection.metadata.delete "output"
end end
end end
@ -80,8 +80,8 @@ class TestCollections < JekyllUnitTest
@site.process @site.process
end end
should "contain only the defaul collections" do should "contain only the default collections" do
refute_equal Hash.new, @site.collections refute_equal @site.collections, {}
refute_nil @site.collections refute_nil @site.collections
end end
end end
@ -113,7 +113,8 @@ class TestCollections < JekyllUnitTest
@collection = @site.collections["methods"] @collection = @site.collections["methods"]
end 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) assert @site.collections.is_a?(Hash)
refute_nil @site.collections["methods"] refute_nil @site.collections["methods"]
assert @site.collections["methods"].is_a? Jekyll::Collection assert @site.collections["methods"].is_a? Jekyll::Collection
@ -123,7 +124,7 @@ class TestCollections < JekyllUnitTest
assert @site.collections["methods"].docs.is_a? Array assert @site.collections["methods"].docs.is_a? Array
@site.collections["methods"].docs.each do |doc| @site.collections["methods"].docs.each do |doc|
assert doc.is_a? Jekyll::Document assert doc.is_a? Jekyll::Document
assert_includes %w[ assert_includes %w(
_methods/configuration.md _methods/configuration.md
_methods/sanitized_path.md _methods/sanitized_path.md
_methods/collection/entries _methods/collection/entries
@ -132,11 +133,12 @@ class TestCollections < JekyllUnitTest
_methods/um_hi.md _methods/um_hi.md
_methods/escape-+\ #%20[].md _methods/escape-+\ #%20[].md
_methods/yaml_with_dots.md _methods/yaml_with_dots.md
], doc.relative_path ), doc.relative_path
end end
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" refute_includes @collection.filtered_entries, "_do_not_read_me.md"
end end
@ -146,7 +148,8 @@ class TestCollections < JekyllUnitTest
should "not include the underscored files in the list of docs" do should "not include the underscored files in the list of docs" do
refute_includes @collection.docs.map(&:relative_path), "_methods/_do_not_read_me.md" refute_includes @collection.docs.map(&:relative_path), "_methods/_do_not_read_me.md"
refute_includes @collection.docs.map(&:relative_path), "_methods/site/_dont_include_me_either.md" refute_includes @collection.docs.map(&:relative_path),
"_methods/site/_dont_include_me_either.md"
end end
end end
@ -184,7 +187,8 @@ class TestCollections < JekyllUnitTest
refute_includes @collection.filtered_entries, "/um_hi.md" refute_includes @collection.filtered_entries, "/um_hi.md"
end 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" assert_includes @collection.docs.map(&:relative_path), "_methods/um_hi.md"
end end
end end
@ -215,5 +219,4 @@ class TestCollections < JekyllUnitTest
assert @collection.docs.any? { |d| d.path.include?("all.dots") } assert @collection.docs.any? { |d| d.path.include?("all.dots") }
end end
end end
end end

View File

@ -1,4 +1,4 @@
require 'helper' require "helper"
class TestCommand < JekyllUnitTest class TestCommand < JekyllUnitTest
context "when calling .add_build_options" do context "when calling .add_build_options" do

View File

@ -11,7 +11,8 @@ class TestCommandsServe < JekyllUnitTest
context "with a program" do context "with a program" do
setup do setup do
@merc, @cmd = nil, Jekyll::Commands::Serve @merc = nil
@cmd = Jekyll::Commands::Serve
Mercenary.program(:jekyll) do |p| Mercenary.program(:jekyll) do |p|
@merc = @cmd.init_with_program( @merc = @cmd.init_with_program(
p p