mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
test both ERB and Erubis
This commit is contained in:
parent
8f76d3b49b
commit
b3e82c5293
1 changed files with 23 additions and 0 deletions
|
@ -1,6 +1,15 @@
|
|||
require File.dirname(__FILE__) + '/helper'
|
||||
|
||||
class ERBTest < Test::Unit::TestCase
|
||||
def engine
|
||||
Tilt::ERBTemplate
|
||||
end
|
||||
|
||||
def setup
|
||||
Tilt.prefer engine, :erb
|
||||
super
|
||||
end
|
||||
|
||||
def erb_app(&block)
|
||||
mock_app {
|
||||
set :views, File.dirname(__FILE__) + '/views'
|
||||
|
@ -9,6 +18,10 @@ class ERBTest < Test::Unit::TestCase
|
|||
get '/'
|
||||
end
|
||||
|
||||
it 'uses the correct engine' do
|
||||
assert_equal engine, Tilt[:erb]
|
||||
end
|
||||
|
||||
it 'renders inline ERB strings' do
|
||||
erb_app { erb '<%= 1 + 1 %>' }
|
||||
assert ok?
|
||||
|
@ -79,3 +92,13 @@ class ERBTest < Test::Unit::TestCase
|
|||
assert_equal '<outer><inner>hi</inner></outer>', body
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
begin
|
||||
require 'erubis'
|
||||
class ErubisTest < ERBTest
|
||||
def engine; Tilt::ErubisTemplate end
|
||||
end
|
||||
rescue LoadError
|
||||
warn "#{$!.to_s}: skipping erubis tests"
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue