Skip to content

Commit

Permalink
Improve specs for yield_content with default block
Browse files Browse the repository at this point in the history
  • Loading branch information
jkowens committed Dec 8, 2018
1 parent ac36e38 commit bf2cb85
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion sinatra-contrib/spec/content_for/yield_block.erb
@@ -1 +1 @@
<% yield_content :foo do %>bar<% end %>
<% yield_content :foo do %>baz<% end %>
2 changes: 1 addition & 1 deletion sinatra-contrib/spec/content_for/yield_block.erubis
@@ -1 +1 @@
<% yield_content :foo do %>bar<% end %>
<% yield_content :foo do %>baz<% end %>
2 changes: 1 addition & 1 deletion sinatra-contrib/spec/content_for/yield_block.haml
@@ -1,2 +1,2 @@
= yield_content :foo do
bar
baz
2 changes: 1 addition & 1 deletion sinatra-contrib/spec/content_for/yield_block.slim
@@ -1,2 +1,2 @@
= yield_content :foo do
| bar
| baz
20 changes: 13 additions & 7 deletions sinatra-contrib/spec/content_for_spec.rb
Expand Up @@ -205,14 +205,20 @@ def body
end
end

it 'renders content' do
expect(get('/yield_block/different_key')).to be_ok
expect(body).to eq("bar")
end
describe 'with a default content block' do
describe 'when content_for key exists' do
it 'ignores default content and renders content' do
expect(get('/yield_block/same_key')).to be_ok
expect(body).to eq("foo")
end
end

it 'renders default content' do
expect(get('/yield_block/same_key')).to be_ok
expect(body).to eq("foo")
describe 'when content_for key is missing' do
it 'renders default content block' do
expect(get('/yield_block/different_key')).to be_ok
expect(body).to eq("baz")
end
end
end

it 'renders content set as parameter' do
Expand Down

0 comments on commit bf2cb85

Please sign in to comment.