require 'spec/helper' class TCActionLayout < Ramaze::Controller map '/' layout '/wrapper' def wrapper "
#@content" end def index 'Hello, World!' end def foo "bar" end end class TCActionOtherLayout < Ramaze::Controller map '/other' layout '/other_wrapper' template_root __DIR__/:template def index "Others Hello" end end class TCActionSingleLayout < Ramaze::Controller map '/single' layout '/single_wrapper' => :index def index "Single Hello" end def without "Without wrapper" end end class TCActionDenyLayout < Ramaze::Controller map '/deny' layout '/single_wrapper' deny_layout :without def index "Single Hello" end def without "Without wrapper" end end class TCActionMultiLayout < Ramaze::Controller map '/multi' layout '/single_wrapper' => [:index, :second] def index "Single Hello" end def second "Second with layout" end def without "Without wrapper" end end class TCActionSubLayout < Ramaze::Controller map '/sub' layout :sub_wrapper def index "Sub Hello" end end describe 'Action rendering' do before :all do ramaze end it 'should work with layouts' do get('/').body.should == "
Hello, World!" get('/foo').body.should == "
bar" get('/bar').body.should == "
Hello from bar" end it 'should work with layout from file' do get('/other').body.should == "
Others Hello
" get('/other/bar').body.should == "Hello from bar
" end it 'should apply single layout' do get('/single').body.should == "Single Hello" get('/single/without').body.should == "Without wrapper" end it 'should deny a single action' do get('/deny').body.should == "Single Hello" get('/deny/without').body.should == "Without wrapper" end it 'should apply layout to a list of actions' do get('/multi').body.should == "Single Hello" get('/multi/second').body.should == "Second with layout" get('/multi/without').body.should == "Without wrapper" end it 'should apply relative layouts' do get('/sub').body.should == "