Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 51 lines (44 sloc) 1.033 kb
c00a25e @rtomayko Test framework refactoring
rtomayko authored
1 require File.dirname(__FILE__) + '/helper'
a734cf3 @rtomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
2
3 describe "ERB Templates" do
4 def erb_app(&block)
5 mock_app {
6 set :views, File.dirname(__FILE__) + '/views'
7 get '/', &block
8 }
9 get '/'
becd6d8 ERB in place
Blake Mizerany authored
10 end
60d5006 @rtomayko Fix whitespace errors across all source files and tests
rtomayko authored
11
a734cf3 @rtomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
12 it 'renders inline ERB strings' do
13 erb_app { erb '<%= 1 + 1 %>' }
72a6e01 @rtomayko use Test::Unit style assertions in Sinatra specs
rtomayko authored
14 assert ok?
15 assert_equal '2', body
becd6d8 ERB in place
Blake Mizerany authored
16 end
60d5006 @rtomayko Fix whitespace errors across all source files and tests
rtomayko authored
17
a734cf3 @rtomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
18 it 'renders .erb files in views path' do
19 erb_app { erb :hello }
72a6e01 @rtomayko use Test::Unit style assertions in Sinatra specs
rtomayko authored
20 assert ok?
21 assert_equal "Hello World\n", body
becd6d8 ERB in place
Blake Mizerany authored
22 end
7d5bc1f Haml & Erb redo
Blake Mizerany authored
23
a734cf3 @rtomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
24 it 'takes a :locals option' do
25 erb_app {
26 locals = {:foo => 'Bar'}
27 erb '<%= foo %>', :locals => locals
28 }
72a6e01 @rtomayko use Test::Unit style assertions in Sinatra specs
rtomayko authored
29 assert ok?
30 assert_equal 'Bar', body
a734cf3 @rtomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
31 end
7d5bc1f Haml & Erb redo
Blake Mizerany authored
32
a734cf3 @rtomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
33 it "renders with inline layouts" do
34 mock_app {
35 layout { 'THIS. IS. <%= yield.upcase %>!' }
36 get('/') { erb 'Sparta' }
37 }
38 get '/'
72a6e01 @rtomayko use Test::Unit style assertions in Sinatra specs
rtomayko authored
39 assert ok?
40 assert_equal 'THIS. IS. SPARTA!', body
a734cf3 @rtomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
41 end
7d5bc1f Haml & Erb redo
Blake Mizerany authored
42
a734cf3 @rtomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
43 it "renders with file layouts" do
44 erb_app {
45 erb 'Hello World', :layout => :layout2
46 }
72a6e01 @rtomayko use Test::Unit style assertions in Sinatra specs
rtomayko authored
47 assert ok?
48 assert_equal "ERB Layout!\nHello World\n", body
7d5bc1f Haml & Erb redo
Blake Mizerany authored
49 end
becd6d8 ERB in place
Blake Mizerany authored
50 end
Something went wrong with that request. Please try again.