roda 2.29.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +52 -0
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +51 -109
  5. data/Rakefile +7 -14
  6. data/doc/conventions.rdoc +4 -4
  7. data/doc/release_notes/1.2.0.txt +1 -1
  8. data/doc/release_notes/3.0.0.txt +84 -0
  9. data/lib/roda.rb +25 -79
  10. data/lib/roda/plugins/assets.rb +25 -58
  11. data/lib/roda/plugins/assets_preloading.rb +0 -5
  12. data/lib/roda/plugins/backtracking_array.rb +0 -5
  13. data/lib/roda/plugins/branch_locals.rb +3 -3
  14. data/lib/roda/plugins/caching.rb +5 -38
  15. data/lib/roda/plugins/chunked.rb +7 -25
  16. data/lib/roda/plugins/class_level_routing.rb +2 -2
  17. data/lib/roda/plugins/content_for.rb +7 -10
  18. data/lib/roda/plugins/cookies.rb +3 -3
  19. data/lib/roda/plugins/csrf.rb +2 -2
  20. data/lib/roda/plugins/delegate.rb +3 -3
  21. data/lib/roda/plugins/drop_body.rb +0 -7
  22. data/lib/roda/plugins/empty_root.rb +0 -3
  23. data/lib/roda/plugins/error_email.rb +4 -6
  24. data/lib/roda/plugins/error_handler.rb +1 -2
  25. data/lib/roda/plugins/error_mail.rb +3 -6
  26. data/lib/roda/plugins/flash.rb +0 -4
  27. data/lib/roda/plugins/h.rb +5 -0
  28. data/lib/roda/plugins/hash_matcher.rb +4 -2
  29. data/lib/roda/plugins/head.rb +5 -7
  30. data/lib/roda/plugins/header_matchers.rb +12 -33
  31. data/lib/roda/plugins/heartbeat.rb +2 -7
  32. data/lib/roda/plugins/indifferent_params.rb +2 -2
  33. data/lib/roda/plugins/json.rb +6 -14
  34. data/lib/roda/plugins/json_parser.rb +2 -13
  35. data/lib/roda/plugins/mailer.rb +29 -39
  36. data/lib/roda/plugins/match_affix.rb +0 -5
  37. data/lib/roda/plugins/middleware.rb +10 -15
  38. data/lib/roda/plugins/multi_route.rb +8 -5
  39. data/lib/roda/plugins/multi_run.rb +1 -0
  40. data/lib/roda/plugins/named_templates.rb +2 -2
  41. data/lib/roda/plugins/optimized_string_matchers.rb +0 -3
  42. data/lib/roda/plugins/padrino_render.rb +6 -9
  43. data/lib/roda/plugins/param_matchers.rb +6 -6
  44. data/lib/roda/plugins/params_capturing.rb +15 -35
  45. data/lib/roda/plugins/partials.rb +3 -8
  46. data/lib/roda/plugins/path.rb +5 -5
  47. data/lib/roda/plugins/path_matchers.rb +3 -3
  48. data/lib/roda/plugins/path_rewriter.rb +4 -9
  49. data/lib/roda/plugins/placeholder_string_matchers.rb +1 -1
  50. data/lib/roda/plugins/precompile_templates.rb +10 -20
  51. data/lib/roda/plugins/public.rb +6 -9
  52. data/lib/roda/plugins/render.rb +50 -171
  53. data/lib/roda/plugins/render_each.rb +4 -7
  54. data/lib/roda/plugins/render_locals.rb +6 -20
  55. data/lib/roda/plugins/request_headers.rb +2 -4
  56. data/lib/roda/plugins/run_append_slash.rb +1 -4
  57. data/lib/roda/plugins/run_handler.rb +4 -7
  58. data/lib/roda/plugins/shared_vars.rb +3 -6
  59. data/lib/roda/plugins/sinatra_helpers.rb +11 -40
  60. data/lib/roda/plugins/slash_path_empty.rb +0 -3
  61. data/lib/roda/plugins/static.rb +2 -2
  62. data/lib/roda/plugins/static_routing.rb +2 -3
  63. data/lib/roda/plugins/streaming.rb +15 -108
  64. data/lib/roda/plugins/strip_path_prefix.rb +1 -1
  65. data/lib/roda/plugins/symbol_matchers.rb +7 -23
  66. data/lib/roda/plugins/type_routing.rb +4 -9
  67. data/lib/roda/plugins/view_options.rb +10 -66
  68. data/lib/roda/version.rb +2 -2
  69. data/spec/all.rb +0 -2
  70. data/spec/composition_spec.rb +1 -1
  71. data/spec/env_spec.rb +1 -1
  72. data/spec/freeze_spec.rb +1 -1
  73. data/spec/integration_spec.rb +1 -1
  74. data/spec/matchers_spec.rb +26 -70
  75. data/spec/opts_spec.rb +1 -1
  76. data/spec/plugin/all_verbs_spec.rb +1 -1
  77. data/spec/plugin/assets_preloading_spec.rb +1 -1
  78. data/spec/plugin/assets_spec.rb +43 -27
  79. data/spec/plugin/backtracking_array_spec.rb +1 -1
  80. data/spec/plugin/branch_locals_spec.rb +1 -1
  81. data/spec/plugin/caching_spec.rb +1 -1
  82. data/spec/plugin/chunked_spec.rb +1 -1
  83. data/spec/plugin/class_level_routing_spec.rb +1 -1
  84. data/spec/plugin/class_matchers_spec.rb +1 -1
  85. data/spec/plugin/content_for_spec.rb +2 -7
  86. data/spec/plugin/cookies_spec.rb +1 -1
  87. data/spec/plugin/csrf_spec.rb +1 -1
  88. data/spec/plugin/default_headers_spec.rb +1 -1
  89. data/spec/plugin/default_status_spec.rb +1 -1
  90. data/spec/plugin/delay_build_spec.rb +1 -1
  91. data/spec/plugin/delegate_spec.rb +1 -1
  92. data/spec/plugin/delete_empty_headers_spec.rb +1 -1
  93. data/spec/plugin/disallow_file_uploads_spec.rb +2 -2
  94. data/spec/plugin/drop_body_spec.rb +1 -1
  95. data/spec/plugin/empty_root_spec.rb +1 -1
  96. data/spec/plugin/environments_spec.rb +1 -1
  97. data/spec/plugin/error_email_spec.rb +1 -1
  98. data/spec/plugin/error_handler_spec.rb +1 -1
  99. data/spec/plugin/error_mail_spec.rb +2 -2
  100. data/spec/plugin/flash_spec.rb +1 -1
  101. data/spec/plugin/h_spec.rb +1 -1
  102. data/spec/plugin/halt_spec.rb +2 -2
  103. data/spec/plugin/hash_matcher_spec.rb +1 -1
  104. data/spec/plugin/head_spec.rb +1 -1
  105. data/spec/plugin/header_matchers_spec.rb +4 -47
  106. data/spec/plugin/heartbeat_spec.rb +1 -1
  107. data/spec/plugin/hooks_spec.rb +1 -1
  108. data/spec/plugin/indifferent_params_spec.rb +1 -1
  109. data/spec/plugin/json_parser_spec.rb +12 -1
  110. data/spec/plugin/json_spec.rb +8 -1
  111. data/spec/plugin/mailer_spec.rb +1 -1
  112. data/spec/plugin/match_affix_spec.rb +1 -1
  113. data/spec/plugin/middleware_spec.rb +15 -1
  114. data/spec/plugin/module_include_spec.rb +1 -1
  115. data/spec/plugin/multi_route_spec.rb +5 -3
  116. data/spec/plugin/multi_run_spec.rb +1 -1
  117. data/spec/plugin/multi_view_spec.rb +1 -1
  118. data/spec/plugin/named_templates_spec.rb +1 -1
  119. data/spec/plugin/not_allowed_spec.rb +1 -1
  120. data/spec/plugin/not_found_spec.rb +1 -1
  121. data/spec/plugin/optimized_string_matchers_spec.rb +1 -1
  122. data/spec/plugin/padrino_render_spec.rb +1 -1
  123. data/spec/plugin/param_matchers_spec.rb +1 -1
  124. data/spec/plugin/params_capturing_spec.rb +6 -22
  125. data/spec/plugin/partials_spec.rb +1 -1
  126. data/spec/plugin/pass_spec.rb +1 -1
  127. data/spec/plugin/path_matchers_spec.rb +1 -1
  128. data/spec/plugin/path_rewriter_spec.rb +1 -1
  129. data/spec/plugin/path_spec.rb +1 -1
  130. data/spec/plugin/placeholder_string_matchers_spec.rb +3 -36
  131. data/spec/plugin/precompile_templates_spec.rb +1 -17
  132. data/spec/plugin/public_spec.rb +3 -4
  133. data/spec/plugin/render_each_spec.rb +1 -1
  134. data/spec/plugin/render_locals_spec.rb +1 -1
  135. data/spec/plugin/render_spec.rb +28 -114
  136. data/spec/plugin/request_headers_spec.rb +1 -1
  137. data/spec/plugin/response_request_spec.rb +1 -1
  138. data/spec/plugin/run_append_slash_spec.rb +1 -1
  139. data/spec/plugin/run_handler_spec.rb +1 -1
  140. data/spec/plugin/shared_vars_spec.rb +1 -1
  141. data/spec/plugin/sinatra_helpers_spec.rb +1 -1
  142. data/spec/plugin/slash_path_empty_spec.rb +1 -1
  143. data/spec/plugin/static_routing_spec.rb +1 -1
  144. data/spec/plugin/static_spec.rb +1 -1
  145. data/spec/plugin/status_303_spec.rb +1 -1
  146. data/spec/plugin/status_handler_spec.rb +1 -1
  147. data/spec/plugin/streaming_spec.rb +1 -106
  148. data/spec/plugin/strip_path_prefix_spec.rb +1 -1
  149. data/spec/plugin/symbol_matchers_spec.rb +1 -77
  150. data/spec/plugin/symbol_status_spec.rb +1 -1
  151. data/spec/plugin/symbol_views_spec.rb +1 -1
  152. data/spec/plugin/type_routing_spec.rb +1 -1
  153. data/spec/plugin/unescape_path_spec.rb +1 -1
  154. data/spec/plugin/view_options_spec.rb +16 -110
  155. data/spec/plugin_spec.rb +1 -1
  156. data/spec/redirect_spec.rb +1 -1
  157. data/spec/request_spec.rb +1 -1
  158. data/spec/response_spec.rb +1 -1
  159. data/spec/session_spec.rb +1 -1
  160. data/spec/spec_helper.rb +1 -3
  161. data/spec/version_spec.rb +1 -1
  162. metadata +6 -26
  163. data/lib/roda/plugins/_erubis_escaping.rb +0 -59
  164. data/lib/roda/plugins/per_thread_caching.rb +0 -71
  165. data/lib/roda/plugins/static_path_info.rb +0 -12
  166. data/lib/roda/plugins/view_subdirs.rb +0 -7
  167. data/lib/roda/plugins/websockets.rb +0 -107
  168. data/spec/plugin/_erubis_escaping_spec.rb +0 -97
  169. data/spec/plugin/per_thread_caching_spec.rb +0 -28
  170. data/spec/plugin/websockets_spec.rb +0 -84
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
 
3
3
  run_tests = true
4
4
  begin
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
  require 'fileutils'
3
3
 
4
4
  run_tests = true
@@ -283,10 +283,10 @@ if run_tests
283
283
  app.compile_assets
284
284
  html = body('/test')
285
285
  html.scan(/<link/).length.must_equal 1
286
- html =~ %r{href="(/assets/app\.[a-f0-9]{40}\.css)"}
286
+ html =~ %r{href="(/assets/app\.[a-f0-9]{64}\.css)"}
287
287
  css = body($1)
288
288
  html.scan(/<script/).length.must_equal 1
289
- html =~ %r{src="(/assets/app\.head\.[a-f0-9]{40}\.js)"}
289
+ html =~ %r{src="(/assets/app\.head\.[a-f0-9]{64}\.js)"}
290
290
  js = body($1)
291
291
  css.must_match(/color: ?red/)
292
292
  css.must_match(/color: ?blue/)
@@ -294,7 +294,7 @@ if run_tests
294
294
  end
295
295
 
296
296
  [[:sha256, 64, 44], [:sha384, 96, 64], [:sha512, 128, 88]].each do |algo, hex_length, base64_length|
297
- it "should handle :sri option for subresource integrity for #{algo} when compiling assets" do
297
+ it "should handle :sri option for subresource integrity #{algo} when compiling assets" do
298
298
  app.plugin :assets, :sri=>algo
299
299
  app.compile_assets
300
300
  html = body('/test')
@@ -318,14 +318,30 @@ if run_tests
318
318
  end
319
319
  end
320
320
 
321
+ it "should handle :sri=>nil option for to disable subresource integrity when compiling assets" do
322
+ app.plugin :assets, :sri=>nil
323
+ app.compile_assets
324
+ html = body('/test')
325
+ html.scan(/<link/).length.must_equal 1
326
+ html.scan(/<script/).length.must_equal 1
327
+ html.wont_match %r|et" integrity="|
328
+ html =~ %r|href="(/assets/app\.[a-f0-9]{64}\.css)"|
329
+ css = body($1)
330
+ html =~ %r|src="(/assets/app\.head\.[a-f0-9]{64}\.js)"|
331
+ js = body($1)
332
+ css.must_match(/color: ?red/)
333
+ css.must_match(/color: ?blue/)
334
+ js.must_include('console.log')
335
+ end
336
+
321
337
  it 'should handle linking to compiled assets when a compiled asset host is used' do
322
338
  app.plugin :assets, :compiled_asset_host=>'https://cdn.example.com'
323
339
  app.compile_assets
324
340
  html = body('/test')
325
341
  html.scan(/<link/).length.must_equal 1
326
- html.must_match %r{href="https://cdn\.example\.com/assets/app\.[a-f0-9]{40}\.css"}
342
+ html.must_match %r{href="https://cdn\.example\.com/assets/app\.[a-f0-9]{64}\.css"}
327
343
  html.scan(/<script/).length.must_equal 1
328
- html.must_match %r{src="https://cdn\.example\.com/assets/app\.head\.[a-f0-9]{40}\.js"}
344
+ html.must_match %r{src="https://cdn\.example\.com/assets/app\.head\.[a-f0-9]{64}\.js"}
329
345
  end
330
346
 
331
347
  it 'should handle compiling assets, linking to them, and accepting requests for them when :gzip is set' do
@@ -333,10 +349,10 @@ if run_tests
333
349
  app.compile_assets
334
350
  html = body('/test')
335
351
  html.scan(/<link/).length.must_equal 1
336
- html =~ %r{href="(/assets/app\.[a-f0-9]{40}\.css)"}
352
+ html =~ %r{href="(/assets/app\.[a-f0-9]{64}\.css)"}
337
353
  css_path = $1
338
354
  html.scan(/<script/).length.must_equal 1
339
- html =~ %r{src="(/assets/app\.head\.[a-f0-9]{40}\.js)"}
355
+ html =~ %r{src="(/assets/app\.head\.[a-f0-9]{64}\.js)"}
340
356
  js_path = $1
341
357
 
342
358
  css = body(css_path)
@@ -357,10 +373,10 @@ if run_tests
357
373
  app.plugin :assets
358
374
  app.compile_assets
359
375
  html = body('/test', 'SCRIPT_NAME'=>'/foo')
360
- html =~ %r{href="/foo(/assets/app\.[a-f0-9]{40}\.css)"}
376
+ html =~ %r{href="/foo(/assets/app\.[a-f0-9]{64}\.css)"}
361
377
  css = body($1)
362
378
  html.scan(/<script/).length.must_equal 1
363
- html =~ %r{src="/foo(/assets/app\.head\.[a-f0-9]{40}\.js)"}
379
+ html =~ %r{src="/foo(/assets/app\.head\.[a-f0-9]{64}\.js)"}
364
380
  js = body($1)
365
381
  css.must_match(/color: ?red/)
366
382
  css.must_match(/color: ?blue/)
@@ -373,10 +389,10 @@ if run_tests
373
389
  app.compile_assets
374
390
  html = body('/test')
375
391
  html.scan(/<link/).length.must_equal 1
376
- html =~ %r{href="(/a/bar/app\.[a-f0-9]{40}\.css)"}
392
+ html =~ %r{href="(/a/bar/app\.[a-f0-9]{64}\.css)"}
377
393
  css = body($1)
378
394
  html.scan(/<script/).length.must_equal 1
379
- html =~ %r{src="(/a/foo/app\.head\.[a-f0-9]{40}\.js)"}
395
+ html =~ %r{src="(/a/foo/app\.head\.[a-f0-9]{64}\.js)"}
380
396
  js = body($1)
381
397
  css.must_match(/color: ?red/)
382
398
  css.must_match(/color: ?blue/)
@@ -395,10 +411,10 @@ if run_tests
395
411
  end
396
412
  html = body('/test')
397
413
  html.scan(/<link/).length.must_equal 1
398
- html =~ %r{href="(/assets/app\.assets\.css\.[a-f0-9]{40}\.css)"}
414
+ html =~ %r{href="(/assets/app\.assets\.css\.[a-f0-9]{64}\.css)"}
399
415
  css = body($1)
400
416
  html.scan(/<script/).length.must_equal 1
401
- html =~ %r{src="(/assets/app\.assets\.js\.head\.[a-f0-9]{40}\.js)"}
417
+ html =~ %r{src="(/assets/app\.assets\.js\.head\.[a-f0-9]{64}\.js)"}
402
418
  js = body($1)
403
419
  css.must_match(/color: ?red/)
404
420
  css.must_match(/color: ?blue/)
@@ -418,10 +434,10 @@ if run_tests
418
434
  end
419
435
  html = body('/test', 'SCRIPT_NAME'=>'/foo')
420
436
  html.scan(/<link/).length.must_equal 1
421
- html =~ %r{href="/foo(/assets/app\.assets\.css\.[a-f0-9]{40}\.css)"}
437
+ html =~ %r{href="/foo(/assets/app\.assets\.css\.[a-f0-9]{64}\.css)"}
422
438
  css = body($1)
423
439
  html.scan(/<script/).length.must_equal 1
424
- html =~ %r{src="/foo(/assets/app\.assets\.js\.head\.[a-f0-9]{40}\.js)"}
440
+ html =~ %r{src="/foo(/assets/app\.assets\.js\.head\.[a-f0-9]{64}\.js)"}
425
441
  js = body($1)
426
442
  css.must_match(/color: ?red/)
427
443
  css.must_match(/color: ?blue/)
@@ -440,10 +456,10 @@ if run_tests
440
456
  end
441
457
  html = body('/test')
442
458
  html.scan(/<link/).length.must_equal 1
443
- html =~ %r{href="(/assets/app\.assets\.css\.[a-f0-9]{40}\.css)"}
459
+ html =~ %r{href="(/assets/app\.assets\.css\.[a-f0-9]{64}\.css)"}
444
460
  css = body($1)
445
461
  html.scan(/<script/).length.must_equal 1
446
- html =~ %r{src="(/assets/app\.assets\.js\.head\.[a-f0-9]{40}\.js)"}
462
+ html =~ %r{src="(/assets/app\.assets\.js\.head\.[a-f0-9]{64}\.js)"}
447
463
  js = body($1)
448
464
  css.must_match(/color: ?red/)
449
465
  css.must_match(/color: ?blue/)
@@ -455,10 +471,10 @@ if run_tests
455
471
  app.compile_assets
456
472
  html = body('/test')
457
473
  html.scan(/<link/).length.must_equal 1
458
- html =~ %r{href="(/assets/app\.[a-f0-9]{40}\.css)"}
474
+ html =~ %r{href="(/assets/app\.[a-f0-9]{64}\.css)"}
459
475
  css = body($1)
460
476
  html.scan(/<script/).length.must_equal 1
461
- html =~ %r{src="(/assets/app\.head\.[a-f0-9]{40}\.js)"}
477
+ html =~ %r{src="(/assets/app\.head\.[a-f0-9]{64}\.js)"}
462
478
  js = body($1)
463
479
  css.must_match(/color: ?red/)
464
480
  css.must_match(/color: ?blue/)
@@ -469,7 +485,7 @@ if run_tests
469
485
  app.compile_assets(:css)
470
486
  html = body('/test')
471
487
  html.scan(/<link/).length.must_equal 1
472
- html =~ %r{href="(/assets/app\.[a-f0-9]{40}\.css)"}
488
+ html =~ %r{href="(/assets/app\.[a-f0-9]{64}\.css)"}
473
489
  css = body($1)
474
490
  html.scan(/<script/).length.must_equal 0
475
491
  css.must_match(/color: ?red/)
@@ -481,7 +497,7 @@ if run_tests
481
497
  html = body('/test')
482
498
  html.scan(/<link/).length.must_equal 0
483
499
  html.scan(/<script/).length.must_equal 1
484
- html =~ %r{src="(/assets/app\.head\.[a-f0-9]{40}\.js)"}
500
+ html =~ %r{src="(/assets/app\.head\.[a-f0-9]{64}\.js)"}
485
501
  js = body($1)
486
502
  js.must_include('console.log')
487
503
  end
@@ -491,7 +507,7 @@ if run_tests
491
507
  html = body('/test')
492
508
  html.scan(/<link/).length.must_equal 0
493
509
  html.scan(/<script/).length.must_equal 1
494
- html =~ %r{src="(/assets/app\.head\.[a-f0-9]{40}\.js)"}
510
+ html =~ %r{src="(/assets/app\.head\.[a-f0-9]{64}\.js)"}
495
511
  js = body($1)
496
512
  js.must_include('console.log')
497
513
  end
@@ -502,7 +518,7 @@ if run_tests
502
518
  html = body('/test')
503
519
  html.scan(/<link/).length.must_equal 0
504
520
  html.scan(/<script/).length.must_equal 1
505
- html =~ %r{src="(/assets/app\.head\.[a-f0-9]{40}\.js)"}
521
+ html =~ %r{src="(/assets/app\.head\.[a-f0-9]{64}\.js)"}
506
522
  js = body($1)
507
523
  js.must_include('console.log')
508
524
  end
@@ -513,7 +529,7 @@ if run_tests
513
529
  html = body('/test')
514
530
  html.scan(/<link/).length.must_equal 0
515
531
  html.scan(/<script/).length.must_equal 1
516
- html =~ %r{src="(/assets/app\.head\.[a-f0-9]{40}\.js)"}
532
+ html =~ %r{src="(/assets/app\.head\.[a-f0-9]{64}\.js)"}
517
533
  js = body($1)
518
534
  js.must_include('console.log')
519
535
  end
@@ -612,13 +628,13 @@ if run_tests
612
628
 
613
629
  app.compile_assets
614
630
  File.exist?(metadata_file).must_equal true
615
- app.allocate.assets([:js, :head]).must_match %r{src="(/assets/app\.head\.[a-f0-9]{40}\.js)"}
631
+ app.allocate.assets([:js, :head]).must_match %r{src="(/assets/app\.head\.[a-f0-9]{64}\.js)"}
616
632
 
617
633
  app.plugin :assets, :compiled=>false, :precompiled=>false
618
634
  app.allocate.assets([:js, :head]).must_equal '<script type="text/javascript" src="/assets/js/head/app.js"></script>'
619
635
 
620
636
  app.plugin :assets, :precompiled=>metadata_file
621
- app.allocate.assets([:js, :head]).must_match %r{src="(/assets/app\.head\.[a-f0-9]{40}\.js)"}
637
+ app.allocate.assets([:js, :head]).must_match %r{src="(/assets/app\.head\.[a-f0-9]{64}\.js)"}
622
638
  end
623
639
 
624
640
  it 'should work correctly with json plugin when r.assets is the last method called' do
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
 
3
3
  describe "backtracking_array plugin" do
4
4
  it "backtracks to next entry in array if later matcher fails" do
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
 
3
3
  begin
4
4
  require 'tilt/erb'
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
 
3
3
  describe 'response.cache_control' do
4
4
  it 'sets the Cache-Control header' do
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
 
3
3
  begin
4
4
  require 'tilt/erb'
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
 
3
3
  describe "class_level_routing plugin" do
4
4
  before do
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
  require 'date'
3
3
 
4
4
  describe "class_matchers plugin" do
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
 
3
3
  begin
4
4
  require 'tilt/erb'
@@ -52,18 +52,13 @@ describe "content_for plugin with multiple calls to the same key" do
52
52
  end
53
53
  end
54
54
 
55
- deprecated "should replace with multiple calls to the same key by default" do
56
- body.strip.must_equal "bar baz"
57
- end
58
-
59
55
  it "should replace with multiple calls to the same key if :append=>false plugin option is used" do
60
56
  app.plugin :content_for, :append => false
61
57
  body.strip.must_equal "bar baz"
62
58
  end
63
59
 
64
- # RODA3: Make default behavior
65
60
  it "should append with multiple calls to the same key if :append=>true plugin option is used" do
66
- app.plugin :content_for, :append => true
61
+ app.plugin :content_for
67
62
  body.strip.must_equal "bar foobaz"
68
63
  end
69
64
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
 
3
3
  describe "cookies plugin" do
4
4
  it "should set cookies on response" do
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
 
3
3
  begin
4
4
  require 'rack/csrf'
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
 
3
3
  describe "default_headers plugin" do
4
4
  it "sets the default headers to use for the response" do
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
 
3
3
  describe "default_status plugin" do
4
4
  it "sets the default response status to use for the response" do
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
 
3
3
  describe "delay_build plugin" do
4
4
  it "does not build rack app until app is called" do
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
 
3
3
  describe "delegate plugin" do
4
4
  it "adds request_delegate and response_delegate class methods for delegating" do
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
 
3
3
  describe "delete_empty_headers plugin" do
4
4
  it "automatically deletes headers that are empty" do
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
 
3
3
  if Rack.release < '1.6'
4
4
  warn "Rack #{Rack.release} used, skipping disallow_file_uploads plugin test"
@@ -6,7 +6,7 @@ else
6
6
  describe "disallow_file_uploads plugin" do
7
7
  it "disallows the uploading of files" do
8
8
  app do |r|
9
- r['foo'][:tempfile].read
9
+ r.params['foo'][:tempfile].read
10
10
  end
11
11
 
12
12
  request_body = StringIO.new("------WebKitFormBoundarymwHIM9XjTTVHn3YP\r\nContent-Disposition: form-data; name=\"foo\"; filename=\"bar.txt\"\r\nContent-Type: text/plain\r\n\r\nfoo\n\r\n------WebKitFormBoundarymwHIM9XjTTVHn3YP--\r\n")
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
 
3
3
  describe "drop_body plugin" do
4
4
  it "automatically drops body and Content-Type/Content-Length headers for responses without a body" do
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
 
3
3
  describe "empty_root plugin" do
4
4
  it "makes root match on emtpy path" do
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
 
3
3
  describe "environments plugin" do
4
4
  before do
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
 
3
3
  describe "error_email plugin" do
4
4
  def app(opts={})
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
 
3
3
  describe "error_handler plugin" do
4
4
  it "executes only if error raised" do
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
 
3
3
  begin
4
4
  require 'mail'
@@ -11,7 +11,7 @@ end
11
11
 
12
12
  describe "error_mail plugin" do
13
13
  def app(opts={})
14
- @emails = emails = [] unless defined?(@emails)
14
+ @emails = [] unless defined?(@emails)
15
15
  @app ||= super(:bare) do
16
16
  plugin :error_mail, {:to=>'t', :from=>'f'}.merge(opts)
17
17
 
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
 
3
3
  describe "flash plugin" do
4
4
  it "flash.now[] sets flash for current page" do
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
 
3
3
  describe "h plugin" do
4
4
  it "adds h method for html escaping" do
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
 
3
3
  describe "halt plugin" do
4
4
  it "should still have halt return rack response as argument given it as argument" do
@@ -109,7 +109,7 @@ describe "halt plugin" do
109
109
  proc{req}.must_raise(Roda::RodaError)
110
110
  end
111
111
 
112
- deprecated "should raise an error for single argument not integer, String, or Array" do
112
+ it "should raise an error for single argument not integer, String, or Array" do
113
113
  app(:halt) do |r|
114
114
  r.halt('a'=>'b')
115
115
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
 
3
3
  describe "hash_matcher plugin" do
4
4
  it "should enable the handling of arbitrary hash keys" do
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
 
3
3
  describe "head plugin" do
4
4
  it "considers HEAD requests as GET requests which return no body" do
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
1
+ require_relative "../spec_helper"
2
2
 
3
3
  describe "accept matcher" do
4
4
  it "should accept mimetypes and set response Content-Type" do
@@ -14,10 +14,9 @@ describe "accept matcher" do
14
14
  end
15
15
 
16
16
  describe "header matcher" do
17
- # RODA3: undeprecate, and switch http-accept to accept
18
- deprecated "should match if header present" do
17
+ it "should match if header present" do
19
18
  app(:header_matchers) do |r|
20
- r.on :header=>"http-accept" do
19
+ r.on :header=>"accept" do
21
20
  "bar"
22
21
  end
23
22
  end
@@ -38,22 +37,6 @@ describe "header matcher" do
38
37
  body("HTTP_ACCEPT" => "application/xml").must_equal "bar-application/xml"
39
38
  status.must_equal 404
40
39
  end
41
-
42
- # RODA3: Remove
43
- it "should automatically use HTTP prefix for headers if :header_matcher_prefix is set" do
44
- app(:bare) do
45
- plugin :header_matchers
46
- opts[:header_matcher_prefix] = true
47
- route do |r|
48
- r.on :header=>"accept" do |v|
49
- "bar-#{v}"
50
- end
51
- end
52
- end
53
-
54
- body("HTTP_ACCEPT" => "application/xml").must_equal "bar-application/xml"
55
- status("ACCEPT"=>"application/xml").must_equal 404
56
- end
57
40
  end
58
41
 
59
42
  describe "host matcher" do
@@ -68,8 +51,7 @@ describe "host matcher" do
68
51
  status("HTTP_HOST" => "foo.com").must_equal 404
69
52
  end
70
53
 
71
- # RODA3: switch deprecated to it
72
- deprecated "should match a host with a regexp" do
54
+ it "should match a host with a regexp" do
73
55
  app(:header_matchers) do |r|
74
56
  r.on :host=>/example/ do
75
57
  "worked"
@@ -90,17 +72,6 @@ describe "host matcher" do
90
72
  body("HTTP_HOST" => "example.com").must_equal '0'
91
73
  end
92
74
 
93
- deprecated "doesn't yield host if passed a regexp" do
94
- app(:header_matchers) do |r|
95
- r.on :host=>/\A(.*)\.example\.com\z/ do |*m|
96
- m.empty? ? '0' : m[0]
97
- end
98
- end
99
-
100
- body("HTTP_HOST" => "foo.example.com").must_equal '0'
101
- end
102
-
103
- # RODA3: Remove :host_matcher_captures setting
104
75
  it "yields host if passed a regexp and opts[:host_matcher_captures] is set" do
105
76
  app(:header_matchers) do |r|
106
77
  r.on :host=>/\A(.*)\.example\.com\z/ do |*m|
@@ -108,22 +79,8 @@ describe "host matcher" do
108
79
  end
109
80
  end
110
81
 
111
- app.opts[:host_matcher_captures] = true
112
82
  body("HTTP_HOST" => "foo.example.com").must_equal 'foo'
113
83
  end
114
-
115
- # RODA3: Remove
116
- it "doesn't yields host if passed a string and opts[:host_matcher_captures] is set" do
117
- app(:header_matchers) do |r|
118
- r.on :host=>'example.com' do |*m|
119
- m.empty? ? '0' : m[0]
120
- end
121
- end
122
-
123
- body("HTTP_HOST" => "example.com").must_equal '0'
124
- app.opts[:host_matcher_captures] = true
125
- body("HTTP_HOST" => "example.com").must_equal '0'
126
- end
127
84
  end
128
85
 
129
86
  describe "user_agent matcher" do