1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00
haml--haml/haml-spec/ruby_haml_test.rb
2015-03-23 00:32:40 +09:00

25 lines
892 B
Ruby

$:.unshift File.expand_path('../../lib', __FILE__)
require "rubygems"
require "minitest/autorun"
require "json"
require "hamlit"
class HamlTest < MiniTest::Unit::TestCase
contexts = JSON.parse(File.read(File.dirname(__FILE__) + "/tests.json"))
contexts.each do |context|
context[1].each do |name, test|
define_method("test_spec: #{name} (#{context[0]})") do
html = test["html"]
haml = test["haml"]
locals = Hash[(test["locals"] || {}).map {|x, y| [x.to_sym, y]}]
options = Hash[(test["config"] || {}).map {|x, y| [x.to_sym, y]}]
options[:format] = options[:format].to_sym if options.key?(:format)
engine = Hamlit::Template.new(options) { haml }
result = engine.render(Object.new, locals)
assert_equal html, result.strip
end
end
end
end