Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

51 lines (44 sloc) 1.033 kb
require File.dirname(__FILE__) + '/helper'
describe "ERB Templates" do
def erb_app(&block)
mock_app {
set :views, File.dirname(__FILE__) + '/views'
get '/', &block
}
get '/'
end
it 'renders inline ERB strings' do
erb_app { erb '<%= 1 + 1 %>' }
assert ok?
assert_equal '2', body
end
it 'renders .erb files in views path' do
erb_app { erb :hello }
assert ok?
assert_equal "Hello World\n", body
end
it 'takes a :locals option' do
erb_app {
locals = {:foo => 'Bar'}
erb '<%= foo %>', :locals => locals
}
assert ok?
assert_equal 'Bar', body
end
it "renders with inline layouts" do
mock_app {
layout { 'THIS. IS. <%= yield.upcase %>!' }
get('/') { erb 'Sparta' }
}
get '/'
assert ok?
assert_equal 'THIS. IS. SPARTA!', body
end
it "renders with file layouts" do
erb_app {
erb 'Hello World', :layout => :layout2
}
assert ok?
assert_equal "ERB Layout!\nHello World\n", body
end
end
Jump to Line
Something went wrong with that request. Please try again.