Sha256: f01e1de4215c7a0f0e36e5222f451cf92eae744948342fdb673429ac240eb189

Contents?: true

Size: 1.21 KB

Versions: 11

Compression:

Stored size: 1.21 KB

Contents

require 'test_helper'

class UnlessElseTagTest < Minitest::Test
  include Liquid

  def test_unless
    assert_template_result('  ',' {% unless true %} this text should not go into the output {% endunless %} ')
    assert_template_result('  this text should go into the output  ',
                           ' {% unless false %} this text should go into the output {% endunless %} ')
    assert_template_result('  you rock ?','{% unless true %} you suck {% endunless %} {% unless false %} you rock {% endunless %}?')
  end

  def test_unless_else
    assert_template_result(' YES ','{% unless true %} NO {% else %} YES {% endunless %}')
    assert_template_result(' YES ','{% unless false %} YES {% else %} NO {% endunless %}')
    assert_template_result(' YES ','{% unless "foo" %} NO {% else %} YES {% endunless %}')
  end

  def test_unless_in_loop
    assert_template_result '23', '{% for i in choices %}{% unless i %}{{ forloop.index }}{% endunless %}{% endfor %}', 'choices' => [1, nil, false]
  end

  def test_unless_else_in_loop
    assert_template_result ' TRUE  2  3 ', '{% for i in choices %}{% unless i %} {{ forloop.index }} {% else %} TRUE {% endunless %}{% endfor %}', 'choices' => [1, nil, false]
  end
end # UnlessElseTest

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
locomotivecms-liquid-4.0.0 test/integration/tags/unless_else_tag_test.rb
liquid-3.0.6 test/integration/tags/unless_else_tag_test.rb
liquid-3.0.5 test/integration/tags/unless_else_tag_test.rb
liquid-3.0.4 test/integration/tags/unless_else_tag_test.rb
liquid-3.0.3 test/integration/tags/unless_else_tag_test.rb
liquid-3.0.2 test/integration/tags/unless_else_tag_test.rb
locomotivecms-liquid-4.0.0.alpha2 test/integration/tags/unless_else_tag_test.rb
locomotivecms-liquid-4.0.0.alpha1 test/integration/tags/unless_else_tag_test.rb
locomotivecms-liquid-4.0.0.alpha test/integration/tags/unless_else_tag_test.rb
liquid-3.0.1 test/integration/tags/unless_else_tag_test.rb
liquid-3.0.0 test/integration/tags/unless_else_tag_test.rb