mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
DRY'd up the tests that loop over the templates.
Also, template name is now inserted into the test method name. Nice when a certain template is having problems, because you can see the template name right in the call stack.
This commit is contained in:
parent
fb34da81bc
commit
06f0b1d190
1 changed files with 5 additions and 10 deletions
|
@ -66,26 +66,21 @@ class TemplateTest < Test::Unit::TestCase
|
|||
assert_equal('', render(''))
|
||||
end
|
||||
|
||||
def test_templates_should_render_correctly
|
||||
@@templates.each do |template|
|
||||
@@templates.each do |template|
|
||||
define_method "test_template_should_render_correctly [template: #{template}] " do
|
||||
assert_renders_correctly template
|
||||
end
|
||||
end
|
||||
|
||||
def test_templates_should_render_correctly_with_render_proc
|
||||
@@templates.each do |template|
|
||||
define_method "test_templates_should_render_correctly_with_render_proc [template: #{template}] " do
|
||||
assert_renders_correctly(template) do |name|
|
||||
engine = Haml::Engine.new(File.read(File.dirname(__FILE__) + "/templates/#{name}.haml"))
|
||||
engine.render_proc(@base).call
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_templates_should_render_correctly_with_def_method
|
||||
@@templates.each do |template|
|
||||
|
||||
define_method "test_templates_should_render_correctly_with_def_method [template: #{template}] " do
|
||||
assert_renders_correctly(template) do |name|
|
||||
method = "render_haml_" + name.gsub(/[^a-zA-Z0-9]/, '_')
|
||||
|
||||
engine = Haml::Engine.new(File.read(File.dirname(__FILE__) + "/templates/#{name}.haml"))
|
||||
engine.def_method(@base, method)
|
||||
@base.send(method)
|
||||
|
|
Loading…
Reference in a new issue