Rubocop fixes for test/test_static_file.rb
This commit is contained in:
parent
1380836a4b
commit
16c1146b4f
|
@ -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/**/*
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue