-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathruby_haml_test.rb
More file actions
23 lines (21 loc) · 877 Bytes
/
ruby_haml_test.rb
File metadata and controls
23 lines (21 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require "rubygems"
require "minitest/autorun"
require "json"
require "haml"
class HamlTest < (defined?(Minitest::Test) ? Minitest::Test : 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 = Haml::Engine.new(haml, options)
result = engine.render(Object.new, locals)
assert_equal html, result.strip
end
end
end
end