Merge pull request #4916 from brint/rubocop_cleaning

Merge pull request 4916
This commit is contained in:
jekyllbot 2016-05-23 13:36:48 -07:00
commit 6eaf2634f2
8 changed files with 81 additions and 73 deletions

View File

@ -62,10 +62,7 @@ AllCops:
- lib/jekyll/tags/post_url.rb
- lib/jekyll/theme.rb
- lib/jekyll/url.rb
- lib/jekyll/utils/ansi.rb
- lib/jekyll/utils/platforms.rb
- lib/jekyll/utils.rb
- lib/jekyll/version.rb
- lib/jekyll.rb
- features/step_definitions.rb
- features/support/formatter.rb
@ -78,13 +75,8 @@ AllCops:
- test/test_liquid_renderer.rb
- test/test_page.rb
- test/test_regenerator.rb
- test/test_related_posts.rb
- test/test_sass.rb
- test/test_site.rb
- test/test_static_file.rb
- test/test_tags.rb
- test/test_theme.rb
- test/test_url.rb
- test/test_utils.rb
- bin/**/*
- benchmark/**/*

View File

@ -8,7 +8,7 @@ module Jekyll
extend self
ESCAPE = format("%c", 27)
MATCH = /#{ESCAPE}\[(?:\d+)(?:;\d+)*(j|k|m|s|u|A|B|G)|\e\(B\e\[m/ix.freeze
MATCH = /#{ESCAPE}\[(?:\d+)(?:;\d+)*(j|k|m|s|u|A|B|G)|\e\(B\e\[m/ix
COLORS = {
:red => 31,
:green => 32,
@ -18,7 +18,7 @@ module Jekyll
:white => 37,
:blue => 34,
:cyan => 36
}
}.freeze
# Strip ANSI from the current string. It also strips cursor stuff,
# well some of it, and it also strips some other stuff that a lot of

View File

@ -1,3 +1,3 @@
module Jekyll
VERSION = '3.2.0.pre.beta1'
VERSION = "3.2.0.pre.beta1".freeze
end

View File

@ -1,4 +1,4 @@
require 'helper'
require "helper"
class TestRelatedPosts < JekyllUnitTest
context "building related posts without lsi" do
@ -33,26 +33,29 @@ class TestRelatedPosts < JekyllUnitTest
@site.reset
@site.read
require 'classifier-reborn'
require "classifier-reborn"
Jekyll::RelatedPosts.lsi = nil
end
should "index Jekyll::Post objects" do
@site.posts.docs = @site.posts.docs.first(1)
expect_any_instance_of(::ClassifierReborn::LSI).to receive(:add_item).with(kind_of(Jekyll::Document))
expect_any_instance_of(::ClassifierReborn::LSI).to \
receive(:add_item).with(kind_of(Jekyll::Document))
Jekyll::RelatedPosts.new(@site.posts.last).build_index
end
should "find related Jekyll::Post objects, given a Jekyll::Post object" do
post = @site.posts.last
allow_any_instance_of(::ClassifierReborn::LSI).to receive(:build_index)
expect_any_instance_of(::ClassifierReborn::LSI).to receive(:find_related).with(post, 11).and_return(@site.posts[-1..-9])
expect_any_instance_of(::ClassifierReborn::LSI).to \
receive(:find_related).with(post, 11).and_return(@site.posts[-1..-9])
Jekyll::RelatedPosts.new(post).build
end
should "use lsi for the related posts" do
allow_any_instance_of(::ClassifierReborn::LSI).to receive(:find_related).and_return(@site.posts[-1..-9])
allow_any_instance_of(::ClassifierReborn::LSI).to \
receive(:find_related).and_return(@site.posts[-1..-9])
allow_any_instance_of(::ClassifierReborn::LSI).to receive(:build_index)
assert_equal @site.posts[-1..-9], Jekyll::RelatedPosts.new(@site.posts.last).build

View File

@ -1,4 +1,4 @@
require 'helper'
require "helper"
class TestSass < JekyllUnitTest
context "importing partials" do
@ -16,11 +16,13 @@ class TestSass < JekyllUnitTest
end
should "register the SCSS converter" do
assert !!@site.find_converter_instance(Jekyll::Converters::Scss), "SCSS converter implementation should exist."
message = "SCSS converter implementation should exist."
assert !!@site.find_converter_instance(Jekyll::Converters::Scss), message
end
should "register the Sass converter" do
assert !!@site.find_converter_instance(Jekyll::Converters::Sass), "Sass converter implementation should exist."
message = "Sass converter implementation should exist."
assert !!@site.find_converter_instance(Jekyll::Converters::Sass), message
end
end
end

View File

@ -1,4 +1,4 @@
require 'helper'
require "helper"
class TestStaticFile < JekyllUnitTest
def make_dummy_file(filename)
@ -6,7 +6,8 @@ class TestStaticFile < JekyllUnitTest
end
def modify_dummy_file(filename)
offset = "some content".size
string = "some content"
offset = string.size
File.write(source_dir(filename), "more content", offset)
end
@ -18,13 +19,13 @@ class TestStaticFile < JekyllUnitTest
StaticFile.new(@site, base, dir, name)
end
def setup_static_file_with_collection(base, dir, name, label, metadata)
site = fixture_site('collections' => {label => metadata})
StaticFile.new(site, base, dir, name, site.collections[label])
def setup_static_file_with_collection(base, dir, name, metadata)
site = fixture_site("collections" => { "foo" => metadata })
StaticFile.new(site, base, dir, name, site.collections["foo"])
end
def setup_static_file_with_defaults(base, dir, name, defaults)
site = fixture_site('defaults' => defaults)
site = fixture_site("defaults" => defaults)
StaticFile.new(site, base, dir, name)
end
@ -63,16 +64,23 @@ class TestStaticFile < JekyllUnitTest
should "have a destination relative directory with a collection" do
static_file = setup_static_file_with_collection(
"root", "_foo/dir/subdir", "file.html", "foo", {"output" => true})
"root",
"_foo/dir/subdir",
"file.html",
{ "output" => true }
)
assert_equal :foo, static_file.type
assert_equal "/foo/dir/subdir/file.html", static_file.url
assert_equal "/foo/dir/subdir", static_file.destination_rel_dir
end
should "use its collection's permalink template for the destination relative directory" do
should "use its collection's permalink template for destination relative directory" do
static_file = setup_static_file_with_collection(
"root", "_foo/dir/subdir", "file.html", "foo",
{"output" => true, "permalink" => "/:path/"})
"root",
"_foo/dir/subdir",
"file.html",
{ "output" => true, "permalink" => "/:path/" }
)
assert_equal :foo, static_file.type
assert_equal "/dir/subdir/file.html", static_file.url
assert_equal "/dir/subdir", static_file.destination_rel_dir
@ -90,9 +98,13 @@ class TestStaticFile < JekyllUnitTest
"values" => { "published" => false }
}]
static_file = setup_static_file_with_defaults(
"root", "private/dir/subdir", "file.html", defaults)
"root",
"private/dir/subdir",
"file.html",
defaults
)
assert(!static_file.write?,
"static_file.write? should return false when _config.yml sets " +
"static_file.write? should return false when _config.yml sets " \
"`published: false`")
end
@ -116,7 +128,7 @@ class TestStaticFile < JekyllUnitTest
assert @static_file.write?, "always true, with current implementation"
end
should "be able to write itself to the desitination direcotry" do
should "be able to write itself to the desitination directory" do
assert @static_file.write(dest_dir)
end
@ -124,7 +136,7 @@ class TestStaticFile < JekyllUnitTest
expected = {
"extname" => ".txt",
"modified_time" => @static_file.modified_time,
"path" => "/static_file.txt",
"path" => "/static_file.txt"
}
assert_equal expected, @static_file.to_liquid
end

View File

@ -1,14 +1,14 @@
require 'helper'
require "helper"
class TestTheme < JekyllUnitTest
def setup
@theme = Theme.new('test-theme')
@theme = Theme.new("test-theme")
@expected_root = File.expand_path "./fixtures/test-theme", File.dirname(__FILE__)
end
context "initializing" do
should "normalize the theme name" do
theme = Theme.new(' Test-Theme ')
theme = Theme.new(" Test-Theme ")
assert_equal "test-theme", theme.name
end
@ -28,7 +28,8 @@ class TestTheme < JekyllUnitTest
should "add itself to sass's load path" do
@theme.configure_sass
assert Sass.load_paths.include?(@theme.sass_path), "Sass load paths should include the theme sass dir"
message = "Sass load paths should include the theme sass dir"
assert Sass.load_paths.include?(@theme.sass_path), message
end
end

View File

@ -1,8 +1,7 @@
require 'helper'
require "helper"
class TestURL < JekyllUnitTest
context "The URL class" do
should "throw an exception if neither permalink or template is specified" do
assert_raises ArgumentError do
URL.new(:placeholders => {})
@ -17,7 +16,7 @@ class TestURL < JekyllUnitTest
end
should "handle multiple of the same key in the template" do
assert_equal '/foo/bar/foo/', URL.new(
assert_equal "/foo/bar/foo/", URL.new(
:template => "/:x/:y/:x/",
:placeholders => { :x => "foo", :y => "bar" }
).to_s
@ -40,7 +39,7 @@ class TestURL < JekyllUnitTest
end
should "handle multiple of the same key in the permalink" do
assert_equal '/foo/bar/foo/', URL.new(
assert_equal "/foo/bar/foo/", URL.new(
:template => "/baz",
:permalink => "/:x/:y/:x/",
:placeholders => { :x => "foo", :y => "bar" }
@ -48,7 +47,7 @@ class TestURL < JekyllUnitTest
end
should "handle nil values for keys in the template" do
assert_equal '/foo/bar/', URL.new(
assert_equal "/foo/bar/", URL.new(
:template => "/:x/:y/:z/",
:placeholders => { :x => "foo", :y => "bar", :z => nil }
).to_s
@ -60,17 +59,16 @@ class TestURL < JekyllUnitTest
"methods" => {
"output" => true
}
},
}
})
site.read
matching_doc = site.collections["methods"].docs.find do |doc|
doc.relative_path == "_methods/escape-+ #%20[].md"
end
assert_equal '/methods/escape-+-20/escape-20.html', URL.new(
:template => '/methods/:title/:name:output_ext',
assert_equal "/methods/escape-+-20/escape-20.html", URL.new(
:template => "/methods/:title/:name:output_ext",
:placeholders => matching_doc.url_placeholders
).to_s
end
end
end