require 'test_helper' class HtmlTagTest < Test::Unit::TestCase include Liquid class ArrayDrop < Liquid::Drop include Enumerable def initialize(array) @array = array end def each(&block) @array.each(&block) end end def test_html_table assert_template_result("\n 1 2 3 \n 4 5 6 \n", '{% tablerow n in numbers cols:3%} {{n}} {% endtablerow %}', 'numbers' => [1,2,3,4,5,6]) assert_template_result("\n\n", '{% tablerow n in numbers cols:3%} {{n}} {% endtablerow %}', 'numbers' => []) end def test_html_table_with_different_cols assert_template_result("\n 1 2 3 4 5 \n 6 \n", '{% tablerow n in numbers cols:5%} {{n}} {% endtablerow %}', 'numbers' => [1,2,3,4,5,6]) end def test_html_col_counter assert_template_result("\n12\n12\n12\n", '{% tablerow n in numbers cols:2%}{{tablerowloop.col}}{% endtablerow %}', 'numbers' => [1,2,3,4,5,6]) end def test_quoted_fragment assert_template_result("\n 1 2 3 \n 4 5 6 \n", "{% tablerow n in collections.frontpage cols:3%} {{n}} {% endtablerow %}", 'collections' => {'frontpage' => [1,2,3,4,5,6]}) assert_template_result("\n 1 2 3 \n 4 5 6 \n", "{% tablerow n in collections['frontpage'] cols:3%} {{n}} {% endtablerow %}", 'collections' => {'frontpage' => [1,2,3,4,5,6]}) end def test_enumerable_drop assert_template_result("\n 1 2 3 \n 4 5 6 \n", '{% tablerow n in numbers cols:3%} {{n}} {% endtablerow %}', 'numbers' => ArrayDrop.new([1,2,3,4,5,6])) end def test_offset_and_limit assert_template_result("\n 1 2 3 \n 4 5 6 \n", '{% tablerow n in numbers cols:3 offset:1 limit:6%} {{n}} {% endtablerow %}', 'numbers' => [0,1,2,3,4,5,6,7]) end end # HtmlTagTest