Do not raise property error

This commit is contained in:
Ian Ker-Seymer
2025-04-02 22:18:09 -04:00
parent a7ad5f4282
commit 7900043ffc
2 changed files with 11 additions and 17 deletions
+1 -5
View File
@@ -992,11 +992,7 @@ module Liquid
ary = InputIterator.new(input, context)
return default_value if ary.empty?
if property.nil?
raise_property_error(property)
end
property = Liquid::Utils.to_s(property)
property = Utils.to_s(property)
block.call(ary) do |item|
if target_value.nil?
+10 -12
View File
@@ -1033,22 +1033,20 @@ class StandardFiltersTest < Minitest::Test
assert_template_result(expected_output, template, { "array" => array })
end
def test_where_with_empty_string_and_nil
array = [
"alpha",
"beta",
"gamma",
]
template = "{{ array | where: '' | join: ' ' }}"
def test_where_with_empty_string_is_a_no_op
environment = { "array" => ["alpha", "beta", "gamma"] }
expected_output = "alpha beta gamma"
assert_template_result(expected_output, template, { "array" => array })
template = "{{ array | where: '' | join: ' ' }}"
assert_template_result(expected_output, template, environment)
end
def test_where_with_nil_is_a_no_op
environment = { "array" => ["alpha", "beta", "gamma"] }
expected_output = "alpha beta gamma"
template = "{{ array | where: nil | join: ' ' }}"
exception = assert_raises(Liquid::ArgumentError) do
assert_template_result(expected_output, template, { "array" => array })
end
assert_equal("Liquid error (line 1): cannot select the property ''", exception.message)
assert_template_result(expected_output, template, environment)
end
def test_where_with_value