Test `inspect` filter with custom object (#9743)
Merge pull request 9743
This commit is contained in:
parent
74f0c4d079
commit
98c14c0f2f
|
@ -34,6 +34,17 @@ class TestFilters < JekyllUnitTest
|
||||||
def select; end
|
def select; end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class KeyValue
|
||||||
|
def initialize(key:, value:)
|
||||||
|
@key = key
|
||||||
|
@val = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def inspect
|
||||||
|
"{#{@key.inspect}=>#{@val.inspect}}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "filters" do
|
context "filters" do
|
||||||
setup do
|
setup do
|
||||||
@sample_time = Time.utc(2013, 3, 27, 11, 22, 33)
|
@sample_time = Time.utc(2013, 3, 27, 11, 22, 33)
|
||||||
|
@ -1457,7 +1468,9 @@ class TestFilters < JekyllUnitTest
|
||||||
|
|
||||||
context "inspect filter" do
|
context "inspect filter" do
|
||||||
should "return a HTML-escaped string representation of an object" do
|
should "return a HTML-escaped string representation of an object" do
|
||||||
assert_equal "{"<a>"=>1}", @filter.inspect("<a>" => 1)
|
hash_like_object = KeyValue.new(:key => "<a>", :value => 1)
|
||||||
|
assert_equal '{"<a>"=>1}', hash_like_object.inspect
|
||||||
|
assert_equal "{"<a>"=>1}", @filter.inspect(hash_like_object)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "quote strings" do
|
should "quote strings" do
|
||||||
|
|
Loading…
Reference in New Issue