diff --git a/test/integration/tags/for_tag_test.rb b/test/integration/tags/for_tag_test.rb index 4dde8a4..120f7fa 100644 --- a/test/integration/tags/for_tag_test.rb +++ b/test/integration/tags/for_tag_test.rb @@ -1,5 +1,11 @@ require 'test_helper' +class ThingWithValue < Liquid::Drop + def value + 3 + end +end + class ForTagTest < Test::Unit::TestCase include Liquid @@ -34,6 +40,20 @@ HERE assert_template_result(' 1 2 3 ','{%for item in (1..3) %} {{item}} {%endfor%}') end + def test_for_with_variable_range + assert_template_result(' 1 2 3 ','{%for item in (1..foobar) %} {{item}} {%endfor%}', "foobar" => 3) + end + + def test_for_with_hash_value_range + foobar = { "value" => 3 } + assert_template_result(' 1 2 3 ','{%for item in (1..foobar.value) %} {{item}} {%endfor%}', "foobar" => foobar) + end + + def test_for_with_drop_value_range + foobar = ThingWithValue.new + assert_template_result(' 1 2 3 ','{%for item in (1..foobar.value) %} {{item}} {%endfor%}', "foobar" => foobar) + end + def test_for_with_variable assert_template_result(' 1 2 3 ','{%for item in array%} {{item}} {%endfor%}','array' => [1,2,3]) assert_template_result('123','{%for item in array%}{{item}}{%endfor%}','array' => [1,2,3])