require File.expand_path('../helper', __FILE__)
begin
require 'radius'
class RadiusTest < Test::Unit::TestCase
def radius_app(&block)
mock_app do
set :views, File.dirname(__FILE__) + '/views'
get('/', &block)
end
get '/'
end
it 'renders inline radius strings' do
radius_app { radius '
Hiya
' }
assert ok?
assert_equal "Hiya
", body
end
it 'renders .radius files in views path' do
radius_app { radius :hello }
assert ok?
assert_equal "Hello From Radius
\n", body
end
it "renders with inline layouts" do
mock_app do
layout { "THIS. IS.
" }
get('/') { radius 'SPARTA' }
end
get '/'
assert ok?
assert_equal "THIS. IS. SPARTA
", body
end
it "renders with file layouts" do
radius_app { radius 'Hello World', :layout => :layout2 }
assert ok?
assert_equal "Radius Layout!
\nHello World
\n", body
end
it "raises error if template not found" do
mock_app { get('/') { radius :no_such_template } }
assert_raise(Errno::ENOENT) { get('/') }
end
it "allows passing locals" do
radius_app {
radius '', :locals => { :value => 'foo' }
}
assert ok?
assert_equal 'foo', body
end
end
rescue LoadError
warn "#{$!.to_s}: skipping radius tests"
end