mirror of
https://github.com/Shopify/liquid.git
synced 2025-10-22 00:01:31 -04:00
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
88 lines
2.1 KiB
Ruby
88 lines
2.1 KiB
Ruby
require 'test_helper'
|
|
|
|
class TestClassA
|
|
liquid_methods :allowedA, :chainedB
|
|
def allowedA
|
|
'allowedA'
|
|
end
|
|
def restrictedA
|
|
'restrictedA'
|
|
end
|
|
def chainedB
|
|
TestClassB.new
|
|
end
|
|
end
|
|
|
|
class TestClassB
|
|
liquid_methods :allowedB, :chainedC
|
|
def allowedB
|
|
'allowedB'
|
|
end
|
|
def chainedC
|
|
TestClassC.new
|
|
end
|
|
end
|
|
|
|
class TestClassC
|
|
liquid_methods :allowedC
|
|
def allowedC
|
|
'allowedC'
|
|
end
|
|
end
|
|
|
|
class TestClassC::LiquidDropClass
|
|
def another_allowedC
|
|
'another_allowedC'
|
|
end
|
|
end
|
|
|
|
class ModuleExUnitTest < Minitest::Test
|
|
include Liquid
|
|
|
|
def setup
|
|
@a = TestClassA.new
|
|
@b = TestClassB.new
|
|
@c = TestClassC.new
|
|
end
|
|
|
|
def test_should_create_LiquidDropClass
|
|
assert TestClassA::LiquidDropClass
|
|
assert TestClassB::LiquidDropClass
|
|
assert TestClassC::LiquidDropClass
|
|
end
|
|
|
|
def test_should_respond_to_liquid
|
|
assert @a.respond_to?(:to_liquid)
|
|
assert @b.respond_to?(:to_liquid)
|
|
assert @c.respond_to?(:to_liquid)
|
|
end
|
|
|
|
def test_should_return_LiquidDropClass_object
|
|
assert @a.to_liquid.is_a?(TestClassA::LiquidDropClass)
|
|
assert @b.to_liquid.is_a?(TestClassB::LiquidDropClass)
|
|
assert @c.to_liquid.is_a?(TestClassC::LiquidDropClass)
|
|
end
|
|
|
|
def test_should_respond_to_liquid_methods
|
|
assert @a.to_liquid.respond_to?(:allowedA)
|
|
assert @a.to_liquid.respond_to?(:chainedB)
|
|
assert @b.to_liquid.respond_to?(:allowedB)
|
|
assert @b.to_liquid.respond_to?(:chainedC)
|
|
assert @c.to_liquid.respond_to?(:allowedC)
|
|
assert @c.to_liquid.respond_to?(:another_allowedC)
|
|
end
|
|
|
|
def test_should_not_respond_to_restricted_methods
|
|
assert ! @a.to_liquid.respond_to?(:restricted)
|
|
end
|
|
|
|
def test_should_use_regular_objects_as_drops
|
|
assert_template_result 'allowedA', "{{ a.allowedA }}", 'a'=>@a
|
|
assert_template_result 'allowedB', "{{ a.chainedB.allowedB }}", 'a'=>@a
|
|
assert_template_result 'allowedC', "{{ a.chainedB.chainedC.allowedC }}", 'a'=>@a
|
|
assert_template_result 'another_allowedC', "{{ a.chainedB.chainedC.another_allowedC }}", 'a'=>@a
|
|
assert_template_result '', "{{ a.restricted }}", 'a'=>@a
|
|
assert_template_result '', "{{ a.unknown }}", 'a'=>@a
|
|
end
|
|
end # ModuleExTest
|