sinatra-acd 1.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +5 -0
- data/AUTHORS +61 -0
- data/CHANGES +1293 -0
- data/Gemfile +76 -0
- data/LICENSE +23 -0
- data/README.de.md +2864 -0
- data/README.es.md +2786 -0
- data/README.fr.md +2924 -0
- data/README.hu.md +694 -0
- data/README.ja.md +2726 -0
- data/README.ko.md +2832 -0
- data/README.md +2980 -0
- data/README.pt-br.md +965 -0
- data/README.pt-pt.md +791 -0
- data/README.ru.md +2799 -0
- data/README.zh.md +2158 -0
- data/Rakefile +199 -0
- data/examples/chat.rb +61 -0
- data/examples/simple.rb +3 -0
- data/examples/stream.ru +26 -0
- data/lib/sinatra.rb +4 -0
- data/lib/sinatra/base.rb +2044 -0
- data/lib/sinatra/images/404.png +0 -0
- data/lib/sinatra/images/500.png +0 -0
- data/lib/sinatra/main.rb +34 -0
- data/lib/sinatra/show_exceptions.rb +345 -0
- data/lib/sinatra/version.rb +3 -0
- data/sinatra.gemspec +19 -0
- data/test/asciidoctor_test.rb +72 -0
- data/test/base_test.rb +171 -0
- data/test/builder_test.rb +91 -0
- data/test/coffee_test.rb +90 -0
- data/test/compile_test.rb +183 -0
- data/test/contest.rb +100 -0
- data/test/creole_test.rb +65 -0
- data/test/delegator_test.rb +160 -0
- data/test/encoding_test.rb +20 -0
- data/test/erb_test.rb +116 -0
- data/test/extensions_test.rb +98 -0
- data/test/filter_test.rb +487 -0
- data/test/haml_test.rb +109 -0
- data/test/helper.rb +131 -0
- data/test/helpers_test.rb +1917 -0
- data/test/integration/app.rb +79 -0
- data/test/integration_helper.rb +236 -0
- data/test/integration_test.rb +104 -0
- data/test/less_test.rb +69 -0
- data/test/liquid_test.rb +77 -0
- data/test/mapped_error_test.rb +285 -0
- data/test/markaby_test.rb +80 -0
- data/test/markdown_test.rb +82 -0
- data/test/mediawiki_test.rb +68 -0
- data/test/middleware_test.rb +68 -0
- data/test/nokogiri_test.rb +67 -0
- data/test/public/favicon.ico +0 -0
- data/test/rabl_test.rb +89 -0
- data/test/rack_test.rb +45 -0
- data/test/radius_test.rb +59 -0
- data/test/rdoc_test.rb +66 -0
- data/test/readme_test.rb +130 -0
- data/test/request_test.rb +97 -0
- data/test/response_test.rb +63 -0
- data/test/result_test.rb +76 -0
- data/test/route_added_hook_test.rb +59 -0
- data/test/routing_test.rb +1412 -0
- data/test/sass_test.rb +115 -0
- data/test/scss_test.rb +88 -0
- data/test/server_test.rb +48 -0
- data/test/settings_test.rb +582 -0
- data/test/sinatra_test.rb +12 -0
- data/test/slim_test.rb +102 -0
- data/test/static_test.rb +236 -0
- data/test/streaming_test.rb +149 -0
- data/test/stylus_test.rb +90 -0
- data/test/templates_test.rb +382 -0
- data/test/textile_test.rb +65 -0
- data/test/views/a/in_a.str +1 -0
- data/test/views/ascii.erb +2 -0
- data/test/views/b/in_b.str +1 -0
- data/test/views/calc.html.erb +1 -0
- data/test/views/error.builder +3 -0
- data/test/views/error.erb +3 -0
- data/test/views/error.haml +3 -0
- data/test/views/error.sass +2 -0
- data/test/views/explicitly_nested.str +1 -0
- data/test/views/foo/hello.test +1 -0
- data/test/views/hello.asciidoc +1 -0
- data/test/views/hello.builder +1 -0
- data/test/views/hello.coffee +1 -0
- data/test/views/hello.creole +1 -0
- data/test/views/hello.erb +1 -0
- data/test/views/hello.haml +1 -0
- data/test/views/hello.less +5 -0
- data/test/views/hello.liquid +1 -0
- data/test/views/hello.mab +1 -0
- data/test/views/hello.md +1 -0
- data/test/views/hello.mediawiki +1 -0
- data/test/views/hello.nokogiri +1 -0
- data/test/views/hello.rabl +2 -0
- data/test/views/hello.radius +1 -0
- data/test/views/hello.rdoc +1 -0
- data/test/views/hello.sass +2 -0
- data/test/views/hello.scss +3 -0
- data/test/views/hello.slim +1 -0
- data/test/views/hello.str +1 -0
- data/test/views/hello.styl +2 -0
- data/test/views/hello.test +1 -0
- data/test/views/hello.textile +1 -0
- data/test/views/hello.wlang +1 -0
- data/test/views/hello.yajl +1 -0
- data/test/views/layout2.builder +3 -0
- data/test/views/layout2.erb +2 -0
- data/test/views/layout2.haml +2 -0
- data/test/views/layout2.liquid +2 -0
- data/test/views/layout2.mab +2 -0
- data/test/views/layout2.nokogiri +3 -0
- data/test/views/layout2.rabl +3 -0
- data/test/views/layout2.radius +2 -0
- data/test/views/layout2.slim +3 -0
- data/test/views/layout2.str +2 -0
- data/test/views/layout2.test +1 -0
- data/test/views/layout2.wlang +2 -0
- data/test/views/nested.str +1 -0
- data/test/views/utf8.erb +2 -0
- data/test/wlang_test.rb +87 -0
- data/test/yajl_test.rb +86 -0
- metadata +280 -0
@@ -0,0 +1,68 @@
|
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'wikicloth'
|
5
|
+
|
6
|
+
class MediaWikiTest < Test::Unit::TestCase
|
7
|
+
def mediawiki_app(&block)
|
8
|
+
mock_app do
|
9
|
+
set :views, File.dirname(__FILE__) + '/views'
|
10
|
+
get('/', &block)
|
11
|
+
end
|
12
|
+
get '/'
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'supports both .mw and .mediawiki extensions' do
|
16
|
+
assert_equal Tilt[:mw], Tilt[:mediawiki]
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'renders inline mediawiki strings' do
|
20
|
+
mediawiki_app { mediawiki "''Hiya''" }
|
21
|
+
assert ok?
|
22
|
+
assert_include body, '<i>Hiya</i>'
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'renders .mediawiki files in views path' do
|
26
|
+
mediawiki_app { mediawiki :hello }
|
27
|
+
assert ok?
|
28
|
+
assert_include body, "<i>Hello from MediaWiki</i>"
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'raises error if template not found' do
|
32
|
+
mock_app { get('/') { mediawiki :no_such_template } }
|
33
|
+
assert_raise(Errno::ENOENT) { get('/') }
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'renders with inline layouts' do
|
37
|
+
mock_app do
|
38
|
+
layout { 'THIS. IS. #{yield.upcase}!' }
|
39
|
+
get('/') { mediawiki 'Sparta', :layout_engine => :str }
|
40
|
+
end
|
41
|
+
get '/'
|
42
|
+
assert ok?
|
43
|
+
assert_like 'THIS. IS. <P>SPARTA</P>!', body
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'renders with file layouts' do
|
47
|
+
mediawiki_app do
|
48
|
+
mediawiki 'Hello World', :layout => :layout2, :layout_engine => :erb
|
49
|
+
end
|
50
|
+
assert ok?
|
51
|
+
assert_body "ERB Layout!\n<p>Hello World</p>"
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'can be used in a nested fashion for partials and whatnot' do
|
55
|
+
mock_app do
|
56
|
+
template(:inner) { "hi" }
|
57
|
+
template(:outer) { "<outer><%= mediawiki :inner %></outer>" }
|
58
|
+
get('/') { erb :outer }
|
59
|
+
end
|
60
|
+
|
61
|
+
get '/'
|
62
|
+
assert ok?
|
63
|
+
assert_like '<outer><p>hi</p></outer>', body
|
64
|
+
end
|
65
|
+
end
|
66
|
+
rescue LoadError
|
67
|
+
warn "#{$!.to_s}: skipping mediawiki tests"
|
68
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
|
+
|
3
|
+
class MiddlewareTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@app = mock_app(Sinatra::Application) do
|
6
|
+
get('/*')do
|
7
|
+
response.headers['X-Tests'] = env['test.ran'].
|
8
|
+
map { |n| n.split('::').last }.
|
9
|
+
join(', ')
|
10
|
+
env['PATH_INFO']
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class MockMiddleware < Struct.new(:app)
|
16
|
+
def call(env)
|
17
|
+
(env['test.ran'] ||= []) << self.class.to_s
|
18
|
+
app.call(env)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class UpcaseMiddleware < MockMiddleware
|
23
|
+
def call(env)
|
24
|
+
env['PATH_INFO'] = env['PATH_INFO'].upcase
|
25
|
+
super
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it "is added with Sinatra::Application.use" do
|
30
|
+
@app.use UpcaseMiddleware
|
31
|
+
get '/hello-world'
|
32
|
+
assert ok?
|
33
|
+
assert_equal '/HELLO-WORLD', body
|
34
|
+
end
|
35
|
+
|
36
|
+
class DowncaseMiddleware < MockMiddleware
|
37
|
+
def call(env)
|
38
|
+
env['PATH_INFO'] = env['PATH_INFO'].downcase
|
39
|
+
super
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it "runs in the order defined" do
|
44
|
+
@app.use UpcaseMiddleware
|
45
|
+
@app.use DowncaseMiddleware
|
46
|
+
get '/Foo'
|
47
|
+
assert_equal "/foo", body
|
48
|
+
assert_equal "UpcaseMiddleware, DowncaseMiddleware", response['X-Tests']
|
49
|
+
end
|
50
|
+
|
51
|
+
it "resets the prebuilt pipeline when new middleware is added" do
|
52
|
+
@app.use UpcaseMiddleware
|
53
|
+
get '/Foo'
|
54
|
+
assert_equal "/FOO", body
|
55
|
+
@app.use DowncaseMiddleware
|
56
|
+
get '/Foo'
|
57
|
+
assert_equal '/foo', body
|
58
|
+
assert_equal "UpcaseMiddleware, DowncaseMiddleware", response['X-Tests']
|
59
|
+
end
|
60
|
+
|
61
|
+
it "works when app is used as middleware" do
|
62
|
+
@app.use UpcaseMiddleware
|
63
|
+
@app = @app.new
|
64
|
+
get '/Foo'
|
65
|
+
assert_equal "/FOO", body
|
66
|
+
assert_equal "UpcaseMiddleware", response['X-Tests']
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'nokogiri'
|
5
|
+
|
6
|
+
class NokogiriTest < Test::Unit::TestCase
|
7
|
+
def nokogiri_app(&block)
|
8
|
+
mock_app do
|
9
|
+
set :views, File.dirname(__FILE__) + '/views'
|
10
|
+
get('/', &block)
|
11
|
+
end
|
12
|
+
get '/'
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'renders inline Nokogiri strings' do
|
16
|
+
nokogiri_app { nokogiri 'xml' }
|
17
|
+
assert ok?
|
18
|
+
assert_body %(<?xml version="1.0"?>\n)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'renders inline blocks' do
|
22
|
+
nokogiri_app do
|
23
|
+
@name = "Frank & Mary"
|
24
|
+
nokogiri { |xml| xml.couple @name }
|
25
|
+
end
|
26
|
+
assert ok?
|
27
|
+
assert_body %(<?xml version="1.0"?>\n<couple>Frank & Mary</couple>\n)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'renders .nokogiri files in views path' do
|
31
|
+
nokogiri_app do
|
32
|
+
@name = "Blue"
|
33
|
+
nokogiri :hello
|
34
|
+
end
|
35
|
+
assert ok?
|
36
|
+
assert_body "<?xml version=\"1.0\"?>\n<exclaim>You're my boy, Blue!</exclaim>\n"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "renders with inline layouts" do
|
40
|
+
next if Tilt::VERSION <= "1.1"
|
41
|
+
mock_app do
|
42
|
+
layout { %(xml.layout { xml << yield }) }
|
43
|
+
get('/') { nokogiri %(xml.em 'Hello World') }
|
44
|
+
end
|
45
|
+
get '/'
|
46
|
+
assert ok?
|
47
|
+
assert_body %(<?xml version="1.0"?>\n<layout>\n <em>Hello World</em>\n</layout>\n)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "renders with file layouts" do
|
51
|
+
next if Tilt::VERSION <= "1.1"
|
52
|
+
nokogiri_app {
|
53
|
+
nokogiri %(xml.em 'Hello World'), :layout => :layout2
|
54
|
+
}
|
55
|
+
assert ok?
|
56
|
+
assert_body %(<?xml version="1.0"?>\n<layout>\n <em>Hello World</em>\n</layout>\n)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "raises error if template not found" do
|
60
|
+
mock_app { get('/') { nokogiri :no_such_template } }
|
61
|
+
assert_raise(Errno::ENOENT) { get('/') }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
rescue LoadError
|
66
|
+
warn "#{$!.to_s}: skipping nokogiri tests"
|
67
|
+
end
|
File without changes
|
data/test/rabl_test.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'rabl'
|
5
|
+
require 'ostruct'
|
6
|
+
require 'json'
|
7
|
+
require 'active_support/core_ext/hash/conversions'
|
8
|
+
|
9
|
+
class RablTest < Test::Unit::TestCase
|
10
|
+
def rabl_app(&block)
|
11
|
+
mock_app {
|
12
|
+
set :views, File.dirname(__FILE__) + '/views'
|
13
|
+
get '/', &block
|
14
|
+
}
|
15
|
+
get '/'
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'renders inline rabl strings' do
|
19
|
+
rabl_app do
|
20
|
+
@foo = OpenStruct.new(:baz => 'w00t')
|
21
|
+
rabl %q{
|
22
|
+
object @foo
|
23
|
+
attributes :baz
|
24
|
+
}
|
25
|
+
end
|
26
|
+
assert ok?
|
27
|
+
assert_equal '{"openstruct":{"baz":"w00t"}}', body
|
28
|
+
end
|
29
|
+
it 'renders .rabl files in views path' do
|
30
|
+
rabl_app do
|
31
|
+
@foo = OpenStruct.new(:bar => 'baz')
|
32
|
+
rabl :hello
|
33
|
+
end
|
34
|
+
assert ok?
|
35
|
+
assert_equal '{"openstruct":{"bar":"baz"}}', body
|
36
|
+
end
|
37
|
+
|
38
|
+
it "renders with file layouts" do
|
39
|
+
rabl_app {
|
40
|
+
@foo = OpenStruct.new(:bar => 'baz')
|
41
|
+
rabl :hello, :layout => :layout2
|
42
|
+
}
|
43
|
+
assert ok?
|
44
|
+
assert_equal '{"qux":{"openstruct":{"bar":"baz"}}}', body
|
45
|
+
end
|
46
|
+
|
47
|
+
it "raises error if template not found" do
|
48
|
+
mock_app {
|
49
|
+
get('/') { rabl :no_such_template }
|
50
|
+
}
|
51
|
+
assert_raise(Errno::ENOENT) { get('/') }
|
52
|
+
end
|
53
|
+
|
54
|
+
it "passes rabl options to the rabl engine" do
|
55
|
+
mock_app do
|
56
|
+
get('/') do
|
57
|
+
@foo = OpenStruct.new(:bar => 'baz')
|
58
|
+
rabl %q{
|
59
|
+
object @foo
|
60
|
+
attributes :bar
|
61
|
+
}, :format => 'xml'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
get '/'
|
65
|
+
assert ok?
|
66
|
+
assert_body '<?xml version="1.0" encoding="UTF-8"?><openstruct><bar>baz</bar></openstruct>'
|
67
|
+
end
|
68
|
+
|
69
|
+
it "passes default rabl options to the rabl engine" do
|
70
|
+
mock_app do
|
71
|
+
set :rabl, :format => 'xml'
|
72
|
+
get('/') do
|
73
|
+
@foo = OpenStruct.new(:bar => 'baz')
|
74
|
+
rabl %q{
|
75
|
+
object @foo
|
76
|
+
attributes :bar
|
77
|
+
}
|
78
|
+
end
|
79
|
+
end
|
80
|
+
get '/'
|
81
|
+
assert ok?
|
82
|
+
assert_body '<?xml version="1.0" encoding="UTF-8"?><openstruct><bar>baz</bar></openstruct>'
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
rescue LoadError
|
88
|
+
warn "#{$!.to_s}: skipping rabl tests"
|
89
|
+
end
|
data/test/rack_test.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
|
+
require 'rack'
|
3
|
+
|
4
|
+
class RackTest < Test::Unit::TestCase
|
5
|
+
setup do
|
6
|
+
@foo = Sinatra.new { get('/foo') { 'foo' }}
|
7
|
+
@bar = Sinatra.new { get('/bar') { 'bar' }}
|
8
|
+
end
|
9
|
+
|
10
|
+
def build(*middleware)
|
11
|
+
endpoint = middleware.pop
|
12
|
+
@app = Rack::Builder.app do
|
13
|
+
middleware.each { |m| use m }
|
14
|
+
run endpoint
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def check(*middleware)
|
19
|
+
build(*middleware)
|
20
|
+
assert get('/foo').ok?
|
21
|
+
assert_body 'foo'
|
22
|
+
assert get('/bar').ok?
|
23
|
+
assert_body 'bar'
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'works as middleware in front of Rack::Lock, with lock enabled' do
|
27
|
+
@foo.enable :lock
|
28
|
+
check(@foo, Rack::Lock, @bar)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'works as middleware behind Rack::Lock, with lock enabled' do
|
32
|
+
@foo.enable :lock
|
33
|
+
check(Rack::Lock, @foo, @bar)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'works as middleware in front of Rack::Lock, with lock disabled' do
|
37
|
+
@foo.disable :lock
|
38
|
+
check(@foo, Rack::Lock, @bar)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'works as middleware behind Rack::Lock, with lock disabled' do
|
42
|
+
@foo.disable :lock
|
43
|
+
check(Rack::Lock, @foo, @bar)
|
44
|
+
end
|
45
|
+
end
|
data/test/radius_test.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
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'
|
10
|
+
get('/', &block)
|
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
|
47
|
+
|
48
|
+
it "allows passing locals" do
|
49
|
+
radius_app {
|
50
|
+
radius '<r:value />', :locals => { :value => 'foo' }
|
51
|
+
}
|
52
|
+
assert ok?
|
53
|
+
assert_equal 'foo', body
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
rescue LoadError
|
58
|
+
warn "#{$!.to_s}: skipping radius tests"
|
59
|
+
end
|
data/test/rdoc_test.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'rdoc'
|
5
|
+
require 'rdoc/markup/to_html'
|
6
|
+
|
7
|
+
class RdocTest < Test::Unit::TestCase
|
8
|
+
def rdoc_app(&block)
|
9
|
+
mock_app do
|
10
|
+
set :views, File.dirname(__FILE__) + '/views'
|
11
|
+
get('/', &block)
|
12
|
+
end
|
13
|
+
get '/'
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'renders inline rdoc strings' do
|
17
|
+
rdoc_app { rdoc '= Hiya' }
|
18
|
+
assert ok?
|
19
|
+
assert_body(/<h1[^>]*>Hiya(<span><a href=\"#label-Hiya\">¶<\/a> <a href=\"#documentation\">↑<\/a><\/span>)?<\/h1>/)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'renders .rdoc files in views path' do
|
23
|
+
rdoc_app { rdoc :hello }
|
24
|
+
assert ok?
|
25
|
+
assert_body(/<h1[^>]*>Hello From RDoc(<span><a href=\"#label-Hello\+From\+RDoc\">¶<\/a> <a href=\"#documentation\">↑<\/a><\/span>)?<\/h1>/)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "raises error if template not found" do
|
29
|
+
mock_app { get('/') { rdoc :no_such_template } }
|
30
|
+
assert_raise(Errno::ENOENT) { get('/') }
|
31
|
+
end
|
32
|
+
|
33
|
+
it "renders with inline layouts" do
|
34
|
+
mock_app do
|
35
|
+
layout { 'THIS. IS. #{yield.upcase}!' }
|
36
|
+
get('/') { rdoc 'Sparta', :layout_engine => :str }
|
37
|
+
end
|
38
|
+
get '/'
|
39
|
+
assert ok?
|
40
|
+
assert_like 'THIS. IS. <P>SPARTA</P>!', body
|
41
|
+
end
|
42
|
+
|
43
|
+
it "renders with file layouts" do
|
44
|
+
rdoc_app {
|
45
|
+
rdoc 'Hello World', :layout => :layout2, :layout_engine => :erb
|
46
|
+
}
|
47
|
+
assert ok?
|
48
|
+
assert_body "ERB Layout!\n<p>Hello World</p>"
|
49
|
+
end
|
50
|
+
|
51
|
+
it "can be used in a nested fashion for partials and whatnot" do
|
52
|
+
mock_app do
|
53
|
+
template(:inner) { "hi" }
|
54
|
+
template(:outer) { "<outer><%= rdoc :inner %></outer>" }
|
55
|
+
get('/') { erb :outer }
|
56
|
+
end
|
57
|
+
|
58
|
+
get '/'
|
59
|
+
assert ok?
|
60
|
+
assert_like '<outer><p>hi</p></outer>', body
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
rescue LoadError
|
65
|
+
warn "#{$!.to_s}: skipping rdoc tests"
|
66
|
+
end
|