From 34ab3bdc8e0a8dcfda3a7940da024595308cd510 Mon Sep 17 00:00:00 2001 From: "Charles-P. Clermont" Date: Mon, 20 Oct 2025 15:00:11 -0400 Subject: [PATCH] Fix assert_template_result tests not picking up Liquid::Environment.default.error_mode The `rake test` command gave us the impression that we were running all the tests on all the error modes, that was false. --- lib/liquid/tags/cycle.rb | 1 + test/integration/expression_test.rb | 9 +++++++-- test/integration/tags/cycle_tag_test.rb | 1 - test/integration/tags/table_row_test.rb | 9 ++++++--- test/test_helper.rb | 2 +- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/liquid/tags/cycle.rb b/lib/liquid/tags/cycle.rb index 60f44d04..51fa9714 100644 --- a/lib/liquid/tags/cycle.rb +++ b/lib/liquid/tags/cycle.rb @@ -78,6 +78,7 @@ module Liquid # Parse remaining comma-separated expressions while p.consume?(:comma) break if p.look(:end_of_string) + @variables << maybe_dup_lookup(safe_parse_expression(p)) end diff --git a/test/integration/expression_test.rb b/test/integration/expression_test.rb index 918f87c2..71969900 100644 --- a/test/integration/expression_test.rb +++ b/test/integration/expression_test.rb @@ -26,8 +26,12 @@ class ExpressionTest < Minitest::Test def test_float assert_template_result("-17.42", "{{ -17.42 }}") assert_template_result("2.5", "{{ 2.5 }}") - assert_expression_result(0.0, "0.....5") - assert_expression_result(0.0, "-0..1") + + with_error_mode(:lax) do + assert_expression_result(0.0, "0.....5") + assert_expression_result(0.0, "-0..1") + end + assert_expression_result(1.5, "1.5") # this is a unfortunate quirky behavior of Liquid @@ -61,6 +65,7 @@ class ExpressionTest < Minitest::Test assert_template_result( "", "{{ - 'theme.css' - }}", + error_mode: :lax, ) end diff --git a/test/integration/tags/cycle_tag_test.rb b/test/integration/tags/cycle_tag_test.rb index b0ee6925..c41fb68e 100644 --- a/test/integration/tags/cycle_tag_test.rb +++ b/test/integration/tags/cycle_tag_test.rb @@ -3,7 +3,6 @@ require 'test_helper' class CycleTagTest < Minitest::Test - def test_simple_cycle_inside_for_loop template = <<~LIQUID {%- for i in (1..3) -%} diff --git a/test/integration/tags/table_row_test.rb b/test/integration/tags/table_row_test.rb index ad12d76f..81444945 100644 --- a/test/integration/tags/table_row_test.rb +++ b/test/integration/tags/table_row_test.rb @@ -138,7 +138,7 @@ class TableRowTest < Minitest::Test def test_tablerow_loop_drop_attributes template = <<~LIQUID.chomp - {% tablerow i in (1...2) %} + {% tablerow i in (1..2) %} col: {{ tablerowloop.col }} col0: {{ tablerowloop.col0 }} col_first: {{ tablerowloop.col_first }} @@ -192,12 +192,14 @@ class TableRowTest < Minitest::Test assert_template_result( "Liquid error (line 1): invalid integer", '{% tablerow n in (1...10) limit:true %} {{n}} {% endtablerow %}', + error_mode: :warn, render_errors: true, ) assert_template_result( "Liquid error (line 1): invalid integer", '{% tablerow n in (1...10) offset:true %} {{n}} {% endtablerow %}', + error_mode: :warn, render_errors: true, ) @@ -205,18 +207,19 @@ class TableRowTest < Minitest::Test "Liquid error (line 1): invalid integer", '{% tablerow n in (1...10) cols:true %} {{n}} {% endtablerow %}', render_errors: true, + error_mode: :warn, ) end def test_table_row_handles_interrupts assert_template_result( "\n 1 \n", - '{% tablerow n in (1...3) cols:2 %} {{n}} {% break %} {{n}} {% endtablerow %}', + '{% tablerow n in (1..3) cols:2 %} {{n}} {% break %} {{n}} {% endtablerow %}', ) assert_template_result( "\n 1 2 \n 3 \n", - '{% tablerow n in (1...3) cols:2 %} {{n}} {% continue %} {{n}} {% endtablerow %}', + '{% tablerow n in (1..3) cols:2 %} {{n}} {% continue %} {{n}} {% endtablerow %}', ) end diff --git a/test/test_helper.rb b/test/test_helper.rb index 4f444738..69172d47 100755 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -34,7 +34,7 @@ module Minitest def assert_template_result( expected, template, assigns = {}, - message: nil, partials: nil, error_mode: nil, render_errors: false, + message: nil, partials: nil, error_mode: Liquid::Environment.default.error_mode, render_errors: false, template_factory: nil ) file_system = StubFileSystem.new(partials || {})