mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-20 11:20:41 -07:00
Make new tests serializable to liquid-spec
(No anonymous classes)
This commit is contained in:
@@ -88,17 +88,11 @@ class HashRenderingTest < Minitest::Test
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_rendering_hash_with_custom_to_s_method_uses_custom_to_s
|
def test_rendering_hash_with_custom_to_s_method_uses_custom_to_s
|
||||||
my_hash = Class.new(Hash) do
|
assert_template_result("kewl", "{{ my_hash }}", { "my_hash" => HashWithCustomToS.new })
|
||||||
def to_s
|
|
||||||
"kewl"
|
|
||||||
end
|
|
||||||
end.new
|
|
||||||
|
|
||||||
assert_template_result("kewl", "{{ my_hash }}", { "my_hash" => my_hash })
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_rendering_hash_without_custom_to_s_uses_default_inspect
|
def test_rendering_hash_without_custom_to_s_uses_default_inspect
|
||||||
my_hash = Class.new(Hash).new
|
my_hash = HashWithoutCustomToS.new
|
||||||
my_hash[:foo] = :bar
|
my_hash[:foo] = :bar
|
||||||
|
|
||||||
assert_template_result("{:foo=>:bar}", "{{ my_hash }}", { "my_hash" => my_hash })
|
assert_template_result("{:foo=>:bar}", "{{ my_hash }}", { "my_hash" => my_hash })
|
||||||
|
|||||||
@@ -294,13 +294,7 @@ class StandardFiltersTest < Minitest::Test
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_join_calls_to_liquid_on_each_element
|
def test_join_calls_to_liquid_on_each_element
|
||||||
drop = Class.new(Liquid::Drop) do
|
assert_equal('i did it, i did it', @filters.join([CustomToLiquidDrop.new('i did it'), CustomToLiquidDrop.new('i did it')], ", "))
|
||||||
def to_liquid
|
|
||||||
'i did it'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
assert_equal('i did it, i did it', @filters.join([drop.new, drop.new], ", "))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_sort
|
def test_sort
|
||||||
|
|||||||
@@ -199,6 +199,26 @@ class ErrorDrop < Liquid::Drop
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class CustomToLiquidDrop < Liquid::Drop
|
||||||
|
def initialize(value)
|
||||||
|
@value = value
|
||||||
|
super()
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_liquid
|
||||||
|
@value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class HashWithCustomToS < Hash
|
||||||
|
def to_s
|
||||||
|
"kewl"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class HashWithoutCustomToS < Hash
|
||||||
|
end
|
||||||
|
|
||||||
class StubFileSystem
|
class StubFileSystem
|
||||||
attr_reader :file_read_count
|
attr_reader :file_read_count
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user