Sha256: fb80004a13d3d33529b51f9845002e686f2ab0ac2963b77d4b384c47f45a3443

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

require File.dirname(__FILE__) + '/helper'

class UnlessElseTest < Test::Unit::TestCase
  include Liquid

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

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

  def test_unless_in_loop
    assert_template_result '23', '{% for i in choices %}{% unless i %}{{ forloop.index }}{% end %}{% end %}', '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 {% end %}{% end %}', 'choices' => [1, nil, false]
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
drnic-liquid-2.1.0 test/unless_else_test.rb