Rubocop fixes for test/test_convertible.rb
This commit is contained in:
parent
5034cc377a
commit
454a1e415c
|
@ -71,7 +71,6 @@ AllCops:
|
||||||
- features/support/formatter.rb
|
- features/support/formatter.rb
|
||||||
- features/support/helpers.rb
|
- features/support/helpers.rb
|
||||||
- test/test_configuration.rb
|
- test/test_configuration.rb
|
||||||
- test/test_convertible.rb
|
|
||||||
- test/test_doctor_command.rb
|
- test/test_doctor_command.rb
|
||||||
- test/test_document.rb
|
- test/test_document.rb
|
||||||
- test/test_entry_filter.rb
|
- test/test_entry_filter.rb
|
||||||
|
|
|
@ -1,30 +1,30 @@
|
||||||
require 'helper'
|
require "helper"
|
||||||
require 'ostruct'
|
require "ostruct"
|
||||||
|
|
||||||
class TestConvertible < JekyllUnitTest
|
class TestConvertible < JekyllUnitTest
|
||||||
context "yaml front-matter" do
|
context "yaml front-matter" do
|
||||||
setup do
|
setup do
|
||||||
@convertible = OpenStruct.new(
|
@convertible = OpenStruct.new(
|
||||||
"site" => Site.new(Jekyll.configuration(
|
"site" => Site.new(Jekyll.configuration(
|
||||||
"source" => File.expand_path('../fixtures', __FILE__)
|
"source" => File.expand_path("../fixtures", __FILE__)
|
||||||
))
|
))
|
||||||
)
|
)
|
||||||
@convertible.extend Jekyll::Convertible
|
@convertible.extend Jekyll::Convertible
|
||||||
@base = File.expand_path('../fixtures', __FILE__)
|
@base = File.expand_path("../fixtures", __FILE__)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "parse the front-matter correctly" do
|
should "parse the front-matter correctly" do
|
||||||
ret = @convertible.read_yaml(@base, 'front_matter.erb')
|
ret = @convertible.read_yaml(@base, "front_matter.erb")
|
||||||
assert_equal({'test' => 'good'}, ret)
|
assert_equal({ "test" => "good" }, ret)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not parse if the front-matter is not at the start of the file" do
|
should "not parse if the front-matter is not at the start of the file" do
|
||||||
ret = @convertible.read_yaml(@base, 'broken_front_matter1.erb')
|
ret = @convertible.read_yaml(@base, "broken_front_matter1.erb")
|
||||||
assert_equal({}, ret)
|
assert_equal({}, ret)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not parse if there is syntax error in front-matter" do
|
should "not parse if there is syntax error in front-matter" do
|
||||||
name = 'broken_front_matter2.erb'
|
name = "broken_front_matter2.erb"
|
||||||
out = capture_stderr do
|
out = capture_stderr do
|
||||||
ret = @convertible.read_yaml(@base, name)
|
ret = @convertible.read_yaml(@base, name)
|
||||||
assert_equal({}, ret)
|
assert_equal({}, ret)
|
||||||
|
@ -35,15 +35,15 @@ class TestConvertible < JekyllUnitTest
|
||||||
|
|
||||||
should "not allow ruby objects in yaml" do
|
should "not allow ruby objects in yaml" do
|
||||||
out = capture_stderr do
|
out = capture_stderr do
|
||||||
@convertible.read_yaml(@base, 'exploit_front_matter.erb')
|
@convertible.read_yaml(@base, "exploit_front_matter.erb")
|
||||||
end
|
end
|
||||||
refute_match(/undefined class\/module DoesNotExist/, out)
|
refute_match(%r!undefined class\/module DoesNotExist!, out)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not parse if there is encoding error in file" do
|
should "not parse if there is encoding error in file" do
|
||||||
name = 'broken_front_matter3.erb'
|
name = "broken_front_matter3.erb"
|
||||||
out = capture_stderr do
|
out = capture_stderr do
|
||||||
ret = @convertible.read_yaml(@base, name, :encoding => 'utf-8')
|
ret = @convertible.read_yaml(@base, name, :encoding => "utf-8")
|
||||||
assert_equal({}, ret)
|
assert_equal({}, ret)
|
||||||
end
|
end
|
||||||
assert_match(/invalid byte sequence in UTF-8/, out)
|
assert_match(/invalid byte sequence in UTF-8/, out)
|
||||||
|
@ -51,7 +51,7 @@ class TestConvertible < JekyllUnitTest
|
||||||
end
|
end
|
||||||
|
|
||||||
should "parse the front-matter but show an error if permalink is empty" do
|
should "parse the front-matter but show an error if permalink is empty" do
|
||||||
name = 'empty_permalink.erb'
|
name = "empty_permalink.erb"
|
||||||
assert_raises(Errors::InvalidPermalinkError) do
|
assert_raises(Errors::InvalidPermalinkError) do
|
||||||
@convertible.read_yaml(@base, name)
|
@convertible.read_yaml(@base, name)
|
||||||
end
|
end
|
||||||
|
@ -59,7 +59,7 @@ class TestConvertible < JekyllUnitTest
|
||||||
|
|
||||||
should "parse the front-matter correctly whitout permalink" do
|
should "parse the front-matter correctly whitout permalink" do
|
||||||
out = capture_stderr do
|
out = capture_stderr do
|
||||||
@convertible.read_yaml(@base, 'front_matter.erb')
|
@convertible.read_yaml(@base, "front_matter.erb")
|
||||||
end
|
end
|
||||||
refute_match(/Invalid permalink/, out)
|
refute_match(/Invalid permalink/, out)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue