Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 66 lines (55 sloc) 1.544 kB
e001d62 @rkh adjust require lines for test helper, so it also works properly on 1.9.2
rkh authored
1 require File.expand_path('../helper', __FILE__)
b464e02 @rkh Add textile helper method. Tilt supports textile for quite some time …
rkh authored
2
3 begin
4 require 'redcloth'
5
6 class TextileTest < Test::Unit::TestCase
7 def textile_app(&block)
8 mock_app do
9 set :views, File.dirname(__FILE__) + '/views'
46e8bd6 @zzak First pass at block styles for tests
zzak authored
10 get('/', &block)
b464e02 @rkh Add textile helper method. Tilt supports textile for quite some time …
rkh authored
11 end
12 get '/'
13 end
14
15 it 'renders inline textile strings' do
46e8bd6 @zzak First pass at block styles for tests
zzak authored
16 textile_app { textile('h1. Hiya') }
b464e02 @rkh Add textile helper method. Tilt supports textile for quite some time …
rkh authored
17 assert ok?
18 assert_equal "<h1>Hiya</h1>", body
19 end
20
21 it 'renders .textile files in views path' do
46e8bd6 @zzak First pass at block styles for tests
zzak authored
22 textile_app { textile(:hello) }
b464e02 @rkh Add textile helper method. Tilt supports textile for quite some time …
rkh authored
23 assert ok?
24 assert_equal "<h1>Hello From Textile</h1>", body
25 end
26
27 it "raises error if template not found" do
46e8bd6 @zzak First pass at block styles for tests
zzak authored
28 mock_app { get('/') { textile(:no_such_template) } }
b464e02 @rkh Add textile helper method. Tilt supports textile for quite some time …
rkh authored
29 assert_raise(Errno::ENOENT) { get('/') }
30 end
a9d89d2 @rkh add markdown, rdoc and textile nesting tests
rkh authored
31
32 it "renders with inline layouts" do
33 mock_app do
34 layout { 'THIS. IS. #{yield.upcase}!' }
46e8bd6 @zzak First pass at block styles for tests
zzak authored
35 get('/') { textile('Sparta', :layout_engine => :str) }
a9d89d2 @rkh add markdown, rdoc and textile nesting tests
rkh authored
36 end
37 get '/'
38 assert ok?
39 assert_like 'THIS. IS. <P>SPARTA</P>!', body
40 end
41
42 it "renders with file layouts" do
46e8bd6 @zzak First pass at block styles for tests
zzak authored
43 textile_app {
44 textile('Hello World', :layout => :layout2, :layout_engine => :erb)
45 }
a9d89d2 @rkh add markdown, rdoc and textile nesting tests
rkh authored
46 assert ok?
47 assert_body "ERB Layout!\n<p>Hello World</p>"
48 end
49
50 it "can be used in a nested fashion for partials and whatnot" do
51 mock_app do
52 template(:inner) { "hi" }
53 template(:outer) { "<outer><%= textile :inner %></outer>" }
46e8bd6 @zzak First pass at block styles for tests
zzak authored
54 get('/') { erb :outer }
a9d89d2 @rkh add markdown, rdoc and textile nesting tests
rkh authored
55 end
56
57 get '/'
58 assert ok?
59 assert_like '<outer><p>hi</p></outer>', body
60 end
b464e02 @rkh Add textile helper method. Tilt supports textile for quite some time …
rkh authored
61 end
e16bc71 @cactus Explicitly handle the exception for failed loading.
cactus authored
62
63 rescue LoadError
b464e02 @rkh Add textile helper method. Tilt supports textile for quite some time …
rkh authored
64 warn "#{$!.to_s}: skipping textile tests"
65 end
Something went wrong with that request. Please try again.