mirror of
				https://github.com/Shopify/liquid.git
				synced 2025-11-04 00:01:04 -05: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
		
			
				
	
	
		
			58 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			58 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
#!/usr/bin/env ruby
 | 
						|
 | 
						|
require 'minitest/autorun'
 | 
						|
require 'spy/integration'
 | 
						|
 | 
						|
$:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib'))
 | 
						|
require 'liquid.rb'
 | 
						|
 | 
						|
mode = :strict
 | 
						|
if env_mode = ENV['LIQUID_PARSER_MODE']
 | 
						|
  puts "-- #{env_mode.upcase} ERROR MODE"
 | 
						|
  mode = env_mode.to_sym
 | 
						|
end
 | 
						|
Liquid::Template.error_mode = mode
 | 
						|
 | 
						|
if Minitest.const_defined?('Test')
 | 
						|
  # We're on Minitest 5+. Nothing to do here.
 | 
						|
else
 | 
						|
  # Minitest 4 doesn't have Minitest::Test yet.
 | 
						|
  Minitest::Test = MiniTest::Unit::TestCase
 | 
						|
end
 | 
						|
 | 
						|
module Minitest
 | 
						|
  class Test
 | 
						|
    def fixture(name)
 | 
						|
      File.join(File.expand_path(File.dirname(__FILE__)), "fixtures", name)
 | 
						|
    end
 | 
						|
  end
 | 
						|
 | 
						|
  module Assertions
 | 
						|
    include Liquid
 | 
						|
 | 
						|
    def assert_template_result(expected, template, assigns = {}, message = nil)
 | 
						|
      assert_equal expected, Template.parse(template).render!(assigns)
 | 
						|
    end
 | 
						|
 | 
						|
    def assert_template_result_matches(expected, template, assigns = {}, message = nil)
 | 
						|
      return assert_template_result(expected, template, assigns, message) unless expected.is_a? Regexp
 | 
						|
 | 
						|
      assert_match expected, Template.parse(template).render!(assigns)
 | 
						|
    end
 | 
						|
 | 
						|
    def assert_match_syntax_error(match, template, registers = {})
 | 
						|
      exception = assert_raises(Liquid::SyntaxError) {
 | 
						|
        Template.parse(template).render(assigns)
 | 
						|
      }
 | 
						|
      assert_match match, exception.message
 | 
						|
    end
 | 
						|
 | 
						|
    def with_error_mode(mode)
 | 
						|
      old_mode = Liquid::Template.error_mode
 | 
						|
      Liquid::Template.error_mode = mode
 | 
						|
      yield
 | 
						|
      Liquid::Template.error_mode = old_mode
 | 
						|
    end
 | 
						|
  end
 | 
						|
end
 |