test/integration/parsing_quirks_test.rb in liquid-4.0.4 vs test/integration/parsing_quirks_test.rb in liquid-5.0.0

- old
+ new

@@ -1,13 +1,15 @@ +# frozen_string_literal: true + require 'test_helper' class ParsingQuirksTest < Minitest::Test include Liquid def test_parsing_css text = " div { font-weight: bold; } " - assert_equal text, Template.parse(text).render! + assert_equal(text, Template.parse(text).render!) end def test_raise_on_single_close_bracet assert_raises(SyntaxError) do Template.parse("text {{method} oh nos!") @@ -25,14 +27,14 @@ Template.parse("TEST {% ") end end def test_error_on_empty_filter - assert Template.parse("{{test}}") + assert(Template.parse("{{test}}")) with_error_mode(:lax) do - assert Template.parse("{{|test}}") + assert(Template.parse("{{|test}}")) end with_error_mode(:strict) do assert_raises(SyntaxError) { Template.parse("{{|test}}") } assert_raises(SyntaxError) { Template.parse("{{test |a|b|}}") } @@ -60,19 +62,19 @@ end end end def test_no_error_on_lax_empty_filter - assert Template.parse("{{test |a|b|}}", error_mode: :lax) - assert Template.parse("{{test}}", error_mode: :lax) - assert Template.parse("{{|test|}}", error_mode: :lax) + assert(Template.parse("{{test |a|b|}}", error_mode: :lax)) + assert(Template.parse("{{test}}", error_mode: :lax)) + assert(Template.parse("{{|test|}}", error_mode: :lax)) end def test_meaningless_parens_lax with_error_mode(:lax) do assigns = { 'b' => 'bar', 'c' => 'baz' } - markup = "a == 'foo' or (b == 'bar' and c == 'baz') or false" + markup = "a == 'foo' or (b == 'bar' and c == 'baz') or false" assert_template_result(' YES ', "{% if #{markup} %} YES {% endif %}", assigns) end end def test_unexpected_characters_silently_eat_logic_lax @@ -112,9 +114,19 @@ def test_extra_dots_in_ranges with_error_mode(:lax) do assert_template_result('12345', "{% for i in (1...5) %}{{ i }}{% endfor %}") end + end + + def test_blank_variable_markup + assert_template_result('', "{{}}") + end + + def test_lookup_on_var_with_literal_name + assigns = { "blank" => { "x" => "result" } } + assert_template_result('result', "{{ blank.x }}", assigns) + assert_template_result('result', "{{ blank['x'] }}", assigns) end def test_contains_in_id assert_template_result(' YES ', '{% if containsallshipments == true %} YES {% endif %}', 'containsallshipments' => true) end