diff --git a/test/integration/hash_rendering_test.rb b/test/integration/hash_rendering_test.rb index 47e6288b..0c1b33e4 100644 --- a/test/integration/hash_rendering_test.rb +++ b/test/integration/hash_rendering_test.rb @@ -88,17 +88,11 @@ class HashRenderingTest < Minitest::Test end def test_rendering_hash_with_custom_to_s_method_uses_custom_to_s - my_hash = Class.new(Hash) do - def to_s - "kewl" - end - end.new - - assert_template_result("kewl", "{{ my_hash }}", { "my_hash" => my_hash }) + assert_template_result("kewl", "{{ my_hash }}", { "my_hash" => HashWithCustomToS.new }) end 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 assert_template_result("{:foo=>:bar}", "{{ my_hash }}", { "my_hash" => my_hash }) diff --git a/test/integration/standard_filter_test.rb b/test/integration/standard_filter_test.rb index e1370fae..e27605ff 100644 --- a/test/integration/standard_filter_test.rb +++ b/test/integration/standard_filter_test.rb @@ -294,13 +294,7 @@ class StandardFiltersTest < Minitest::Test end def test_join_calls_to_liquid_on_each_element - drop = Class.new(Liquid::Drop) do - def to_liquid - 'i did it' - end - end - - assert_equal('i did it, i did it', @filters.join([drop.new, drop.new], ", ")) + assert_equal('i did it, i did it', @filters.join([CustomToLiquidDrop.new('i did it'), CustomToLiquidDrop.new('i did it')], ", ")) end def test_sort diff --git a/test/test_helper.rb b/test/test_helper.rb index 293ea476..a6d3e16e 100755 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -199,6 +199,26 @@ class ErrorDrop < Liquid::Drop 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 attr_reader :file_read_count