require 'spec_helper' describe InlineTemplates do describe 'render' do it 'builds elements' do test_rit do ~ span('test') end.should == "test" end it 'builds multiple elements' do test_rit do ~ span('test 1') ~ span('test 2') end.should == "test 1test 2" end it 'captures' do test_rit do ~ div do ~ span('test') end end.should == "
test
" end it 'handles locals and conditionals' do locals = { :cond => true, :a => 'foo', :b => 'bar' } test_block = proc do if cond ~ a else ~ b end end test_rit(locals, &test_block).should == "foo" locals[:cond] = false test_rit(locals, &test_block).should == "bar" end it 'supports response postprocessing' do test_rit do e1 = div 'foo' e2 = span 'bar' ~ (e1 + e2) end.should == "
foo
bar" end it 'properly handles nested blocks' do locals = { :list => [ '1', '2', '3', '4' ] } test_rit(locals) do ~ ul do list.each do |item| ~ li(item) end end end.should == '' end it 'implements t helper' do test_rit do ~ t('
') end.should == "<br />" end it 'implements h helper' do test_rit do ~ h('
') end.should == "
" end it 'passes instance variables' do test_rit do ~ @virtual_path end.should == "(inline)" end it 'wraps output of builders' do test_rit do ~ form_for(:foo, :url => "foo", :authenticity_token => false) do |f| ~ f.submit end end.should == "
" end end end