Rubocop fixes for test/test_static_file.rb

This commit is contained in:
Brint O'Hearn 2016-05-19 20:48:30 -05:00
parent 1380836a4b
commit 16c1146b4f
2 changed files with 21 additions and 22 deletions

View File

@ -81,7 +81,6 @@ AllCops:
- test/test_related_posts.rb - test/test_related_posts.rb
- test/test_sass.rb - test/test_sass.rb
- test/test_site.rb - test/test_site.rb
- test/test_static_file.rb
- test/test_tags.rb - test/test_tags.rb
- test/test_utils.rb - test/test_utils.rb
- bin/**/* - bin/**/*

View File

@ -1,4 +1,4 @@
require 'helper' require "helper"
class TestStaticFile < JekyllUnitTest class TestStaticFile < JekyllUnitTest
def make_dummy_file(filename) def make_dummy_file(filename)
@ -6,7 +6,8 @@ class TestStaticFile < JekyllUnitTest
end end
def modify_dummy_file(filename) def modify_dummy_file(filename)
offset = "some content".size string = "some content"
offset = string.size
File.write(source_dir(filename), "more content", offset) File.write(source_dir(filename), "more content", offset)
end end
@ -18,13 +19,13 @@ class TestStaticFile < JekyllUnitTest
StaticFile.new(@site, base, dir, name) StaticFile.new(@site, base, dir, name)
end end
def setup_static_file_with_collection(base, dir, name, label, metadata) def setup_static_file_with_collection(base, dir, name, metadata)
site = fixture_site('collections' => {label => metadata}) site = fixture_site("collections" => { "foo" => metadata })
StaticFile.new(site, base, dir, name, site.collections[label]) StaticFile.new(site, base, dir, name, site.collections["foo"])
end end
def setup_static_file_with_defaults(base, dir, name, defaults) 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) StaticFile.new(site, base, dir, name)
end end
@ -62,17 +63,16 @@ class TestStaticFile < JekyllUnitTest
end end
should "have a destination relative directory with a collection" do should "have a destination relative directory with a collection" do
static_file = setup_static_file_with_collection( static_file = setup_static_file_with_collection("root", "_foo/dir/subdir",
"root", "_foo/dir/subdir", "file.html", "foo", {"output" => true}) "file.html", { "output" => true })
assert_equal :foo, static_file.type assert_equal :foo, static_file.type
assert_equal "/foo/dir/subdir/file.html", static_file.url assert_equal "/foo/dir/subdir/file.html", static_file.url
assert_equal "/foo/dir/subdir", static_file.destination_rel_dir assert_equal "/foo/dir/subdir", static_file.destination_rel_dir
end 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( static_file = setup_static_file_with_collection("root", "_foo/dir/subdir",
"root", "_foo/dir/subdir", "file.html", "foo", "file.html", { "output" => true, "permalink" => "/:path/" })
{"output" => true, "permalink" => "/:path/"})
assert_equal :foo, static_file.type assert_equal :foo, static_file.type
assert_equal "/dir/subdir/file.html", static_file.url assert_equal "/dir/subdir/file.html", static_file.url
assert_equal "/dir/subdir", static_file.destination_rel_dir assert_equal "/dir/subdir", static_file.destination_rel_dir
@ -86,13 +86,13 @@ class TestStaticFile < JekyllUnitTest
should "use the _config.yml defaults to determine writability" do should "use the _config.yml defaults to determine writability" do
defaults = [{ defaults = [{
"scope" => {"path" => "private"}, "scope" => { "path" => "private" },
"values" => {"published" => false} "values" => { "published" => false }
}] }]
static_file = setup_static_file_with_defaults( static_file = setup_static_file_with_defaults("root", "private/dir/subdir",
"root", "private/dir/subdir", "file.html", defaults) "file.html", defaults)
assert(!static_file.write?, 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`") "`published: false`")
end end
@ -116,7 +116,7 @@ class TestStaticFile < JekyllUnitTest
assert @static_file.write?, "always true, with current implementation" assert @static_file.write?, "always true, with current implementation"
end 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) assert @static_file.write(dest_dir)
end end
@ -124,7 +124,7 @@ class TestStaticFile < JekyllUnitTest
expected = { expected = {
"extname" => ".txt", "extname" => ".txt",
"modified_time" => @static_file.modified_time, "modified_time" => @static_file.modified_time,
"path" => "/static_file.txt", "path" => "/static_file.txt"
} }
assert_equal expected, @static_file.to_liquid assert_equal expected, @static_file.to_liquid
end end