Sha256: bf898ff0723f52adab067e0b8ae342dd01609bb0843ff1e784a927e8309fd32e

Contents?: true

Size: 1.81 KB

Versions: 12

Compression:

Stored size: 1.81 KB

Contents

require 'test_helper'

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

  def test_blankspace
    template = Liquid::Template.parse("  ")
    assert_equal ["  "], template.root.nodelist
  end

  def test_variable_beginning
    template = Liquid::Template.parse("{{funk}}  ")
    assert_equal 2, template.root.nodelist.size
    assert_equal Variable, template.root.nodelist[0].class
    assert_equal String, template.root.nodelist[1].class
  end

  def test_variable_end
    template = Liquid::Template.parse("  {{funk}}")
    assert_equal 2, template.root.nodelist.size
    assert_equal String, template.root.nodelist[0].class
    assert_equal Variable, template.root.nodelist[1].class
  end

  def test_variable_middle
    template = Liquid::Template.parse("  {{funk}}  ")
    assert_equal 3, template.root.nodelist.size
    assert_equal String, template.root.nodelist[0].class
    assert_equal Variable, template.root.nodelist[1].class
    assert_equal String, template.root.nodelist[2].class
  end

  def test_variable_many_embedded_fragments
    template = Liquid::Template.parse("  {{funk}} {{so}} {{brother}} ")
    assert_equal 7, template.root.nodelist.size
    assert_equal [String, Variable, String, Variable, String, Variable, String],
                 block_types(template.root.nodelist)
  end

  def test_with_block
    template = Liquid::Template.parse("  {% comment %} {% endcomment %} ")
    assert_equal [String, Comment, String], block_types(template.root.nodelist)
    assert_equal 3, template.root.nodelist.size
  end

  def test_with_custom_tag
    Liquid::Template.register_tag("testtag", Block)

    assert_nothing_thrown do
      template = Liquid::Template.parse( "{% testtag %} {% endtesttag %}")
    end
  end

  private
    def block_types(nodelist)
      nodelist.collect { |node| node.class }
    end
end # VariableTest

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
liquid-2.6.3 test/liquid/block_test.rb
liquid-2.6.2 test/liquid/block_test.rb
liquid-2.6.1 test/liquid/block_test.rb
liquid-2.5.5 test/liquid/block_test.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/liquid-2.6.0/test/liquid/block_test.rb
liquid-2.6.0 test/liquid/block_test.rb
liquid-2.5.4 test/liquid/block_test.rb
liquid-2.6.0.rc1 test/liquid/block_test.rb
liquid-2.5.3 test/liquid/block_test.rb
liquid-2.5.1 test/liquid/block_test.rb
wordify_liquid-2.5.1 test/liquid/block_test.rb
liquid-2.5.0 test/liquid/block_test.rb