Tests: 5 template helpers can nest layouts

This commit is contained in:
Alexey Muranov 2013-02-17 12:53:34 +01:00
parent 9087825161
commit ea0d9673ed
5 changed files with 89 additions and 0 deletions

View File

@ -85,6 +85,24 @@ class ERBTest < Test::Unit::TestCase
assert ok?
assert_equal '<outer><inner>hi</inner></outer>', body
end
it "can rendere truly nested layouts by accepting a layout and a block with the contents" do
mock_app do
template(:main_outer_layout) { "<h1>Title</h1>\n<%= yield %>" }
template(:an_inner_layout) { "<h2>Subtitle</h2>\n<%= yield %>" }
template(:a_page) { "<p>Contents.</p>\n" }
get('/') do
erb :main_outer_layout, :layout => false do
erb :an_inner_layout do
erb :a_page
end
end
end
end
get '/'
assert ok?
assert_body "<h1>Title</h1>\n<h2>Subtitle</h2>\n<p>Contents.</p>\n"
end
end

View File

@ -84,6 +84,24 @@ class HAMLTest < Test::Unit::TestCase
haml_app { haml "= foo", :locals => { :foo => 'bar' }}
assert_equal "bar\n", body
end
it "can rendere truly nested layouts by accepting a layout and a block with the contents" do
mock_app do
template(:main_outer_layout) { "%h1 Title\n= yield" }
template(:an_inner_layout) { "%h2 Subtitle\n= yield" }
template(:a_page) { "%p Contents." }
get('/') do
haml :main_outer_layout, :layout => false do
haml :an_inner_layout do
haml :a_page
end
end
end
end
get '/'
assert ok?
assert_body "<h1>Title</h1>\n<h2>Subtitle</h2>\n<p>Contents.</p>\n"
end
end
rescue LoadError

View File

@ -52,6 +52,24 @@ class LiquidTest < Test::Unit::TestCase
assert ok?
assert_equal 'foo', body
end
it "can rendere truly nested layouts by accepting a layout and a block with the contents" do
mock_app do
template(:main_outer_layout) { "<h1>Title</h1>\n{{ yield }}" }
template(:an_inner_layout) { "<h2>Subtitle</h2>\n{{ yield }}" }
template(:a_page) { "<p>Contents.</p>\n" }
get('/') do
liquid :main_outer_layout, :layout => false do
liquid :an_inner_layout do
liquid :a_page
end
end
end
end
get '/'
assert ok?
assert_body "<h1>Title</h1>\n<h2>Subtitle</h2>\n<p>Contents.</p>\n"
end
end
rescue LoadError

View File

@ -77,6 +77,24 @@ class SlimTest < Test::Unit::TestCase
assert ok?
assert_body '<x foo="bar"></x>'
end
it "can rendere truly nested layouts by accepting a layout and a block with the contents" do
mock_app do
template(:main_outer_layout) { "h1 Title\n== yield" }
template(:an_inner_layout) { "h2 Subtitle\n== yield" }
template(:a_page) { "p Contents." }
get('/') do
slim :main_outer_layout, :layout => false do
slim :an_inner_layout do
slim :a_page
end
end
end
end
get '/'
assert ok?
assert_body "<h1>Title</h1>\n<h2>Subtitle</h2>\n<p>Contents.</p>\n"
end
end
rescue LoadError

View File

@ -63,6 +63,23 @@ class WLangTest < Test::Unit::TestCase
assert_body "WLang Layout!\nHello World"
end
it "can rendere truly nested layouts by accepting a layout and a block with the contents" do
mock_app do
template(:main_outer_layout) { "<h1>Title</h1>\n>{ yield }" }
template(:an_inner_layout) { "<h2>Subtitle</h2>\n>{ yield }" }
template(:a_page) { "<p>Contents.</p>\n" }
get('/') do
wlang :main_outer_layout, :layout => false do
wlang :an_inner_layout do
wlang :a_page
end
end
end
end
get '/'
assert ok?
assert_body "<h1>Title</h1>\n<h2>Subtitle</h2>\n<p>Contents.</p>\n"
end
end
rescue LoadError