roda 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +34 -0
  3. data/Rakefile +22 -46
  4. data/doc/release_notes/2.3.0.txt +109 -0
  5. data/lib/roda/plugins/assets.rb +2 -1
  6. data/lib/roda/plugins/caching.rb +1 -1
  7. data/lib/roda/plugins/chunked.rb +1 -1
  8. data/lib/roda/plugins/error_email.rb +1 -1
  9. data/lib/roda/plugins/head.rb +6 -0
  10. data/lib/roda/plugins/heartbeat.rb +40 -0
  11. data/lib/roda/plugins/json.rb +23 -3
  12. data/lib/roda/plugins/json_parser.rb +72 -0
  13. data/lib/roda/plugins/mailer.rb +22 -5
  14. data/lib/roda/plugins/named_templates.rb +2 -2
  15. data/lib/roda/plugins/path_rewriter.rb +82 -0
  16. data/lib/roda/plugins/precompile_templates.rb +87 -0
  17. data/lib/roda/plugins/render.rb +111 -43
  18. data/lib/roda/plugins/render_each.rb +1 -1
  19. data/lib/roda/plugins/shared_vars.rb +1 -1
  20. data/lib/roda/plugins/view_options.rb +28 -3
  21. data/lib/roda/version.rb +1 -1
  22. data/spec/composition_spec.rb +3 -3
  23. data/spec/env_spec.rb +1 -1
  24. data/spec/freeze_spec.rb +6 -6
  25. data/spec/integration_spec.rb +16 -15
  26. data/spec/matchers_spec.rb +110 -110
  27. data/spec/opts_spec.rb +8 -8
  28. data/spec/plugin/_erubis_escaping_spec.rb +34 -3
  29. data/spec/plugin/all_verbs_spec.rb +8 -8
  30. data/spec/plugin/assets_spec.rb +164 -150
  31. data/spec/plugin/backtracking_array_spec.rb +18 -18
  32. data/spec/plugin/caching_spec.rb +70 -70
  33. data/spec/plugin/chunked_spec.rb +38 -38
  34. data/spec/plugin/class_level_routing_spec.rb +78 -78
  35. data/spec/plugin/content_for_spec.rb +2 -2
  36. data/spec/plugin/cookies_spec.rb +4 -4
  37. data/spec/plugin/csrf_spec.rb +8 -8
  38. data/spec/plugin/default_headers_spec.rb +6 -6
  39. data/spec/plugin/delay_build_spec.rb +7 -6
  40. data/spec/plugin/delegate_spec.rb +2 -2
  41. data/spec/plugin/delete_empty_headers_spec.rb +2 -2
  42. data/spec/plugin/drop_body_spec.rb +6 -6
  43. data/spec/plugin/empty_root_spec.rb +3 -3
  44. data/spec/plugin/environments_spec.rb +7 -7
  45. data/spec/plugin/error_email_spec.rb +23 -23
  46. data/spec/plugin/error_handler_spec.rb +14 -14
  47. data/spec/plugin/flash_spec.rb +30 -29
  48. data/spec/plugin/h_spec.rb +1 -1
  49. data/spec/plugin/halt_spec.rb +16 -16
  50. data/spec/plugin/hash_matcher_spec.rb +5 -5
  51. data/spec/plugin/head_spec.rb +10 -10
  52. data/spec/plugin/header_matchers_spec.rb +13 -13
  53. data/spec/plugin/heartbeat_spec.rb +74 -0
  54. data/spec/plugin/hooks_spec.rb +20 -20
  55. data/spec/plugin/indifferent_params_spec.rb +1 -1
  56. data/spec/plugin/json_parser_spec.rb +72 -0
  57. data/spec/plugin/json_spec.rb +22 -9
  58. data/spec/plugin/mailer_spec.rb +72 -58
  59. data/spec/plugin/match_affix_spec.rb +2 -2
  60. data/spec/plugin/middleware_spec.rb +7 -7
  61. data/spec/plugin/module_include_spec.rb +4 -4
  62. data/spec/plugin/multi_route_spec.rb +66 -66
  63. data/spec/plugin/multi_run_spec.rb +21 -21
  64. data/spec/plugin/named_templates_spec.rb +6 -6
  65. data/spec/plugin/not_allowed_spec.rb +17 -17
  66. data/spec/plugin/not_found_spec.rb +14 -14
  67. data/spec/plugin/padrino_render_spec.rb +2 -2
  68. data/spec/plugin/param_matchers_spec.rb +6 -6
  69. data/spec/plugin/partials_spec.rb +3 -3
  70. data/spec/plugin/pass_spec.rb +7 -7
  71. data/spec/plugin/path_matchers_spec.rb +6 -6
  72. data/spec/plugin/path_rewriter_spec.rb +37 -0
  73. data/spec/plugin/path_spec.rb +41 -40
  74. data/spec/plugin/per_thread_caching_spec.rb +6 -6
  75. data/spec/plugin/precompile_templates_spec.rb +74 -0
  76. data/spec/plugin/render_each_spec.rb +4 -4
  77. data/spec/plugin/render_spec.rb +179 -76
  78. data/spec/plugin/shared_vars_spec.rb +4 -4
  79. data/spec/plugin/sinatra_helpers_spec.rb +121 -121
  80. data/spec/plugin/slash_path_empty_spec.rb +10 -10
  81. data/spec/plugin/static_spec.rb +4 -4
  82. data/spec/plugin/streaming_spec.rb +11 -11
  83. data/spec/plugin/symbol_matchers_spec.rb +24 -24
  84. data/spec/plugin/symbol_views_spec.rb +3 -3
  85. data/spec/plugin/view_options_spec.rb +10 -10
  86. data/spec/plugin_spec.rb +2 -2
  87. data/spec/redirect_spec.rb +10 -10
  88. data/spec/request_spec.rb +8 -8
  89. data/spec/response_spec.rb +23 -23
  90. data/spec/session_spec.rb +4 -4
  91. data/spec/spec_helper.rb +5 -19
  92. data/spec/version_spec.rb +4 -4
  93. data/spec/views/iv.erb +1 -0
  94. metadata +16 -5
@@ -32,10 +32,10 @@ describe "render_each plugin" do
32
32
  end
33
33
  end
34
34
 
35
- body.should == 'rfoo1 rfoo2 rfoo3 '
36
- body("/a").should == 'rbar14 rbar24 rbar34 '
37
- body("/b").should == 'rbar rbar rbar '
38
- body("/c").should == 'rbar41 rbar42 rbar43 '
35
+ body.must_equal 'rfoo1 rfoo2 rfoo3 '
36
+ body("/a").must_equal 'rbar14 rbar24 rbar34 '
37
+ body("/b").must_equal 'rbar rbar rbar '
38
+ body("/c").must_equal 'rbar41 rbar42 rbar43 '
39
39
  end
40
40
  end
41
41
  end
@@ -36,35 +36,35 @@ describe "render plugin" do
36
36
  end
37
37
 
38
38
  it "default actions" do
39
- body("/about").strip.should == "<h1>About Roda</h1>"
40
- body("/home").strip.should == "<title>Roda: Home</title>\n<h1>Home</h1>\n<p>Hello Agent Smith</p>"
41
- body("/inline").strip.should == "Hello Agent Smith"
42
- body("/path").strip.should == "<h1>Path</h1>"
43
- body("/content").strip.should == "<title>Roda: Home</title>\nbar"
39
+ body("/about").strip.must_equal "<h1>About Roda</h1>"
40
+ body("/home").strip.must_equal "<title>Roda: Home</title>\n<h1>Home</h1>\n<p>Hello Agent Smith</p>"
41
+ body("/inline").strip.must_equal "Hello Agent Smith"
42
+ body("/path").strip.must_equal "<h1>Path</h1>"
43
+ body("/content").strip.must_equal "<title>Roda: Home</title>\nbar"
44
44
  end
45
45
 
46
46
  it "with str as engine" do
47
47
  app.plugin :render, :engine => "str"
48
- body("/about").strip.should == "<h1>About Roda</h1>"
49
- body("/home").strip.should == "<title>Roda: Home</title>\n<h1>Home</h1>\n<p>Hello Agent Smith</p>"
50
- body("/inline").strip.should == "Hello <%= name %>"
48
+ body("/about").strip.must_equal "<h1>About Roda</h1>"
49
+ body("/home").strip.must_equal "<title>Roda: Home</title>\n<h1>Home</h1>\n<p>Hello Agent Smith</p>"
50
+ body("/inline").strip.must_equal "Hello <%= name %>"
51
51
  end
52
52
 
53
53
  it "with str as ext" do
54
54
  app.plugin :render, :ext => "str"
55
- body("/about").strip.should == "<h1>About Roda</h1>"
56
- body("/home").strip.should == "<title>Roda: Home</title>\n<h1>Home</h1>\n<p>Hello Agent Smith</p>"
57
- body("/inline").strip.should == "Hello Agent Smith"
55
+ body("/about").strip.must_equal "<h1>About Roda</h1>"
56
+ body("/home").strip.must_equal "<title>Roda: Home</title>\n<h1>Home</h1>\n<p>Hello Agent Smith</p>"
57
+ body("/inline").strip.must_equal "Hello <%= name %>"
58
58
  end
59
59
 
60
60
  it "custom default layout support" do
61
61
  app.plugin :render, :layout => "layout-alternative"
62
- body("/home").strip.should == "<title>Alternative Layout: Home</title>\n<h1>Home</h1>\n<p>Hello Agent Smith</p>"
62
+ body("/home").strip.must_equal "<title>Alternative Layout: Home</title>\n<h1>Home</h1>\n<p>Hello Agent Smith</p>"
63
63
  end
64
64
 
65
65
  it "using hash for :layout" do
66
66
  app.plugin :render, :layout => {:inline=> 'a<%= yield %>b'}
67
- body("/home").strip.should == "a<h1>Home</h1>\n<p>Hello Agent Smith</p>\nb"
67
+ body("/home").strip.must_equal "a<h1>Home</h1>\n<p>Hello Agent Smith</p>\nb"
68
68
  end
69
69
  end
70
70
 
@@ -80,7 +80,7 @@ describe "render plugin" do
80
80
  end
81
81
  end
82
82
 
83
- body.gsub(/\n+/, "\n").should == "Header\nThis is the actual content.\nFooter\n"
83
+ body.gsub(/\n+/, "\n").must_equal "Header\nThis is the actual content.\nFooter\n"
84
84
  end
85
85
 
86
86
  it "views without default layouts" do
@@ -92,7 +92,7 @@ describe "render plugin" do
92
92
  end
93
93
  end
94
94
 
95
- body.strip.should == "<h1>Home</h1>\n<p>Hello Agent Smith</p>"
95
+ body.strip.must_equal "<h1>Home</h1>\n<p>Hello Agent Smith</p>"
96
96
  end
97
97
 
98
98
  it "layout overrides" do
@@ -104,7 +104,7 @@ describe "render plugin" do
104
104
  end
105
105
  end
106
106
 
107
- body.strip.should == "<title>Alternative Layout: Home</title>\n<h1>Home</h1>\n<p>Hello Agent Smith</p>"
107
+ body.strip.must_equal "<title>Alternative Layout: Home</title>\n<h1>Home</h1>\n<p>Hello Agent Smith</p>"
108
108
  end
109
109
 
110
110
  it "locals overrides" do
@@ -116,7 +116,7 @@ describe "render plugin" do
116
116
  end
117
117
  end
118
118
 
119
- body.strip.should == "Roda:AA::Home:BB"
119
+ body.strip.must_equal "Roda:AA::Home:BB"
120
120
  end
121
121
 
122
122
  it ":layout=>true/false/string/hash/not-present respects plugin layout switch and template" do
@@ -133,73 +133,73 @@ describe "render plugin" do
133
133
  end
134
134
  end
135
135
 
136
- body.gsub("\n", '').should == "HeaderbarFooter"
137
- body('/a').gsub("\n", '').should == "HeaderbarFooter"
138
- body('/f').gsub("\n", '').should == "bar"
139
- body('/s').gsub("\n", '').should == "<title>Roda: a</title>bar"
140
- body('/h').gsub("\n", '').should == "<title>Roda: a</title>bar"
136
+ body.gsub("\n", '').must_equal "HeaderbarFooter"
137
+ body('/a').gsub("\n", '').must_equal "HeaderbarFooter"
138
+ body('/f').gsub("\n", '').must_equal "bar"
139
+ body('/s').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
140
+ body('/h').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
141
141
 
142
142
  app.plugin :render
143
- body.gsub("\n", '').should == "HeaderbarFooter"
144
- body('/a').gsub("\n", '').should == "HeaderbarFooter"
145
- body('/f').gsub("\n", '').should == "bar"
146
- body('/s').gsub("\n", '').should == "<title>Roda: a</title>bar"
147
- body('/h').gsub("\n", '').should == "<title>Roda: a</title>bar"
143
+ body.gsub("\n", '').must_equal "HeaderbarFooter"
144
+ body('/a').gsub("\n", '').must_equal "HeaderbarFooter"
145
+ body('/f').gsub("\n", '').must_equal "bar"
146
+ body('/s').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
147
+ body('/h').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
148
148
 
149
149
  app.plugin :render, :layout=>true
150
- body.gsub("\n", '').should == "HeaderbarFooter"
151
- body('/a').gsub("\n", '').should == "HeaderbarFooter"
152
- body('/f').gsub("\n", '').should == "bar"
153
- body('/s').gsub("\n", '').should == "<title>Roda: a</title>bar"
154
- body('/h').gsub("\n", '').should == "<title>Roda: a</title>bar"
150
+ body.gsub("\n", '').must_equal "HeaderbarFooter"
151
+ body('/a').gsub("\n", '').must_equal "HeaderbarFooter"
152
+ body('/f').gsub("\n", '').must_equal "bar"
153
+ body('/s').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
154
+ body('/h').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
155
155
 
156
156
  app.plugin :render, :layout=>'layout-alternative'
157
- body.gsub("\n", '').should == "<title>Alternative Layout: a</title>bar"
158
- body('/a').gsub("\n", '').should == "<title>Alternative Layout: a</title>bar"
159
- body('/f').gsub("\n", '').should == "bar"
160
- body('/s').gsub("\n", '').should == "<title>Roda: a</title>bar"
161
- body('/h').gsub("\n", '').should == "<title>Roda: a</title>bar"
157
+ body.gsub("\n", '').must_equal "<title>Alternative Layout: a</title>bar"
158
+ body('/a').gsub("\n", '').must_equal "<title>Alternative Layout: a</title>bar"
159
+ body('/f').gsub("\n", '').must_equal "bar"
160
+ body('/s').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
161
+ body('/h').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
162
162
 
163
163
  app.plugin :render, :layout=>nil
164
- body.gsub("\n", '').should == "HeaderbarFooter"
165
- body('/a').gsub("\n", '').should == "bar"
166
- body('/f').gsub("\n", '').should == "bar"
167
- body('/s').gsub("\n", '').should == "<title>Roda: a</title>bar"
168
- body('/h').gsub("\n", '').should == "<title>Roda: a</title>bar"
164
+ body.gsub("\n", '').must_equal "HeaderbarFooter"
165
+ body('/a').gsub("\n", '').must_equal "bar"
166
+ body('/f').gsub("\n", '').must_equal "bar"
167
+ body('/s').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
168
+ body('/h').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
169
169
 
170
170
  app.plugin :render, :layout=>false
171
- body.gsub("\n", '').should == "HeaderbarFooter"
172
- body('/a').gsub("\n", '').should == "bar"
173
- body('/f').gsub("\n", '').should == "bar"
174
- body('/s').gsub("\n", '').should == "<title>Roda: a</title>bar"
175
- body('/h').gsub("\n", '').should == "<title>Roda: a</title>bar"
171
+ body.gsub("\n", '').must_equal "HeaderbarFooter"
172
+ body('/a').gsub("\n", '').must_equal "bar"
173
+ body('/f').gsub("\n", '').must_equal "bar"
174
+ body('/s').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
175
+ body('/h').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
176
176
 
177
177
  app.plugin :render, :layout_opts=>{:template=>'layout-alternative', :locals=>{:title=>'a'}}
178
- body.gsub("\n", '').should == "<title>Alternative Layout: a</title>bar"
179
- body('/a').gsub("\n", '').should == "bar"
180
- body('/f').gsub("\n", '').should == "bar"
181
- body('/s').gsub("\n", '').should == "<title>Roda: a</title>bar"
182
- body('/h').gsub("\n", '').should == "<title>Roda: a</title>bar"
178
+ body.gsub("\n", '').must_equal "<title>Alternative Layout: a</title>bar"
179
+ body('/a').gsub("\n", '').must_equal "bar"
180
+ body('/f').gsub("\n", '').must_equal "bar"
181
+ body('/s').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
182
+ body('/h').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
183
183
  end
184
184
 
185
185
  it "app :root option affects :views default" do
186
186
  app
187
187
  app.plugin :render
188
- app.render_opts[:views].should == File.join(Dir.pwd, 'views')
188
+ app.render_opts[:views].must_equal File.join(Dir.pwd, 'views')
189
189
 
190
190
  app.opts[:root] = '/foo'
191
191
  app.plugin :render
192
- app.render_opts[:views].should == '/foo/views'
192
+ app.render_opts[:views].must_equal '/foo/views'
193
193
 
194
194
  app.opts[:root] = '/foo/bar'
195
195
  app.plugin :render
196
- app.render_opts[:views].should == '/foo/bar/views'
196
+ app.render_opts[:views].must_equal '/foo/bar/views'
197
197
 
198
198
  app.opts[:root] = nil
199
199
  app.plugin :render
200
- app.render_opts[:views].should == File.join(Dir.pwd, 'views')
200
+ app.render_opts[:views].must_equal File.join(Dir.pwd, 'views')
201
201
  app.plugin :render, :views=>'bar'
202
- app.render_opts[:views].should == File.join(Dir.pwd, 'bar')
202
+ app.render_opts[:views].must_equal File.join(Dir.pwd, 'bar')
203
203
  end
204
204
 
205
205
  it "inline layouts and inline views" do
@@ -207,7 +207,7 @@ describe "render plugin" do
207
207
  view({:inline=>'bar'}, :layout=>{:inline=>'Foo: <%= yield %>'})
208
208
  end
209
209
 
210
- body.strip.should == "Foo: bar"
210
+ body.strip.must_equal "Foo: bar"
211
211
  end
212
212
 
213
213
  it "inline renders with opts" do
@@ -215,7 +215,7 @@ describe "render plugin" do
215
215
  render({:inline=>'<%= bar %>'}, {:engine=>'str'})
216
216
  end
217
217
 
218
- body.strip.should == '<%= bar %>'
218
+ body.strip.must_equal '<%= bar %>'
219
219
  end
220
220
 
221
221
  it "template renders with :template opts" do
@@ -225,7 +225,7 @@ describe "render plugin" do
225
225
  render(:template=>"about", :locals=>{:title => "About Roda"})
226
226
  end
227
227
  end
228
- body.strip.should == "<h1>About Roda</h1>"
228
+ body.strip.must_equal "<h1>About Roda</h1>"
229
229
  end
230
230
 
231
231
  it "template renders with :template_class opts" do
@@ -233,7 +233,22 @@ describe "render plugin" do
233
233
  @a = 1
234
234
  render(:inline=>'i#{@a}', :template_class=>::Tilt[:str])
235
235
  end
236
- body.should == "i1"
236
+ body.must_equal "i1"
237
+ end
238
+
239
+ it "can specify engine-specific options via :engine_opts" do
240
+ app(:bare) do
241
+ plugin :render, :engine_opts=>{'a.erb'=>{:outvar=>'@a'}}
242
+ route do |r|
243
+ r.is('a') do
244
+ render(:inline=>'<%= @a.class.name %>', :engine=>'a.erb')
245
+ end
246
+ render(:inline=>'<%= @a.class.name %>')
247
+ end
248
+ end
249
+
250
+ body('/a').must_equal "String"
251
+ body.must_equal "NilClass"
237
252
  end
238
253
 
239
254
  it "template cache respects :template_opts" do
@@ -256,32 +271,120 @@ describe "render plugin" do
256
271
  end
257
272
  end
258
273
 
259
- body('/a').should == "i-a"
260
- body('/b').should == "i-b"
274
+ body('/a').must_equal "i-a"
275
+ body('/b').must_equal "i-b"
261
276
  end
262
277
 
263
- it "template cache respects :template_opts" do
278
+ it "template cache respects :template_block" do
264
279
  c = Class.new do
265
- def initialize(path, _, opts)
280
+ def initialize(path, *, &block)
266
281
  @path = path
267
- @opts = opts
282
+ @block = block
268
283
  end
269
284
  def render(*)
270
- "#{@path}-#{@opts[:foo]}"
285
+ "#{@path}-#{@block.call}"
286
+ end
287
+ end
288
+
289
+ proca = proc{'a'}
290
+ procb = proc{'b'}
291
+
292
+ app(:render) do |r|
293
+ r.is "a" do
294
+ render(:path=>"i", :template_class=>c, :template_block=>proca)
295
+ end
296
+ r.is "b" do
297
+ render(:path=>"i", :template_class=>c, :template_block=>procb)
271
298
  end
272
299
  end
273
300
 
301
+ body('/a').must_equal "i-a"
302
+ body('/b').must_equal "i-b"
303
+ end
304
+
305
+ it "template cache respects :locals" do
306
+ template = '<%= @a ? b : c %>'
307
+
274
308
  app(:render) do |r|
275
309
  r.is "a" do
276
- render(:inline=>"i", :template_class=>c, :template_opts=>{:foo=>'a'})
310
+ @a = true
311
+ render(:inline=>template.dup, :locals=>{:b=>1})
277
312
  end
278
313
  r.is "b" do
279
- render(:inline=>"i", :template_class=>c, :template_opts=>{:foo=>'b'})
314
+ @a = true
315
+ render(:inline=>template.dup, :locals=>{:b=>2, :c=>4})
316
+ end
317
+ r.is "c" do
318
+ render(:inline=>template.dup, :locals=>{:c=>3})
319
+ end
320
+ end
321
+
322
+ body('/a').must_equal "1"
323
+ body('/b').must_equal "2"
324
+ body('/c').must_equal "3"
325
+ end
326
+
327
+ it "Support :cache=>false option to disable template caching" do
328
+ app(:bare) do
329
+ plugin :render, :views=>"./spec/views"
330
+
331
+ route do |r|
332
+ @a = 'a'
333
+ r.is('a'){render('iv', :cache=>false)}
334
+ render('iv')
335
+ end
336
+ end
337
+
338
+ body('/a').strip.must_equal "a"
339
+ app.render_opts[:cache][File.expand_path('spec/views/iv.erb')].must_equal nil
340
+ body('/b').strip.must_equal "a"
341
+ app.render_opts[:cache][File.expand_path('spec/views/iv.erb')].wont_equal nil
342
+ end
343
+
344
+ it "Support :cache=>true option to enable template caching when :template_block is used" do
345
+ c = Class.new do
346
+ def initialize(path, *, &block)
347
+ @path = path
348
+ @block = block
349
+ end
350
+ def render(*)
351
+ "#{@path}-#{@block.call}"
352
+ end
353
+ end
354
+
355
+ proca = proc{'a'}
356
+
357
+ app(:bare) do
358
+ plugin :render, :views=>"./spec/views"
359
+
360
+ route do |r|
361
+ @a = 'a'
362
+ r.is('a'){render(:path=>'iv', :template_class=>c, :template_block=>proca)}
363
+ render(:path=>'iv', :template_class=>c, :template_block=>proca, :cache=>true)
364
+ end
365
+ end
366
+
367
+ body('/a').strip.must_equal "iv-a"
368
+ app.render_opts[:cache][['iv', c, nil, nil, proca]].must_equal nil
369
+ body('/b').strip.must_equal "iv-a"
370
+ app.render_opts[:cache][['iv', c, nil, nil, proca]].wont_equal nil
371
+ end
372
+
373
+ it "Support :cache_key option to force the key used when caching" do
374
+ app(:bare) do
375
+ plugin :render, :views=>"./spec/views"
376
+
377
+ route do |r|
378
+ @a = 'a'
379
+ r.is('a'){render('iv', :cache_key=>:a)}
380
+ r.is('about'){render('about', :cache_key=>:a, :cache=>false, :locals=>{:title=>'a'})}
381
+ render('about', :cache_key=>:a)
280
382
  end
281
383
  end
282
384
 
283
- body('/a').should == "i-a"
284
- body('/b').should == "i-b"
385
+ body('/a').strip.must_equal "a"
386
+ body('/b').strip.must_equal "a"
387
+ body('/about').strip.must_equal "<h1>a</h1>"
285
388
  end
286
389
 
287
390
  it "render_opts inheritance" do
@@ -289,15 +392,15 @@ describe "render plugin" do
289
392
  c.plugin :render
290
393
  sc = Class.new(c)
291
394
 
292
- c.render_opts.should_not equal(sc.render_opts)
293
- c.render_opts[:cache].should_not equal(sc.render_opts[:cache])
395
+ c.render_opts.wont_be_same_as(sc.render_opts)
396
+ c.render_opts[:cache].wont_be_same_as(sc.render_opts[:cache])
294
397
  end
295
398
 
296
399
  it "render plugin call should not override options" do
297
400
  c = Class.new(Roda)
298
401
  c.plugin :render, :layout=>:foo
299
402
  c.plugin :render
300
- c.render_opts[:layout].should == :foo
403
+ c.render_opts[:layout].must_equal :foo
301
404
  end
302
405
 
303
406
  it "with caching disabled" do
@@ -309,9 +412,9 @@ describe "render plugin" do
309
412
  end
310
413
  end
311
414
 
312
- body("/inline").strip.should == "Hello Agent Smith: false"
415
+ body("/inline").strip.must_equal "Hello Agent Smith: false"
313
416
 
314
- Class.new(app).render_opts[:cache].should == false
417
+ Class.new(app).render_opts[:cache].must_equal false
315
418
  end
316
419
  end
317
420
  end
@@ -9,7 +9,7 @@ describe "shared_vars plugin" do
9
9
  r.run old_app
10
10
  end
11
11
 
12
- body.should == 'c'
12
+ body.must_equal 'c'
13
13
  end
14
14
 
15
15
  it "adds shared with hash merges the hash into the shared vars" do
@@ -18,7 +18,7 @@ describe "shared_vars plugin" do
18
18
  shared[:c]
19
19
  end
20
20
 
21
- body.should == 'c'
21
+ body.must_equal 'c'
22
22
  end
23
23
 
24
24
  it "calling shared with hash and a block sets shared variables only for that block" do
@@ -33,13 +33,13 @@ describe "shared_vars plugin" do
33
33
  "#{shared[:c]}:#{shared[:d]}:#{c}:#{d}"
34
34
  end
35
35
 
36
- body.should == 'b::c:d'
36
+ body.must_equal 'b::c:d'
37
37
  end
38
38
 
39
39
  it "calling shared with no arguments and a block raises an error" do
40
40
  app(:shared_vars) do |r|
41
41
  shared{}
42
42
  end
43
- proc{body}.should raise_error(Roda::RodaError)
43
+ proc{body}.must_raise(Roda::RodaError)
44
44
  end
45
45
  end