Skip to content

Commit

Permalink
Merge pull request #1641 from Shopify/assert-template-result-static-env
Browse files Browse the repository at this point in the history
Use static environment assert_template_result input values
  • Loading branch information
dylanahsmith committed Nov 2, 2022
2 parents 29732f4 + a39422f commit 1cd5ec5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions test/integration/tags/increment_tag_test.rb
Expand Up @@ -6,20 +6,21 @@ class IncrementTagTest < Minitest::Test
include Liquid

def test_inc
assert_template_result('0', '{%increment port %}', {})
assert_template_result('0 1', '{%increment port %} {%increment port%}', {})
assert_template_result('0 1', '{%increment port %} {{ port }}')
assert_template_result(' 0 1 2', '{{port}} {%increment port %} {%increment port%} {{port}}')
assert_template_result('0 0 1 2 1',
'{%increment port %} {%increment starboard%} ' \
'{%increment port %} {%increment port%} ' \
'{%increment starboard %}', {})
'{%increment starboard %}')
end

def test_dec
assert_template_result('9', '{%decrement port %}', { 'port' => 10 })
assert_template_result('-1 -2', '{%decrement port %} {%decrement port%}', {})
assert_template_result('1 5 2 2 5',
assert_template_result('-1 -1', '{%decrement port %} {{ port }}', { 'port' => 10 })
assert_template_result(' -1 -2 -2', '{{port}} {%decrement port %} {%decrement port%} {{port}}')
assert_template_result('0 1 2 0 3 1 1 3',
'{%increment starboard %} {%increment starboard%} {%increment starboard%} ' \
'{%increment port %} {%increment starboard%} ' \
'{%increment port %} {%decrement port%} ' \
'{%decrement starboard %}', { 'port' => 1, 'starboard' => 5 })
'{%decrement starboard %}')
end
end
2 changes: 1 addition & 1 deletion test/test_helper.rb
Expand Up @@ -44,7 +44,7 @@ def assert_template_result(
template = Liquid::Template.parse(template, line_numbers: true, error_mode: error_mode&.to_sym)
file_system = StubFileSystem.new(partials || {})
registers = Liquid::Registers.new(file_system: file_system)
context = Liquid::Context.build(environments: assigns, rethrow_errors: !render_errors, registers: registers)
context = Liquid::Context.build(static_environments: assigns, rethrow_errors: !render_errors, registers: registers)
output = template.render(context)
assert_equal(expected, output, message)
end
Expand Down

0 comments on commit 1cd5ec5

Please sign in to comment.