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_multi
template = <<-END
END
expected = {
'foo/bar' => "<%= h product[:price] %>
",
'baz/caz' => "<%= h product[:name] %>
"
}
assert_template_result expected, template
end
def test_multi_spec_dir
template = <<-END
END
expected = {
'/a/b/foo/bar' => "<%= h product[:price] %>
",
'/a/b/baz/caz' => "<%= h product[:name] %>
"
}
assert_template_result expected, template, :output_dir => '/a/b'
end
def test_replace
template = <<-END
foo bar
END
expected = {
'foo/bar' => "<%= h product[:price] %>
"
}
assert_template_result expected, template
end
def test_block_and_content
template = <<-END
END
expected = {
'foo/bar' => "<% @products.each do |product| %>Name: | <%= product.name %> |
<% end %>
"
}
assert_template_result expected, template
end
def test_form
template = <<-END
END
expected = {
'foo/bar' => "<%= form_tag {:action => 'create'}, :method => \"get\" %>hello world <%= end_form_tag %>
"
}
assert_template_result expected, template
end
def test_link_to
template = <<-END
END
expected = {
'foo/bar' => "<%= link_to 'Hello World', :action => 'show', :id => @product %>
"
}
assert_template_result expected, template
end
def test_link_to_if
template = <<-END
END
expected = {
'foo/bar' => "<%= link_to_if @product_pages.current.previous, 'Previous page', {:page => @product_pages.current.previous } %>
"
}
assert_template_result expected, template
end
def test_submit
template = <<-END
END
expected = {
'foo/bar' => "<%= submit_tag 'Hello World', :foo => 'bar' %>
"
}
assert_template_result expected, template
end
def test_text_field
template = <<-END
END
expected = {
'foo/bar' => "<%= text_field 'product', 'price', :maxlength => 21, :size => 10 %>
"
}
assert_template_result expected, template
end
def test_hidden_field
template = <<-END
END
expected = {
'foo/bar' => "<%= hidden_field 'product', 'price' %>
"
}
assert_template_result expected, template
end
def test_password_field
template = <<-END
END
expected = {
'foo/bar' => "<%= password_field 'product', 'price', :maxlength => 21, :size => 10 %>
"
}
assert_template_result expected, template
end
def test_text_area
template = <<-END
END
expected = {
'foo/bar' => "<%= text_area 'product', 'desc', :class => \"foo\", :cols => 21, :disabled => true, :readonly => true, :rows => 10, :style => \"bar\" %>
"
}
assert_template_result expected, template
end
def test_example
template = <<-END
foo bar
END
expected = {
'foo/bar' => "<%= h product[:price] %>
"
}
assert_template_result expected, template
end
end