Sha256: efe5703b5da52ac3283b9e5a1f530616fb5d55cb47ffa4e6e5db0d8cfce5d3b7

Contents?: true

Size: 895 Bytes

Versions: 4

Compression:

Stored size: 895 Bytes

Contents

require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))

begin
  require 'tilt/erb'
rescue LoadError
  warn "tilt not installed, skipping content_for plugin test"  
else
describe "content_for plugin" do
  before do
    app(:bare) do
      plugin :render, :views=>'./spec/views'
      plugin :content_for

      route do |r|
        r.root do
          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
      end
    end
  end

  it "should be able to set content in template and get that content in the layout" do
    body.strip.should == "bar foo"
  end

  it "should work if content is not set by the template" do
    body('/a').strip.should == "bar"
  end
end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
roda-2.2.0 spec/plugin/content_for_spec.rb
roda-2.1.0 spec/plugin/content_for_spec.rb
roda-2.0.0 spec/plugin/content_for_spec.rb
roda-1.3.0 spec/plugin/content_for_spec.rb