From 16c1146b4f55f2047367a28946b02015adca3e6e Mon Sep 17 00:00:00 2001 From: Brint O'Hearn Date: Thu, 19 May 2016 20:48:30 -0500 Subject: [PATCH] Rubocop fixes for test/test_static_file.rb --- .rubocop.yml | 1 - test/test_static_file.rb | 42 ++++++++++++++++++++-------------------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 47ad2353..24816dc7 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -81,7 +81,6 @@ AllCops: - test/test_related_posts.rb - test/test_sass.rb - test/test_site.rb - - test/test_static_file.rb - test/test_tags.rb - test/test_utils.rb - bin/**/* diff --git a/test/test_static_file.rb b/test/test_static_file.rb index 85512ab4..b705ff05 100644 --- a/test/test_static_file.rb +++ b/test/test_static_file.rb @@ -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 @@ -62,17 +63,16 @@ class TestStaticFile < JekyllUnitTest end 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}) + static_file = setup_static_file_with_collection("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 - static_file = setup_static_file_with_collection( - "root", "_foo/dir/subdir", "file.html", "foo", - {"output" => true, "permalink" => "/:path/"}) + 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", { "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 @@ -86,13 +86,13 @@ class TestStaticFile < JekyllUnitTest should "use the _config.yml defaults to determine writability" do defaults = [{ - "scope" => {"path" => "private"}, - "values" => {"published" => false} + "scope" => { "path" => "private" }, + "values" => { "published" => false } }] - static_file = setup_static_file_with_defaults( - "root", "private/dir/subdir", "file.html", defaults) + static_file = setup_static_file_with_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,15 +116,15 @@ 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 should "be able to convert to liquid" do expected = { - "extname" => ".txt", - "modified_time" => @static_file.modified_time, - "path" => "/static_file.txt", + "extname" => ".txt", + "modified_time" => @static_file.modified_time, + "path" => "/static_file.txt" } assert_equal expected, @static_file.to_liquid end