Skip to content
This repository
Newer
Older
100644 60 lines (50 sloc) 1.379 kb
e001d626 »
2011-05-11 adjust require lines for test helper, so it also works properly on 1.9.2
1 require File.expand_path('../helper', __FILE__)
7cb94f2d »
2010-09-12 Add radius helper method. Tilt supports radius for quite some time no…
2
3 begin
4 require 'radius'
5
6 class RadiusTest < Test::Unit::TestCase
7 def radius_app(&block)
8 mock_app do
9 set :views, File.dirname(__FILE__) + '/views'
46e8bd67 »
2012-05-21 First pass at block styles for tests
10 get('/', &block)
7cb94f2d »
2010-09-12 Add radius helper method. Tilt supports radius for quite some time no…
11 end
12 get '/'
13 end
14
15 it 'renders inline radius strings' do
16 radius_app { radius '<h1>Hiya</h1>' }
17 assert ok?
18 assert_equal "<h1>Hiya</h1>", body
19 end
20
21 it 'renders .radius files in views path' do
22 radius_app { radius :hello }
23 assert ok?
24 assert_equal "<h1>Hello From Radius</h1>\n", body
25 end
26
27 it "renders with inline layouts" do
28 mock_app do
29 layout { "<h1>THIS. IS. <r:yield /></h1>" }
30 get('/') { radius '<EM>SPARTA</EM>' }
31 end
32 get '/'
33 assert ok?
34 assert_equal "<h1>THIS. IS. <EM>SPARTA</EM></h1>", body
35 end
36
37 it "renders with file layouts" do
38 radius_app { radius 'Hello World', :layout => :layout2 }
39 assert ok?
40 assert_equal "<h1>Radius Layout!</h1>\n<p>Hello World</p>\n", body
41 end
42
43 it "raises error if template not found" do
44 mock_app { get('/') { radius :no_such_template } }
45 assert_raise(Errno::ENOENT) { get('/') }
46 end
498bad91 »
2012-07-18 Remove trailing whitespaces
47
7cb94f2d »
2010-09-12 Add radius helper method. Tilt supports radius for quite some time no…
48 it "allows passing locals" do
46e8bd67 »
2012-05-21 First pass at block styles for tests
49 radius_app {
7cb94f2d »
2010-09-12 Add radius helper method. Tilt supports radius for quite some time no…
50 radius '<r:value />', :locals => { :value => 'foo' }
46e8bd67 »
2012-05-21 First pass at block styles for tests
51 }
7cb94f2d »
2010-09-12 Add radius helper method. Tilt supports radius for quite some time no…
52 assert ok?
53 assert_equal 'foo', body
54 end
55 end
e16bc715 »
2011-01-25 Explicitly handle the exception for failed loading.
56
57 rescue LoadError
7cb94f2d »
2010-09-12 Add radius helper method. Tilt supports radius for quite some time no…
58 warn "#{$!.to_s}: skipping radius tests"
59 end
Something went wrong with that request. Please try again.