require 'spec_helper' describe Templates do let (:app) do mock_app do get '/without_layout' do render template('index.erb') end get '/with_layout' do render template('layout.erb') do render template('index.erb') end end get '/instance_var' do @foo = 'bar' render template('instance.erb') end get '/local_var' do render template('local.erb'), :foo => 'bar' end end end it 'renders correctly without layout' do response = app.get('/without_layout') response.body.should == '

Hello!

' end it 'passes a instance variable to template' do response = app.get('/instance_var') response.body.should == 'bar' end it 'passes a local variable to template' do response = app.get('/local_var') response.body.should == 'bar' end it 'renders correctly with layout' do response = app.get('/with_layout') rendered = Tilt.new(template('layout.erb')).render do Tilt.new(template('index.erb')).render end response.body.should == rendered end end