roda 3.28.0 → 3.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +40 -0
  3. data/README.rdoc +15 -1
  4. data/doc/conventions.rdoc +17 -8
  5. data/doc/release_notes/3.29.0.txt +15 -0
  6. data/doc/release_notes/3.30.0.txt +14 -0
  7. data/doc/release_notes/3.31.0.txt +11 -0
  8. data/doc/release_notes/3.32.0.txt +42 -0
  9. data/doc/release_notes/3.33.0.txt +8 -0
  10. data/lib/roda.rb +3 -0
  11. data/lib/roda/plugins/_symbol_regexp_matchers.rb +2 -0
  12. data/lib/roda/plugins/assets.rb +26 -5
  13. data/lib/roda/plugins/caching.rb +2 -0
  14. data/lib/roda/plugins/common_logger.rb +1 -1
  15. data/lib/roda/plugins/content_security_policy.rb +2 -0
  16. data/lib/roda/plugins/default_headers.rb +2 -0
  17. data/lib/roda/plugins/exception_page.rb +9 -5
  18. data/lib/roda/plugins/hash_matcher.rb +1 -1
  19. data/lib/roda/plugins/header_matchers.rb +5 -1
  20. data/lib/roda/plugins/indifferent_params.rb +4 -0
  21. data/lib/roda/plugins/partials.rb +33 -6
  22. data/lib/roda/plugins/path.rb +42 -15
  23. data/lib/roda/plugins/placeholder_string_matchers.rb +2 -0
  24. data/lib/roda/plugins/public.rb +25 -17
  25. data/lib/roda/plugins/relative_path.rb +73 -0
  26. data/lib/roda/plugins/render.rb +17 -5
  27. data/lib/roda/plugins/render_each.rb +11 -3
  28. data/lib/roda/plugins/run_append_slash.rb +1 -1
  29. data/lib/roda/plugins/symbol_matchers.rb +2 -2
  30. data/lib/roda/version.rb +1 -1
  31. metadata +13 -214
  32. data/Rakefile +0 -108
  33. data/doc/release_notes/1.0.0.txt +0 -329
  34. data/doc/release_notes/1.1.0.txt +0 -226
  35. data/doc/release_notes/1.2.0.txt +0 -406
  36. data/doc/release_notes/1.3.0.txt +0 -109
  37. data/doc/release_notes/2.0.0.txt +0 -75
  38. data/doc/release_notes/2.1.0.txt +0 -124
  39. data/doc/release_notes/2.10.0.txt +0 -27
  40. data/doc/release_notes/2.11.0.txt +0 -70
  41. data/doc/release_notes/2.12.0.txt +0 -40
  42. data/doc/release_notes/2.13.0.txt +0 -10
  43. data/doc/release_notes/2.14.0.txt +0 -44
  44. data/doc/release_notes/2.15.0.txt +0 -53
  45. data/doc/release_notes/2.16.0.txt +0 -48
  46. data/doc/release_notes/2.17.0.txt +0 -62
  47. data/doc/release_notes/2.18.0.txt +0 -69
  48. data/doc/release_notes/2.19.0.txt +0 -30
  49. data/doc/release_notes/2.2.0.txt +0 -97
  50. data/doc/release_notes/2.20.0.txt +0 -5
  51. data/doc/release_notes/2.21.0.txt +0 -17
  52. data/doc/release_notes/2.22.0.txt +0 -41
  53. data/doc/release_notes/2.23.0.txt +0 -29
  54. data/doc/release_notes/2.24.0.txt +0 -65
  55. data/doc/release_notes/2.25.0.txt +0 -14
  56. data/doc/release_notes/2.26.0.txt +0 -13
  57. data/doc/release_notes/2.27.0.txt +0 -56
  58. data/doc/release_notes/2.28.0.txt +0 -17
  59. data/doc/release_notes/2.29.0.txt +0 -156
  60. data/doc/release_notes/2.3.0.txt +0 -109
  61. data/doc/release_notes/2.4.0.txt +0 -55
  62. data/doc/release_notes/2.5.0.txt +0 -23
  63. data/doc/release_notes/2.5.1.txt +0 -4
  64. data/doc/release_notes/2.6.0.txt +0 -21
  65. data/doc/release_notes/2.7.0.txt +0 -75
  66. data/doc/release_notes/2.8.0.txt +0 -44
  67. data/doc/release_notes/2.9.0.txt +0 -6
  68. data/spec/all.rb +0 -1
  69. data/spec/assets/css/app.scss +0 -1
  70. data/spec/assets/css/no_access.css +0 -1
  71. data/spec/assets/css/raw.css +0 -1
  72. data/spec/assets/js/head/app.js +0 -1
  73. data/spec/composition_spec.rb +0 -31
  74. data/spec/define_roda_method_spec.rb +0 -274
  75. data/spec/env_spec.rb +0 -11
  76. data/spec/freeze_spec.rb +0 -37
  77. data/spec/integration_spec.rb +0 -209
  78. data/spec/matchers_spec.rb +0 -832
  79. data/spec/opts_spec.rb +0 -42
  80. data/spec/plugin/_after_hook_spec.rb +0 -19
  81. data/spec/plugin/all_verbs_spec.rb +0 -29
  82. data/spec/plugin/assets_preloading_spec.rb +0 -98
  83. data/spec/plugin/assets_spec.rb +0 -745
  84. data/spec/plugin/backtracking_array_spec.rb +0 -42
  85. data/spec/plugin/branch_locals_spec.rb +0 -106
  86. data/spec/plugin/caching_spec.rb +0 -337
  87. data/spec/plugin/chunked_spec.rb +0 -201
  88. data/spec/plugin/class_level_routing_spec.rb +0 -164
  89. data/spec/plugin/class_matchers_spec.rb +0 -40
  90. data/spec/plugin/common_logger_spec.rb +0 -85
  91. data/spec/plugin/content_for_spec.rb +0 -162
  92. data/spec/plugin/content_security_policy_spec.rb +0 -175
  93. data/spec/plugin/cookies_spec.rb +0 -51
  94. data/spec/plugin/csrf_spec.rb +0 -111
  95. data/spec/plugin/default_headers_spec.rb +0 -82
  96. data/spec/plugin/default_status_spec.rb +0 -95
  97. data/spec/plugin/delay_build_spec.rb +0 -23
  98. data/spec/plugin/delegate_spec.rb +0 -23
  99. data/spec/plugin/delete_empty_headers_spec.rb +0 -27
  100. data/spec/plugin/direct_call_spec.rb +0 -28
  101. data/spec/plugin/disallow_file_uploads_spec.rb +0 -25
  102. data/spec/plugin/drop_body_spec.rb +0 -24
  103. data/spec/plugin/early_hints_spec.rb +0 -19
  104. data/spec/plugin/empty_root_spec.rb +0 -14
  105. data/spec/plugin/environments_spec.rb +0 -42
  106. data/spec/plugin/error_email_spec.rb +0 -97
  107. data/spec/plugin/error_handler_spec.rb +0 -216
  108. data/spec/plugin/error_mail_spec.rb +0 -93
  109. data/spec/plugin/exception_page_spec.rb +0 -168
  110. data/spec/plugin/flash_spec.rb +0 -121
  111. data/spec/plugin/h_spec.rb +0 -11
  112. data/spec/plugin/halt_spec.rb +0 -119
  113. data/spec/plugin/hash_matcher_spec.rb +0 -27
  114. data/spec/plugin/hash_routes_spec.rb +0 -535
  115. data/spec/plugin/head_spec.rb +0 -52
  116. data/spec/plugin/header_matchers_spec.rb +0 -98
  117. data/spec/plugin/heartbeat_spec.rb +0 -74
  118. data/spec/plugin/hooks_spec.rb +0 -152
  119. data/spec/plugin/indifferent_params_spec.rb +0 -14
  120. data/spec/plugin/json_parser_spec.rb +0 -141
  121. data/spec/plugin/json_spec.rb +0 -83
  122. data/spec/plugin/mail_processor_spec.rb +0 -451
  123. data/spec/plugin/mailer_spec.rb +0 -282
  124. data/spec/plugin/match_affix_spec.rb +0 -43
  125. data/spec/plugin/match_hook_spec.rb +0 -79
  126. data/spec/plugin/middleware_spec.rb +0 -237
  127. data/spec/plugin/middleware_stack_spec.rb +0 -81
  128. data/spec/plugin/module_include_spec.rb +0 -48
  129. data/spec/plugin/multi_route_spec.rb +0 -268
  130. data/spec/plugin/multi_run_spec.rb +0 -87
  131. data/spec/plugin/multi_view_spec.rb +0 -50
  132. data/spec/plugin/multibyte_string_matcher_spec.rb +0 -44
  133. data/spec/plugin/named_templates_spec.rb +0 -96
  134. data/spec/plugin/not_allowed_spec.rb +0 -69
  135. data/spec/plugin/not_found_spec.rb +0 -128
  136. data/spec/plugin/optimized_string_matchers_spec.rb +0 -43
  137. data/spec/plugin/padrino_render_spec.rb +0 -34
  138. data/spec/plugin/param_matchers_spec.rb +0 -69
  139. data/spec/plugin/params_capturing_spec.rb +0 -33
  140. data/spec/plugin/partials_spec.rb +0 -43
  141. data/spec/plugin/pass_spec.rb +0 -29
  142. data/spec/plugin/path_matchers_spec.rb +0 -42
  143. data/spec/plugin/path_rewriter_spec.rb +0 -45
  144. data/spec/plugin/path_spec.rb +0 -222
  145. data/spec/plugin/placeholder_string_matchers_spec.rb +0 -126
  146. data/spec/plugin/precompile_templates_spec.rb +0 -61
  147. data/spec/plugin/public_spec.rb +0 -85
  148. data/spec/plugin/render_each_spec.rb +0 -82
  149. data/spec/plugin/render_locals_spec.rb +0 -114
  150. data/spec/plugin/render_spec.rb +0 -912
  151. data/spec/plugin/request_aref_spec.rb +0 -51
  152. data/spec/plugin/request_headers_spec.rb +0 -39
  153. data/spec/plugin/response_request_spec.rb +0 -43
  154. data/spec/plugin/route_block_args_spec.rb +0 -86
  155. data/spec/plugin/route_csrf_spec.rb +0 -305
  156. data/spec/plugin/run_append_slash_spec.rb +0 -77
  157. data/spec/plugin/run_handler_spec.rb +0 -53
  158. data/spec/plugin/sessions_spec.rb +0 -452
  159. data/spec/plugin/shared_vars_spec.rb +0 -45
  160. data/spec/plugin/sinatra_helpers_spec.rb +0 -537
  161. data/spec/plugin/slash_path_empty_spec.rb +0 -22
  162. data/spec/plugin/static_routing_spec.rb +0 -192
  163. data/spec/plugin/static_spec.rb +0 -30
  164. data/spec/plugin/status_303_spec.rb +0 -28
  165. data/spec/plugin/status_handler_spec.rb +0 -158
  166. data/spec/plugin/streaming_spec.rb +0 -246
  167. data/spec/plugin/strip_path_prefix_spec.rb +0 -24
  168. data/spec/plugin/symbol_matchers_spec.rb +0 -51
  169. data/spec/plugin/symbol_status_spec.rb +0 -25
  170. data/spec/plugin/symbol_views_spec.rb +0 -32
  171. data/spec/plugin/timestamp_public_spec.rb +0 -85
  172. data/spec/plugin/type_routing_spec.rb +0 -348
  173. data/spec/plugin/typecast_params_spec.rb +0 -1370
  174. data/spec/plugin/unescape_path_spec.rb +0 -22
  175. data/spec/plugin/view_options_spec.rb +0 -170
  176. data/spec/plugin_spec.rb +0 -71
  177. data/spec/redirect_spec.rb +0 -41
  178. data/spec/request_spec.rb +0 -97
  179. data/spec/response_spec.rb +0 -199
  180. data/spec/route_spec.rb +0 -39
  181. data/spec/session_middleware_spec.rb +0 -129
  182. data/spec/session_spec.rb +0 -37
  183. data/spec/spec_helper.rb +0 -137
  184. data/spec/version_spec.rb +0 -14
  185. data/spec/views/_test.erb +0 -1
  186. data/spec/views/a.erb +0 -1
  187. data/spec/views/a.rdoc +0 -2
  188. data/spec/views/about.erb +0 -1
  189. data/spec/views/about.str +0 -1
  190. data/spec/views/about/_test.css.gz +0 -0
  191. data/spec/views/about/_test.erb +0 -1
  192. data/spec/views/about/_test.erb.gz +0 -0
  193. data/spec/views/about/comp_test.erb +0 -1
  194. data/spec/views/b.erb +0 -1
  195. data/spec/views/c.erb +0 -1
  196. data/spec/views/comp_layout.erb +0 -1
  197. data/spec/views/comp_test.erb +0 -1
  198. data/spec/views/content-yield.erb +0 -1
  199. data/spec/views/each.str +0 -1
  200. data/spec/views/home.erb +0 -2
  201. data/spec/views/home.str +0 -2
  202. data/spec/views/iv.erb +0 -1
  203. data/spec/views/layout-alternative.erb +0 -2
  204. data/spec/views/layout-yield.erb +0 -3
  205. data/spec/views/layout.erb +0 -2
  206. data/spec/views/layout.str +0 -2
  207. data/spec/views/multiple-layout.erb +0 -1
  208. data/spec/views/multiple.erb +0 -1
@@ -1,126 +0,0 @@
1
- require_relative "../spec_helper"
2
-
3
- describe "placeholder_string_matchers plugin" do
4
- it "should handle string with embedded param" do
5
- app(:placeholder_string_matchers) do |r|
6
- r.on "posts/:id" do |id|
7
- id
8
- end
9
-
10
- r.on "responses-:id" do |id|
11
- id
12
- end
13
- end
14
-
15
- body('/posts/123').must_equal '123'
16
- status('/post/123').must_equal 404
17
- body('/responses-123').must_equal '123'
18
- end
19
-
20
- it "should handle multiple params in single string" do
21
- app(:placeholder_string_matchers) do |r|
22
- r.on "u/:uid/posts/:id" do |uid, id|
23
- uid + id
24
- end
25
- end
26
-
27
- body("/u/jdoe/posts/123").must_equal 'jdoe123'
28
- status("/u/jdoe/pots/123").must_equal 404
29
- end
30
-
31
- it "should escape regexp metacharaters in string" do
32
- app(:placeholder_string_matchers) do |r|
33
- r.on "u/:uid/posts?/:id" do |uid, id|
34
- uid + id
35
- end
36
- end
37
-
38
- body("/u/jdoe/posts?/123").must_equal 'jdoe123'
39
- status("/u/jdoe/post/123").must_equal 404
40
- end
41
-
42
- it "should handle colons by themselves" do
43
- app(:placeholder_string_matchers) do |r|
44
- r.on "u/:/:uid/posts/::id" do |uid, id|
45
- uid + id
46
- end
47
- end
48
-
49
- body("/u/:/jdoe/posts/:123").must_equal 'jdoe123'
50
- status("/u/a/jdoe/post/b123").must_equal 404
51
- end
52
-
53
- it "should work with params_capturing plugin to add captures to r.params for string matchers" do
54
- app(:bare) do
55
- plugin :placeholder_string_matchers
56
- plugin :params_capturing
57
-
58
- route do |r|
59
- r.on("bar/:foo") do |foo|
60
- "b-#{foo}-#{r.params['foo']}-#{r.params['captures'].length}"
61
- end
62
-
63
- r.on("baz/:bar", :foo) do |bar, foo|
64
- "b-#{bar}-#{foo}-#{r.params['bar']}-#{r.params['foo']}-#{r.params['captures'].length}"
65
- end
66
- end
67
- end
68
-
69
- body('/bar/banana', 'rack.input'=>StringIO.new).must_equal 'b-banana-banana-1'
70
- body('/baz/ban/ana', 'rack.input'=>StringIO.new).must_equal 'b-ban-ana-ban-ana-2'
71
- end
72
-
73
- it "works with symbol_matchers plugin" do
74
- app(:bare) do
75
- plugin :placeholder_string_matchers
76
- plugin :symbol_matchers
77
- symbol_matcher(:f, /(f+)/)
78
-
79
- route do |r|
80
- r.is ":d" do |d|
81
- "d#{d}"
82
- end
83
-
84
- r.is "thing/:thing" do |d|
85
- "thing#{d}"
86
- end
87
-
88
- r.is "thing2", ":thing" do |d|
89
- "thing2#{d}"
90
- end
91
-
92
- r.is ":f" do |f|
93
- "f#{f}"
94
- end
95
-
96
- r.is 'q:rest' do |rest|
97
- "rest#{rest}"
98
- end
99
-
100
- r.is ":w" do |w|
101
- "w#{w}"
102
- end
103
-
104
- r.is ':d/:w/:f' do |d, w, f|
105
- "dwf#{d}#{w}#{f}"
106
- end
107
- end
108
- end
109
-
110
- status.must_equal 404
111
- body("/1").must_equal 'd1'
112
- body("/11232135").must_equal 'd11232135'
113
- body("/a").must_equal 'wa'
114
- body("/1az0").must_equal 'w1az0'
115
- body("/f").must_equal 'ff'
116
- body("/ffffffffffffffff").must_equal 'fffffffffffffffff'
117
- status("/-").must_equal 404
118
- body("/1/1a/f").must_equal 'dwf11af'
119
- body("/12/1azy/fffff").must_equal 'dwf121azyfffff'
120
- status("/1/f/a").must_equal 404
121
- body("/qa/b/c/d//f/g").must_equal 'resta/b/c/d//f/g'
122
- body('/q').must_equal 'rest'
123
- body('/thing/q').must_equal 'thingq'
124
- body('/thing2/q').must_equal 'thing2q'
125
- end
126
- end
@@ -1,61 +0,0 @@
1
- require_relative "../spec_helper"
2
-
3
- begin
4
- require 'tilt/erb'
5
- rescue LoadError
6
- warn "tilt not installed, skipping precompiled_templates plugin test"
7
- else
8
- describe "precompile_templates plugin" do
9
- it "adds support for template precompilation" do
10
- app(:bare) do
11
- plugin :render, :views=>'spec/views'
12
- plugin :precompile_templates
13
- route do |r|
14
- @a = 1
15
- render('iv')
16
- end
17
- end
18
-
19
- app.render_opts[:cache][File.expand_path('spec/views/iv.erb')].must_be_nil
20
- app.precompile_templates 'spec/views/iv.erb'
21
- app.render_opts[:cache][File.expand_path('spec/views/iv.erb')].wont_equal nil
22
- app.render_opts[:cache][File.expand_path('spec/views/iv.erb')].instance_variable_get(:@compiled_method).length.must_equal 1
23
- body.strip.must_equal '1'
24
- app.render_opts[:cache][File.expand_path('spec/views/iv.erb')].instance_variable_get(:@compiled_method).length.must_equal 1
25
- end
26
-
27
- it "adds support for template precompilation with :locals" do
28
- app(:bare) do
29
- plugin :render, :views=>'spec/views'
30
- plugin :precompile_templates
31
- route do |r|
32
- render('about', :locals=>{:title=>'1'})
33
- end
34
- end
35
-
36
- app.render_opts[:cache][File.expand_path('spec/views/about.erb')].must_be_nil
37
- app.precompile_templates 'spec/views/about.erb', :locals=>[:title]
38
- app.render_opts[:cache][File.expand_path('spec/views/about.erb')].wont_equal nil
39
- app.render_opts[:cache][File.expand_path('spec/views/about.erb')].instance_variable_get(:@compiled_method).length.must_equal 1
40
- body.strip.must_equal '<h1>1</h1>'
41
- app.render_opts[:cache][File.expand_path('spec/views/about.erb')].instance_variable_get(:@compiled_method).length.must_equal 1
42
- end
43
-
44
- it "adds support for template precompilation with :inline" do
45
- app(:bare) do
46
- plugin :render, :views=>'spec/views'
47
- plugin :precompile_templates
48
- route do |r|
49
- render(:inline=>'a', :cache_key=>'a')
50
- end
51
- end
52
-
53
- app.render_opts[:cache]['a'].must_be_nil
54
- app.precompile_templates :inline=>'a', :cache_key=>'a'
55
- app.render_opts[:cache]['a'].wont_equal nil
56
- app.render_opts[:cache]['a'].instance_variable_get(:@compiled_method).length.must_equal 1
57
- body.strip.must_equal "a"
58
- app.render_opts[:cache]['a'].instance_variable_get(:@compiled_method).length.must_equal 1
59
- end
60
- end
61
- end
@@ -1,85 +0,0 @@
1
- require_relative "../spec_helper"
2
-
3
- describe "public plugin" do
4
- it "adds r.public for serving static files from public folder" do
5
- app(:bare) do
6
- plugin :public, :root=>'spec/views'
7
-
8
- route do |r|
9
- r.public
10
-
11
- r.on 'static' do
12
- r.public
13
- end
14
- end
15
- end
16
-
17
- status("/about/_test.erb\0").must_equal 404
18
- body('/about/_test.erb').must_equal File.read('spec/views/about/_test.erb')
19
- body('/static/about/_test.erb').must_equal File.read('spec/views/about/_test.erb')
20
- body('/foo/.././/about/_test.erb').must_equal File.read('spec/views/about/_test.erb')
21
- end
22
-
23
- it "respects the application's :root option" do
24
- app(:bare) do
25
- opts[:root] = File.expand_path('../../', __FILE__)
26
- plugin :public, :root=>'views'
27
-
28
- route do |r|
29
- r.public
30
- end
31
- end
32
-
33
- body('/about/_test.erb').must_equal File.read('spec/views/about/_test.erb')
34
- end
35
-
36
- it "keeps existing :root option if loaded a second time" do
37
- app(:bare) do
38
- plugin :public, :root=>'spec/views'
39
- plugin :public
40
-
41
- route do |r|
42
- r.public
43
- end
44
- end
45
-
46
- body('/about/_test.erb').must_equal File.read('spec/views/about/_test.erb')
47
- end
48
-
49
- it "assumes public directory as default :root option" do
50
- app(:public){}
51
- app.opts[:public_root].must_equal File.expand_path('public')
52
- end
53
-
54
- it "handles serving gzip files in gzip mode if client supports gzip" do
55
- app(:bare) do
56
- plugin :public, :root=>'spec/views', :gzip=>true
57
-
58
- route do |r|
59
- r.public
60
- end
61
- end
62
-
63
- body('/about/_test.erb').must_equal File.read('spec/views/about/_test.erb')
64
- header('Content-Encoding', '/about/_test.erb').must_be_nil
65
-
66
- body('/about.erb').must_equal File.read('spec/views/about.erb')
67
- header('Content-Encoding', '/about.erb').must_be_nil
68
-
69
- body('/about/_test.erb', 'HTTP_ACCEPT_ENCODING'=>'deflate, gzip').must_equal File.binread('spec/views/about/_test.erb.gz')
70
- h = req('/about/_test.erb', 'HTTP_ACCEPT_ENCODING'=>'deflate, gzip')[1]
71
- h['Content-Encoding'].must_equal 'gzip'
72
- h['Content-Type'].must_equal 'text/plain'
73
-
74
- body('/about/_test.css', 'HTTP_ACCEPT_ENCODING'=>'deflate, gzip').must_equal File.binread('spec/views/about/_test.css.gz')
75
- h = req('/about/_test.css', 'HTTP_ACCEPT_ENCODING'=>'deflate, gzip')[1]
76
- h['Content-Encoding'].must_equal 'gzip'
77
- h['Content-Type'].must_equal 'text/css'
78
-
79
- s, h, b = req('/about/_test.css', 'HTTP_IF_MODIFIED_SINCE'=>h["Last-Modified"], 'HTTP_ACCEPT_ENCODING'=>'deflate, gzip')
80
- s.must_equal 304
81
- h['Content-Encoding'].must_be_nil
82
- h['Content-Type'].must_be_nil
83
- b.must_equal []
84
- end
85
- end
@@ -1,82 +0,0 @@
1
- require_relative "../spec_helper"
2
-
3
- begin
4
- require 'tilt'
5
- require 'tilt/string'
6
- require 'tilt/rdoc'
7
- require_relative '../../lib/roda/plugins/render'
8
- rescue LoadError
9
- warn "tilt not installed, skipping render_each plugin test"
10
- else
11
- describe "render_each plugin" do
12
- [true, false].each do |cache|
13
- it "calls render with each argument, returning joined string with all results in cache: #{cache} mode" do
14
- app(:bare) do
15
- plugin :render, :views=>'spec/views', :engine=>'str', :cache=>cache
16
- plugin :render_each
17
-
18
- o = Object.new
19
- def o.to_s; 'each' end
20
-
21
- route do |r|
22
- r.root do
23
- render_each([1,2,3], :each)
24
- end
25
-
26
- r.is 'a' do
27
- render_each([1,2,3], :each, :local=>:foo, :bar=>4)
28
- end
29
-
30
- r.is 'b' do
31
- render_each([1,2,3], :each, :local=>nil)
32
- end
33
-
34
- r.is 'c' do
35
- render_each([1,2,3], :each, :locals=>{:foo=>4})
36
- end
37
-
38
- r.is 'd' do
39
- render_each([1,2,3], {:template=>:each}, :local=>:each)
40
- end
41
-
42
- r.is 'e' do
43
- render_each([1,2,3], o)
44
- end
45
- end
46
- end
47
-
48
- 3.times do
49
- body.must_equal "r-1-\nr-2-\nr-3-\n"
50
- body("/a").must_equal "r--1\nr--2\nr--3\n"
51
- body("/b").must_equal "r--\nr--\nr--\n"
52
- body("/c").must_equal "r-1-4\nr-2-4\nr-3-4\n"
53
- body("/d").must_equal "r-1-\nr-2-\nr-3-\n"
54
- body("/e").must_equal "r-1-\nr-2-\nr-3-\n"
55
- end
56
- end
57
-
58
- if Roda::RodaPlugins::Render::COMPILED_METHOD_SUPPORT
59
- it "calls render with each argument, handling template engines that don't support compilation in cache: #{cache} mode" do
60
- app(:bare) do
61
- plugin :render, :views=>'spec/views', :engine=>'rdoc', :cache=>cache
62
- plugin :render_each
63
-
64
- route do |r|
65
- r.root do
66
- render_each([1], :a)
67
- end
68
- r.is 'a' do
69
- render_each([1], :a, :local=>:b)
70
- end
71
- end
72
- end
73
-
74
- 3.times do
75
- body.strip.must_equal "<p># a # * b</p>"
76
- body('/a').strip.must_equal "<p># a # * b</p>"
77
- end
78
- end
79
- end
80
- end
81
- end
82
- end
@@ -1,114 +0,0 @@
1
- require_relative "../spec_helper"
2
-
3
- begin
4
- require 'tilt/erb'
5
- rescue LoadError
6
- warn "tilt not installed, skipping render_locals plugin test"
7
- else
8
- describe "render_locals plugin with :merge option" do
9
- before do
10
- app(:bare) do
11
- plugin :render_locals, :render=>{:a=>1, :b=>2, :c=>3, :d=>4, :e=>5}, :layout=>{:a=>-1, :f=>6}, :merge=>true
12
- plugin :render, :views=>"./spec/views", :check_paths=>true, :layout_opts=>{:inline=>'<%= a %>|<%= b %>|<%= c %>|<%= d %>|<%= e %>|<%= f %>|<%= yield %>'}
13
-
14
- route do |r|
15
- r.on "base" do
16
- view(:inline=>'(<%= a %>|<%= b %>|<%= c %>|<%= d %>|<%= e %>)')
17
- end
18
- r.on "override" do
19
- view(:inline=>'(<%= a %>|<%= b %>|<%= c %>|<%= d %>|<%= e %>)', :locals=>{:b=>-2, :d=>-4, :f=>-6}, :layout_opts=>{:locals=>{:d=>0, :c=>-3, :e=>-5}})
20
- end
21
- r.on "no_merge" do
22
- view(:inline=>'(<%= a %>|<%= b %>|<%= c %>|<%= d %>|<%= e %>)', :locals=>{:b=>-2, :d=>-4, :f=>-6}, :layout_opts=>{:merge_locals=>false, :locals=>{:d=>0, :c=>-3, :e=>-5}})
23
- end
24
- end
25
- end
26
- end
27
-
28
- it "should choose method opts before plugin opts, and layout specific before locals" do
29
- body("/base").must_equal '-1|2|3|4|5|6|(1|2|3|4|5)'
30
- body("/override").must_equal '-1|-2|-3|0|-5|-6|(1|-2|3|-4|5)'
31
- body("/no_merge").must_equal '-1|2|-3|0|-5|6|(1|-2|3|-4|5)'
32
- end
33
- end
34
-
35
- describe "render_locals plugin" do
36
- it "locals overrides" do
37
- app(:bare) do
38
- plugin :render, :views=>"./spec/views", :layout_opts=>{:template=>'multiple-layout'}
39
- plugin :render_locals, :render=>{:title=>'Home', :b=>'B'}, :layout=>{:title=>'Roda', :a=>'A'}
40
-
41
- route do |r|
42
- view("multiple", :locals=>{:b=>"BB"}, :layout_opts=>{:locals=>{:a=>'AA'}})
43
- end
44
- end
45
-
46
- body.strip.must_equal "Roda:AA::Home:BB"
47
- end
48
-
49
- it ":layout=>true/false/string/hash/not-present respects plugin layout switch and template" do
50
- app(:bare) do
51
- plugin :render, :views=>"./spec/views", :layout_opts=>{:template=>'layout-yield'}
52
- plugin :render_locals, :layout=>{:title=>'a'}
53
-
54
- route do |r|
55
- opts = {:content=>'bar'}
56
- opts[:layout] = true if r.path == '/'
57
- opts[:layout] = false if r.path == '/f'
58
- opts[:layout] = 'layout' if r.path == '/s'
59
- opts[:layout] = {:template=>'layout'} if r.path == '/h'
60
- view(opts)
61
- end
62
- end
63
-
64
- body.gsub("\n", '').must_equal "HeaderbarFooter"
65
- body('/a').gsub("\n", '').must_equal "HeaderbarFooter"
66
- body('/f').gsub("\n", '').must_equal "bar"
67
- body('/s').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
68
- body('/h').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
69
-
70
- app.plugin :render
71
- body.gsub("\n", '').must_equal "HeaderbarFooter"
72
- body('/a').gsub("\n", '').must_equal "HeaderbarFooter"
73
- body('/f').gsub("\n", '').must_equal "bar"
74
- body('/s').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
75
- body('/h').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
76
-
77
- app.plugin :render, :layout=>true
78
- body.gsub("\n", '').must_equal "HeaderbarFooter"
79
- body('/a').gsub("\n", '').must_equal "HeaderbarFooter"
80
- body('/f').gsub("\n", '').must_equal "bar"
81
- body('/s').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
82
- body('/h').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
83
-
84
- app.plugin :render, :layout=>'layout-alternative'
85
- body.gsub("\n", '').must_equal "<title>Alternative Layout: a</title>bar"
86
- body('/a').gsub("\n", '').must_equal "<title>Alternative Layout: a</title>bar"
87
- body('/f').gsub("\n", '').must_equal "bar"
88
- body('/s').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
89
- body('/h').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
90
-
91
- app.plugin :render, :layout=>nil
92
- body.gsub("\n", '').must_equal "HeaderbarFooter"
93
- body('/a').gsub("\n", '').must_equal "bar"
94
- body('/f').gsub("\n", '').must_equal "bar"
95
- body('/s').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
96
- body('/h').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
97
-
98
- app.plugin :render, :layout=>false
99
- body.gsub("\n", '').must_equal "HeaderbarFooter"
100
- body('/a').gsub("\n", '').must_equal "bar"
101
- body('/f').gsub("\n", '').must_equal "bar"
102
- body('/s').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
103
- body('/h').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
104
-
105
- app.plugin :render, :layout_opts=>{:template=>'layout-alternative'}
106
- app.plugin :render_locals, :layout=>{:title=>'a'}
107
- body.gsub("\n", '').must_equal "<title>Alternative Layout: a</title>bar"
108
- body('/a').gsub("\n", '').must_equal "bar"
109
- body('/f').gsub("\n", '').must_equal "bar"
110
- body('/s').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
111
- body('/h').gsub("\n", '').must_equal "<title>Roda: a</title>bar"
112
- end
113
- end
114
- end