spec/plugin/content_for_spec.rb in roda-2.8.0 vs spec/plugin/content_for_spec.rb in roda-2.9.0
- old
+ new
@@ -17,10 +17,13 @@
view(:inline => "<% content_for :foo do %>foo<% end %>bar", :layout => { :inline => '<%= yield %> <%= content_for(:foo) %>' })
end
r.get 'a' do
view(:inline => "bar", :layout => { :inline => '<%= content_for(:foo) %> <%= yield %>' })
end
+ r.get 'b' do
+ view(:inline => '<% content_for(:foo, "foo") %>bar', :layout => { :inline => '<%= yield %> <%= content_for(:foo) %>' })
+ end
end
end
end
it "should be able to set content in template and get that content in the layout" do
@@ -28,10 +31,14 @@
end
it "should work if content is not set by the template" do
body('/a').strip.must_equal "bar"
end
+
+ it "should work if a raw string is set" do
+ body('/b').strip.must_equal "bar foo"
+ end
end
describe "content_for plugin with haml" do
before do
app(:bare) do
@@ -40,16 +47,20 @@
route do |r|
r.root do
view(:inline => "- content_for :foo do\n - capture_haml do\n foo\nbar", :layout => { :inline => "= yield\n=content_for :foo" })
end
+ r.get 'a' do
+ view(:inline => "- content_for :foo, 'foo'\nbar", :layout => { :inline => "= yield\n=content_for :foo" })
+ end
end
end
end
it "should work with alternate rendering engines" do
body.strip.must_equal "bar\nfoo"
+ body('/a').strip.must_equal "bar\nfoo"
end
end
describe "content_for plugin with mixed template engines" do
before do
@@ -59,16 +70,20 @@
route do |r|
r.root do
view(:inline => "<% content_for :foo do %>foo<% end %>bar")
end
+ r.get 'a' do
+ view(:inline => "<% content_for :foo, 'foo' %>bar")
+ end
end
end
end
it "should work with alternate rendering engines" do
body.strip.must_equal "bar\nfoo"
+ body('/a').strip.must_equal "bar\nfoo"
end
end
describe "content_for plugin when overriding :engine" do
before do
@@ -78,14 +93,18 @@
route do |r|
r.root do
view(:inline => "<% content_for :foo do %>foo<% end %>bar", :engine=>:erb)
end
+ r.get 'a' do
+ view(:inline => "<% content_for :foo, 'foo' %>bar", :engine=>:erb)
+ end
end
end
end
it "should work with alternate rendering engines" do
body.strip.must_equal "bar\nfoo"
+ body('/a').strip.must_equal "bar\nfoo"
end
end
end