sinatra-acd 1.4.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +5 -0
  3. data/AUTHORS +61 -0
  4. data/CHANGES +1293 -0
  5. data/Gemfile +76 -0
  6. data/LICENSE +23 -0
  7. data/README.de.md +2864 -0
  8. data/README.es.md +2786 -0
  9. data/README.fr.md +2924 -0
  10. data/README.hu.md +694 -0
  11. data/README.ja.md +2726 -0
  12. data/README.ko.md +2832 -0
  13. data/README.md +2980 -0
  14. data/README.pt-br.md +965 -0
  15. data/README.pt-pt.md +791 -0
  16. data/README.ru.md +2799 -0
  17. data/README.zh.md +2158 -0
  18. data/Rakefile +199 -0
  19. data/examples/chat.rb +61 -0
  20. data/examples/simple.rb +3 -0
  21. data/examples/stream.ru +26 -0
  22. data/lib/sinatra.rb +4 -0
  23. data/lib/sinatra/base.rb +2044 -0
  24. data/lib/sinatra/images/404.png +0 -0
  25. data/lib/sinatra/images/500.png +0 -0
  26. data/lib/sinatra/main.rb +34 -0
  27. data/lib/sinatra/show_exceptions.rb +345 -0
  28. data/lib/sinatra/version.rb +3 -0
  29. data/sinatra.gemspec +19 -0
  30. data/test/asciidoctor_test.rb +72 -0
  31. data/test/base_test.rb +171 -0
  32. data/test/builder_test.rb +91 -0
  33. data/test/coffee_test.rb +90 -0
  34. data/test/compile_test.rb +183 -0
  35. data/test/contest.rb +100 -0
  36. data/test/creole_test.rb +65 -0
  37. data/test/delegator_test.rb +160 -0
  38. data/test/encoding_test.rb +20 -0
  39. data/test/erb_test.rb +116 -0
  40. data/test/extensions_test.rb +98 -0
  41. data/test/filter_test.rb +487 -0
  42. data/test/haml_test.rb +109 -0
  43. data/test/helper.rb +131 -0
  44. data/test/helpers_test.rb +1917 -0
  45. data/test/integration/app.rb +79 -0
  46. data/test/integration_helper.rb +236 -0
  47. data/test/integration_test.rb +104 -0
  48. data/test/less_test.rb +69 -0
  49. data/test/liquid_test.rb +77 -0
  50. data/test/mapped_error_test.rb +285 -0
  51. data/test/markaby_test.rb +80 -0
  52. data/test/markdown_test.rb +82 -0
  53. data/test/mediawiki_test.rb +68 -0
  54. data/test/middleware_test.rb +68 -0
  55. data/test/nokogiri_test.rb +67 -0
  56. data/test/public/favicon.ico +0 -0
  57. data/test/rabl_test.rb +89 -0
  58. data/test/rack_test.rb +45 -0
  59. data/test/radius_test.rb +59 -0
  60. data/test/rdoc_test.rb +66 -0
  61. data/test/readme_test.rb +130 -0
  62. data/test/request_test.rb +97 -0
  63. data/test/response_test.rb +63 -0
  64. data/test/result_test.rb +76 -0
  65. data/test/route_added_hook_test.rb +59 -0
  66. data/test/routing_test.rb +1412 -0
  67. data/test/sass_test.rb +115 -0
  68. data/test/scss_test.rb +88 -0
  69. data/test/server_test.rb +48 -0
  70. data/test/settings_test.rb +582 -0
  71. data/test/sinatra_test.rb +12 -0
  72. data/test/slim_test.rb +102 -0
  73. data/test/static_test.rb +236 -0
  74. data/test/streaming_test.rb +149 -0
  75. data/test/stylus_test.rb +90 -0
  76. data/test/templates_test.rb +382 -0
  77. data/test/textile_test.rb +65 -0
  78. data/test/views/a/in_a.str +1 -0
  79. data/test/views/ascii.erb +2 -0
  80. data/test/views/b/in_b.str +1 -0
  81. data/test/views/calc.html.erb +1 -0
  82. data/test/views/error.builder +3 -0
  83. data/test/views/error.erb +3 -0
  84. data/test/views/error.haml +3 -0
  85. data/test/views/error.sass +2 -0
  86. data/test/views/explicitly_nested.str +1 -0
  87. data/test/views/foo/hello.test +1 -0
  88. data/test/views/hello.asciidoc +1 -0
  89. data/test/views/hello.builder +1 -0
  90. data/test/views/hello.coffee +1 -0
  91. data/test/views/hello.creole +1 -0
  92. data/test/views/hello.erb +1 -0
  93. data/test/views/hello.haml +1 -0
  94. data/test/views/hello.less +5 -0
  95. data/test/views/hello.liquid +1 -0
  96. data/test/views/hello.mab +1 -0
  97. data/test/views/hello.md +1 -0
  98. data/test/views/hello.mediawiki +1 -0
  99. data/test/views/hello.nokogiri +1 -0
  100. data/test/views/hello.rabl +2 -0
  101. data/test/views/hello.radius +1 -0
  102. data/test/views/hello.rdoc +1 -0
  103. data/test/views/hello.sass +2 -0
  104. data/test/views/hello.scss +3 -0
  105. data/test/views/hello.slim +1 -0
  106. data/test/views/hello.str +1 -0
  107. data/test/views/hello.styl +2 -0
  108. data/test/views/hello.test +1 -0
  109. data/test/views/hello.textile +1 -0
  110. data/test/views/hello.wlang +1 -0
  111. data/test/views/hello.yajl +1 -0
  112. data/test/views/layout2.builder +3 -0
  113. data/test/views/layout2.erb +2 -0
  114. data/test/views/layout2.haml +2 -0
  115. data/test/views/layout2.liquid +2 -0
  116. data/test/views/layout2.mab +2 -0
  117. data/test/views/layout2.nokogiri +3 -0
  118. data/test/views/layout2.rabl +3 -0
  119. data/test/views/layout2.radius +2 -0
  120. data/test/views/layout2.slim +3 -0
  121. data/test/views/layout2.str +2 -0
  122. data/test/views/layout2.test +1 -0
  123. data/test/views/layout2.wlang +2 -0
  124. data/test/views/nested.str +1 -0
  125. data/test/views/utf8.erb +2 -0
  126. data/test/wlang_test.rb +87 -0
  127. data/test/yajl_test.rb +86 -0
  128. metadata +280 -0
@@ -0,0 +1,34 @@
1
+ require 'sinatra/base'
2
+
3
+ module Sinatra
4
+ class Application < Base
5
+
6
+ # we assume that the first file that requires 'sinatra' is the
7
+ # app_file. all other path related options are calculated based
8
+ # on this path by default.
9
+ set :app_file, caller_files.first || $0
10
+
11
+ set :run, Proc.new { File.expand_path($0) == File.expand_path(app_file) }
12
+
13
+ if run? && ARGV.any?
14
+ require 'optparse'
15
+ OptionParser.new { |op|
16
+ op.on('-p port', 'set the port (default is 4567)') { |val| set :port, Integer(val) }
17
+ op.on('-o addr', "set the host (default is #{bind})") { |val| set :bind, val }
18
+ op.on('-e env', 'set the environment (default is development)') { |val| set :environment, val.to_sym }
19
+ op.on('-s server', 'specify rack server/handler (default is thin)') { |val| set :server, val }
20
+ op.on('-x', 'turn on the mutex lock (default is off)') { set :lock, true }
21
+ }.parse!(ARGV.dup)
22
+ end
23
+ end
24
+
25
+ at_exit { Application.run! if $!.nil? && Application.run? }
26
+ end
27
+
28
+ # include would include the module in Object
29
+ # extend only extends the `main` object
30
+ extend Sinatra::Delegator
31
+
32
+ class Rack::Builder
33
+ include Sinatra::Delegator
34
+ end
@@ -0,0 +1,345 @@
1
+ require 'rack/showexceptions'
2
+
3
+ module Sinatra
4
+ # Sinatra::ShowExceptions catches all exceptions raised from the app it
5
+ # wraps. It shows a useful backtrace with the sourcefile and clickable
6
+ # context, the whole Rack environment and the request data.
7
+ #
8
+ # Be careful when you use this on public-facing sites as it could reveal
9
+ # information helpful to attackers.
10
+ class ShowExceptions < Rack::ShowExceptions
11
+ @@eats_errors = Object.new
12
+ def @@eats_errors.flush(*) end
13
+ def @@eats_errors.puts(*) end
14
+
15
+ def initialize(app)
16
+ @app = app
17
+ @template = ERB.new(TEMPLATE)
18
+ end
19
+
20
+ def call(env)
21
+ @app.call(env)
22
+ rescue Exception => e
23
+ errors, env["rack.errors"] = env["rack.errors"], @@eats_errors
24
+
25
+ if prefers_plain_text?(env)
26
+ content_type = "text/plain"
27
+ body = [dump_exception(e)]
28
+ else
29
+ content_type = "text/html"
30
+ body = pretty(env, e)
31
+ end
32
+
33
+ env["rack.errors"] = errors
34
+
35
+ [500,
36
+ {"Content-Type" => content_type,
37
+ "Content-Length" => Rack::Utils.bytesize(body.join).to_s},
38
+ body]
39
+ end
40
+
41
+ private
42
+
43
+ def prefers_plain_text?(env)
44
+ !(Request.new(env).preferred_type("text/plain","text/html") == "text/html") &&
45
+ [/curl/].index{|item| item =~ env["HTTP_USER_AGENT"]}
46
+ end
47
+
48
+ def frame_class(frame)
49
+ if frame.filename =~ /lib\/sinatra.*\.rb/
50
+ "framework"
51
+ elsif (defined?(Gem) && frame.filename.include?(Gem.dir)) ||
52
+ frame.filename =~ /\/bin\/(\w+)$/
53
+ "system"
54
+ else
55
+ "app"
56
+ end
57
+ end
58
+
59
+ TEMPLATE = <<-HTML # :nodoc:
60
+ <!DOCTYPE html>
61
+ <html>
62
+ <head>
63
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
64
+ <title><%=h exception.class %> at <%=h path %></title>
65
+
66
+ <script type="text/javascript">
67
+ //<!--
68
+ function toggle(id) {
69
+ var pre = document.getElementById("pre-" + id);
70
+ var post = document.getElementById("post-" + id);
71
+ var context = document.getElementById("context-" + id);
72
+
73
+ if (pre.style.display == 'block') {
74
+ pre.style.display = 'none';
75
+ post.style.display = 'none';
76
+ context.style.background = "none";
77
+ } else {
78
+ pre.style.display = 'block';
79
+ post.style.display = 'block';
80
+ context.style.background = "#fffed9";
81
+ }
82
+ }
83
+
84
+ function toggleBacktrace(){
85
+ var bt = document.getElementById("backtrace");
86
+ var toggler = document.getElementById("expando");
87
+
88
+ if (bt.className == 'condensed') {
89
+ bt.className = 'expanded';
90
+ toggler.innerHTML = "(condense)";
91
+ } else {
92
+ bt.className = 'condensed';
93
+ toggler.innerHTML = "(expand)";
94
+ }
95
+ }
96
+ //-->
97
+ </script>
98
+
99
+ <style type="text/css" media="screen">
100
+ * {margin: 0; padding: 0; border: 0; outline: 0;}
101
+ div.clear {clear: both;}
102
+ body {background: #EEEEEE; margin: 0; padding: 0;
103
+ font-family: 'Lucida Grande', 'Lucida Sans Unicode',
104
+ 'Garuda';}
105
+ code {font-family: 'Lucida Console', monospace;
106
+ font-size: 12px;}
107
+ li {height: 18px;}
108
+ ul {list-style: none; margin: 0; padding: 0;}
109
+ ol:hover {cursor: pointer;}
110
+ ol li {white-space: pre;}
111
+ #explanation {font-size: 12px; color: #666666;
112
+ margin: 20px 0 0 100px;}
113
+ /* WRAP */
114
+ #wrap {width: 1000px; background: #FFFFFF; margin: 0 auto;
115
+ padding: 30px 50px 20px 50px;
116
+ border-left: 1px solid #DDDDDD;
117
+ border-right: 1px solid #DDDDDD;}
118
+ /* HEADER */
119
+ #header {margin: 0 auto 25px auto;}
120
+ #header img {float: left;}
121
+ #header #summary {float: left; margin: 12px 0 0 20px; width:660px;
122
+ font-family: 'Lucida Grande', 'Lucida Sans Unicode';}
123
+ h1 {margin: 0; font-size: 36px; color: #981919;}
124
+ h2 {margin: 0; font-size: 22px; color: #333333;}
125
+ #header ul {margin: 0; font-size: 12px; color: #666666;}
126
+ #header ul li strong{color: #444444;}
127
+ #header ul li {display: inline; padding: 0 10px;}
128
+ #header ul li.first {padding-left: 0;}
129
+ #header ul li.last {border: 0; padding-right: 0;}
130
+ /* BODY */
131
+ #backtrace,
132
+ #get,
133
+ #post,
134
+ #cookies,
135
+ #rack {width: 980px; margin: 0 auto 10px auto;}
136
+ p#nav {float: right; font-size: 14px;}
137
+ /* BACKTRACE */
138
+ a#expando {float: left; padding-left: 5px; color: #666666;
139
+ font-size: 14px; text-decoration: none; cursor: pointer;}
140
+ a#expando:hover {text-decoration: underline;}
141
+ h3 {float: left; width: 100px; margin-bottom: 10px;
142
+ color: #981919; font-size: 14px; font-weight: bold;}
143
+ #nav a {color: #666666; text-decoration: none; padding: 0 5px;}
144
+ #backtrace li.frame-info {background: #f7f7f7; padding-left: 10px;
145
+ font-size: 12px; color: #333333;}
146
+ #backtrace ul {list-style-position: outside; border: 1px solid #E9E9E9;
147
+ border-bottom: 0;}
148
+ #backtrace ol {width: 920px; margin-left: 50px;
149
+ font: 10px 'Lucida Console', monospace; color: #666666;}
150
+ #backtrace ol li {border: 0; border-left: 1px solid #E9E9E9;
151
+ padding: 2px 0;}
152
+ #backtrace ol code {font-size: 10px; color: #555555; padding-left: 5px;}
153
+ #backtrace-ul li {border-bottom: 1px solid #E9E9E9; height: auto;
154
+ padding: 3px 0;}
155
+ #backtrace-ul .code {padding: 6px 0 4px 0;}
156
+ #backtrace.condensed .system,
157
+ #backtrace.condensed .framework {display:none;}
158
+ /* REQUEST DATA */
159
+ p.no-data {padding-top: 2px; font-size: 12px; color: #666666;}
160
+ table.req {width: 980px; text-align: left; font-size: 12px;
161
+ color: #666666; padding: 0; border-spacing: 0;
162
+ border: 1px solid #EEEEEE; border-bottom: 0;
163
+ border-left: 0;
164
+ clear:both}
165
+ table.req tr th {padding: 2px 10px; font-weight: bold;
166
+ background: #F7F7F7; border-bottom: 1px solid #EEEEEE;
167
+ border-left: 1px solid #EEEEEE;}
168
+ table.req tr td {padding: 2px 20px 2px 10px;
169
+ border-bottom: 1px solid #EEEEEE;
170
+ border-left: 1px solid #EEEEEE;}
171
+ /* HIDE PRE/POST CODE AT START */
172
+ .pre-context,
173
+ .post-context {display: none;}
174
+
175
+ table td.code {width:750px}
176
+ table td.code div {width:750px;overflow:hidden}
177
+ </style>
178
+ </head>
179
+ <body>
180
+ <div id="wrap">
181
+ <div id="header">
182
+ <img src="<%= env['SCRIPT_NAME'] %>/__sinatra__/500.png" alt="application error" height="161" width="313" />
183
+ <div id="summary">
184
+ <h1><strong><%=h exception.class %></strong> at <strong><%=h path %>
185
+ </strong></h1>
186
+ <h2><%=h exception.message %></h2>
187
+ <ul>
188
+ <li class="first"><strong>file:</strong> <code>
189
+ <%=h frames.first.filename.split("/").last %></code></li>
190
+ <li><strong>location:</strong> <code><%=h frames.first.function %>
191
+ </code></li>
192
+ <li class="last"><strong>line:
193
+ </strong> <%=h frames.first.lineno %></li>
194
+ </ul>
195
+ </div>
196
+ <div class="clear"></div>
197
+ </div>
198
+
199
+ <div id="backtrace" class='condensed'>
200
+ <h3>BACKTRACE</h3>
201
+ <p><a href="#" id="expando"
202
+ onclick="toggleBacktrace(); return false">(expand)</a></p>
203
+ <p id="nav"><strong>JUMP TO:</strong>
204
+ <a href="#get-info">GET</a>
205
+ <a href="#post-info">POST</a>
206
+ <a href="#cookie-info">COOKIES</a>
207
+ <a href="#env-info">ENV</a>
208
+ </p>
209
+ <div class="clear"></div>
210
+
211
+ <ul id="backtrace-ul">
212
+
213
+ <% id = 1 %>
214
+ <% frames.each do |frame| %>
215
+ <% if frame.context_line && frame.context_line != "#" %>
216
+
217
+ <li class="frame-info <%= frame_class(frame) %>">
218
+ <code><%=h frame.filename %></code> in
219
+ <code><strong><%=h frame.function %></strong></code>
220
+ </li>
221
+
222
+ <li class="code <%= frame_class(frame) %>">
223
+ <% if frame.pre_context %>
224
+ <ol start="<%=h frame.pre_context_lineno + 1 %>"
225
+ class="pre-context" id="pre-<%= id %>"
226
+ onclick="toggle(<%= id %>);">
227
+ <% frame.pre_context.each do |line| %>
228
+ <li class="pre-context-line"><code><%=h line %></code></li>
229
+ <% end %>
230
+ </ol>
231
+ <% end %>
232
+
233
+ <ol start="<%= frame.lineno %>" class="context" id="<%= id %>"
234
+ onclick="toggle(<%= id %>);">
235
+ <li class="context-line" id="context-<%= id %>"><code><%=
236
+ h frame.context_line %></code></li>
237
+ </ol>
238
+
239
+ <% if frame.post_context %>
240
+ <ol start="<%=h frame.lineno + 1 %>" class="post-context"
241
+ id="post-<%= id %>" onclick="toggle(<%= id %>);">
242
+ <% frame.post_context.each do |line| %>
243
+ <li class="post-context-line"><code><%=h line %></code></li>
244
+ <% end %>
245
+ </ol>
246
+ <% end %>
247
+ <div class="clear"></div>
248
+ </li>
249
+
250
+ <% end %>
251
+
252
+ <% id += 1 %>
253
+ <% end %>
254
+
255
+ </ul>
256
+ </div> <!-- /BACKTRACE -->
257
+
258
+ <div id="get">
259
+ <h3 id="get-info">GET</h3>
260
+ <% if req.GET and not req.GET.empty? %>
261
+ <table class="req">
262
+ <tr>
263
+ <th>Variable</th>
264
+ <th>Value</th>
265
+ </tr>
266
+ <% req.GET.sort_by { |k, v| k.to_s }.each { |key, val| %>
267
+ <tr>
268
+ <td><%=h key %></td>
269
+ <td class="code"><div><%=h val.inspect %></div></td>
270
+ </tr>
271
+ <% } %>
272
+ </table>
273
+ <% else %>
274
+ <p class="no-data">No GET data.</p>
275
+ <% end %>
276
+ <div class="clear"></div>
277
+ </div> <!-- /GET -->
278
+
279
+ <div id="post">
280
+ <h3 id="post-info">POST</h3>
281
+ <% if req.POST and not req.POST.empty? %>
282
+ <table class="req">
283
+ <tr>
284
+ <th>Variable</th>
285
+ <th>Value</th>
286
+ </tr>
287
+ <% req.POST.sort_by { |k, v| k.to_s }.each { |key, val| %>
288
+ <tr>
289
+ <td><%=h key %></td>
290
+ <td class="code"><div><%=h val.inspect %></div></td>
291
+ </tr>
292
+ <% } %>
293
+ </table>
294
+ <% else %>
295
+ <p class="no-data">No POST data.</p>
296
+ <% end %>
297
+ <div class="clear"></div>
298
+ </div> <!-- /POST -->
299
+
300
+ <div id="cookies">
301
+ <h3 id="cookie-info">COOKIES</h3>
302
+ <% unless req.cookies.empty? %>
303
+ <table class="req">
304
+ <tr>
305
+ <th>Variable</th>
306
+ <th>Value</th>
307
+ </tr>
308
+ <% req.cookies.each { |key, val| %>
309
+ <tr>
310
+ <td><%=h key %></td>
311
+ <td class="code"><div><%=h val.inspect %></div></td>
312
+ </tr>
313
+ <% } %>
314
+ </table>
315
+ <% else %>
316
+ <p class="no-data">No cookie data.</p>
317
+ <% end %>
318
+ <div class="clear"></div>
319
+ </div> <!-- /COOKIES -->
320
+
321
+ <div id="rack">
322
+ <h3 id="env-info">Rack ENV</h3>
323
+ <table class="req">
324
+ <tr>
325
+ <th>Variable</th>
326
+ <th>Value</th>
327
+ </tr>
328
+ <% env.sort_by { |k, v| k.to_s }.each { |key, val| %>
329
+ <tr>
330
+ <td><%=h key %></td>
331
+ <td class="code"><div><%=h val %></div></td>
332
+ </tr>
333
+ <% } %>
334
+ </table>
335
+ <div class="clear"></div>
336
+ </div> <!-- /RACK ENV -->
337
+
338
+ <p id="explanation">You're seeing this error because you have
339
+ enabled the <code>show_exceptions</code> setting.</p>
340
+ </div> <!-- /WRAP -->
341
+ </body>
342
+ </html>
343
+ HTML
344
+ end
345
+ end
@@ -0,0 +1,3 @@
1
+ module Sinatra
2
+ VERSION = '1.4.5'
3
+ end
@@ -0,0 +1,19 @@
1
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
2
+ require 'sinatra/version'
3
+
4
+ Gem::Specification.new 'sinatra-acd', Sinatra::VERSION do |s|
5
+ s.description = "Sinatra is a DSL for quickly creating web applications in Ruby with minimal effort."
6
+ s.summary = "Classy web-development dressed in a DSL"
7
+ s.authors = ["Blake Mizerany", "Ryan Tomayko", "Simon Rozet", "Konstantin Haase"]
8
+ s.email = "sinatrarb@googlegroups.com"
9
+ s.homepage = "http://www.sinatrarb.com/"
10
+ s.license = 'MIT'
11
+ s.files = `git ls-files`.split("\n") - %w[.gitignore .travis.yml]
12
+ s.test_files = s.files.select { |p| p =~ /^test\/.*_test.rb/ }
13
+ s.extra_rdoc_files = s.files.select { |p| p =~ /^README/ } << 'LICENSE'
14
+ s.rdoc_options = %w[--line-numbers --inline-source --title Sinatra --main README.rdoc --encoding=UTF-8]
15
+
16
+ s.add_dependency 'rack', '~> 1.4'
17
+ s.add_dependency 'tilt', '~> 2.0.1'
18
+ s.add_dependency 'rack-protection', '~> 1.4'
19
+ end
@@ -0,0 +1,72 @@
1
+ require File.expand_path('../helper', __FILE__)
2
+
3
+ begin
4
+ require 'asciidoctor'
5
+
6
+ class AsciidoctorTest < Test::Unit::TestCase
7
+ def asciidoc_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 AsciiDoc strings' do
16
+ asciidoc_app { asciidoc '== Hiya' }
17
+ assert ok?
18
+ assert_match %r{<h2.*?>Hiya</h2>}, body
19
+ end
20
+
21
+ it 'uses the correct engine' do
22
+ engine = Tilt::AsciidoctorTemplate
23
+ assert_equal engine, Tilt[:ad]
24
+ assert_equal engine, Tilt[:adoc]
25
+ assert_equal engine, Tilt[:asciidoc]
26
+ end
27
+
28
+ it 'renders .asciidoc files in views path' do
29
+ asciidoc_app { asciidoc :hello }
30
+ assert ok?
31
+ assert_match %r{<h2.*?>Hello from AsciiDoc</h2>}, body
32
+ end
33
+
34
+ it 'raises error if template not found' do
35
+ mock_app { get('/') { asciidoc :no_such_template } }
36
+ assert_raise(Errno::ENOENT) { get('/') }
37
+ end
38
+
39
+ it 'renders with inline layouts' do
40
+ mock_app do
41
+ layout { 'THIS. IS. #{yield.upcase}!' }
42
+ get('/') { asciidoc 'Sparta', :layout_engine => :str }
43
+ end
44
+ get '/'
45
+ assert ok?
46
+ assert_include body, 'THIS. IS.'
47
+ assert_include body, '<P>SPARTA</P>'
48
+ end
49
+
50
+ it 'renders with file layouts' do
51
+ asciidoc_app do
52
+ asciidoc 'Hello World', :layout => :layout2, :layout_engine => :erb
53
+ end
54
+ assert ok?
55
+ assert_include body, 'ERB Layout!'
56
+ assert_include body, '<p>Hello World</p>'
57
+ end
58
+
59
+ it 'can be used in a nested fashion for partials and whatnot' do
60
+ mock_app do
61
+ template(:inner) { 'hi' }
62
+ template(:outer) { '<outer><%= asciidoc :inner %></outer>' }
63
+ get('/') { erb :outer }
64
+ end
65
+ get '/'
66
+ assert ok?
67
+ assert_match %r{<outer>.*<p.*?>hi</p>.*</outer>}m, body
68
+ end
69
+ end
70
+ rescue LoadError
71
+ warn "#{$!.to_s}: skipping asciidoc tests"
72
+ end