Sha256: 365ca9389e6820b1a49b6b269501033be7ff01241e0f5fa733b21e0f4582139e
Contents?: true
Size: 1.32 KB
Versions: 10
Compression:
Stored size: 1.32 KB
Contents
require 'spec_helper' describe Templates do let (:app_class) do mock_app_class do helpers do def template_root File.join(__dir__, "views") end end 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 '/via_helper' do erb :index end get '/local_var' do render template('local.erb'), :foo => 'bar' end end end let (:app) { Rack::MockRequest.new(app_class.new)} it 'renders correctly without layout' do response = app.get('/without_layout') response.body.should == '<p>Hello!</p>' 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
Version data entries
10 entries across 10 versions & 1 rubygems