add tests for calling yield_content more than once

This commit is contained in:
Konstantin Haase 2011-03-28 17:12:43 +02:00
parent 3eb5e41529
commit 5360a0d930
5 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,3 @@
<%= yield_content :foo %>
<%= yield_content :foo %>
<%= yield_content :foo %>

View File

@ -0,0 +1,3 @@
<%= yield_content :foo %>
<%= yield_content :foo %>
<%= yield_content :foo %>

View File

@ -0,0 +1,3 @@
= yield_content :foo
= yield_content :foo
= yield_content :foo

View File

@ -0,0 +1,3 @@
= yield_content :foo
= yield_content :foo
= yield_content :foo

View File

@ -37,6 +37,11 @@ describe Sinatra::ContentFor do
body.should == "foo"
end
it 'renders blocks more than once' do
get('/multiple_yields/same_key').should be_ok
body.should == "foofoofoo"
end
it 'does not render a block with a different key' do
get('/different_key').should be_ok
body.should == ""
@ -47,6 +52,11 @@ describe Sinatra::ContentFor do
body.should == "foobarbaz"
end
it 'renders multiple blocks more than once' do
get('/multiple_yields/multiple_blocks').should be_ok
body.should == "foobarbazfoobarbazfoobarbaz"
end
it 'passes values to the blocks' do
get('/passes_values/takes_values').should be_ok
body.should == "<i>1</i>2"