Files
liquid/test/unit/block_unit_test.rb
Ken Dreyer ee4295c889 tests: switch to minitest
Ruby 1.9+ uses Minitest as the backend for Test::Unit. As of Minitest 5,
the shim has broken some compatibility with Test::Unit::TestCase in some
scenarios.

Adjusts the test suite to support Minitest 5's syntax.

Minitest versions 4 and below do not support the newer Minitest::Test
class that arrived in version 5. For that case, use the
MiniTest::Unit::TestCase class as a fallback

Conflicts:
	test/integration/tags/for_tag_test.rb
	test/test_helper.rb
2014-07-28 16:36:38 +00:00

56 lines
1.8 KiB
Ruby

require 'test_helper'
class BlockUnitTest < Minitest::Test
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 Liquid::Template.parse( "{% testtag %} {% endtesttag %}")
end
private
def block_types(nodelist)
nodelist.collect { |node| node.class }
end
end # VariableTest