test/template_test.rb in masterview-0.0.11 vs test/template_test.rb in masterview-0.0.12
- old
+ new
@@ -1,11 +1,48 @@
+#!/usr/bin/env ruby
+
require 'test/unit'
currentPath = File.dirname(__FILE__)
require File.join( currentPath, '../lib/masterview' )
require File.join( currentPath, 'test_helper' )
-include MasterView::Directives
class TestTemplate < Test::Unit::TestCase
+
+ def test_attr
+ template = <<-END
+ <div mv:generate='foo/bar'>
+ <span class="red" mv:attr=":class => 'blue', :id => 'testid'">foo bar</span>
+ </div>
+ END
+ expected = {
+ 'foo/bar' => "<div><span class=\"blue\" id=\"testid\">foo bar</span></div>"
+ }
+ assert_template_result expected, template
+ end
+
+ def test_attr_erb
+ template = <<-END
+ <div mv:generate='foo/bar'>
+ <span class="red" mv:attr=":class => 'blue', :id => '{{{= @product.id }}}'">foo bar</span>
+ </div>
+ END
+ expected = {
+ 'foo/bar' => "<div><span class=\"blue\" id=\"<%= @product.id %>\">foo bar</span></div>"
+ }
+ assert_template_result expected, template
+ end
+
+ def test_attr_erb2
+ template = <<-END
+ <div mv:generate='foo/bar'>
+ <span class="red" mv:attr=":class => 'blue', :id => \#\{@product.id\}">foo bar</span>
+ </div>
+ END
+ expected = {
+ 'foo/bar' => "<div><span class=\"blue\" id=\"<%= @product.id %>\">foo bar</span></div>"
+ }
+ assert_template_result expected, template
+ end
def test_multi
template = <<-END
<div mv:generate='foo/bar'>
<span mv:replace="h product[:price]">foo bar</span>