roda 3.28.0 → 3.29.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +10 -0
  3. data/README.rdoc +10 -0
  4. data/doc/release_notes/3.29.0.txt +15 -0
  5. data/lib/roda.rb +1 -0
  6. data/lib/roda/plugins/caching.rb +2 -0
  7. data/lib/roda/plugins/common_logger.rb +1 -1
  8. data/lib/roda/plugins/exception_page.rb +7 -1
  9. data/lib/roda/plugins/indifferent_params.rb +2 -0
  10. data/lib/roda/version.rb +1 -1
  11. metadata +4 -214
  12. data/Rakefile +0 -108
  13. data/doc/release_notes/1.0.0.txt +0 -329
  14. data/doc/release_notes/1.1.0.txt +0 -226
  15. data/doc/release_notes/1.2.0.txt +0 -406
  16. data/doc/release_notes/1.3.0.txt +0 -109
  17. data/doc/release_notes/2.0.0.txt +0 -75
  18. data/doc/release_notes/2.1.0.txt +0 -124
  19. data/doc/release_notes/2.10.0.txt +0 -27
  20. data/doc/release_notes/2.11.0.txt +0 -70
  21. data/doc/release_notes/2.12.0.txt +0 -40
  22. data/doc/release_notes/2.13.0.txt +0 -10
  23. data/doc/release_notes/2.14.0.txt +0 -44
  24. data/doc/release_notes/2.15.0.txt +0 -53
  25. data/doc/release_notes/2.16.0.txt +0 -48
  26. data/doc/release_notes/2.17.0.txt +0 -62
  27. data/doc/release_notes/2.18.0.txt +0 -69
  28. data/doc/release_notes/2.19.0.txt +0 -30
  29. data/doc/release_notes/2.2.0.txt +0 -97
  30. data/doc/release_notes/2.20.0.txt +0 -5
  31. data/doc/release_notes/2.21.0.txt +0 -17
  32. data/doc/release_notes/2.22.0.txt +0 -41
  33. data/doc/release_notes/2.23.0.txt +0 -29
  34. data/doc/release_notes/2.24.0.txt +0 -65
  35. data/doc/release_notes/2.25.0.txt +0 -14
  36. data/doc/release_notes/2.26.0.txt +0 -13
  37. data/doc/release_notes/2.27.0.txt +0 -56
  38. data/doc/release_notes/2.28.0.txt +0 -17
  39. data/doc/release_notes/2.29.0.txt +0 -156
  40. data/doc/release_notes/2.3.0.txt +0 -109
  41. data/doc/release_notes/2.4.0.txt +0 -55
  42. data/doc/release_notes/2.5.0.txt +0 -23
  43. data/doc/release_notes/2.5.1.txt +0 -4
  44. data/doc/release_notes/2.6.0.txt +0 -21
  45. data/doc/release_notes/2.7.0.txt +0 -75
  46. data/doc/release_notes/2.8.0.txt +0 -44
  47. data/doc/release_notes/2.9.0.txt +0 -6
  48. data/spec/all.rb +0 -1
  49. data/spec/assets/css/app.scss +0 -1
  50. data/spec/assets/css/no_access.css +0 -1
  51. data/spec/assets/css/raw.css +0 -1
  52. data/spec/assets/js/head/app.js +0 -1
  53. data/spec/composition_spec.rb +0 -31
  54. data/spec/define_roda_method_spec.rb +0 -274
  55. data/spec/env_spec.rb +0 -11
  56. data/spec/freeze_spec.rb +0 -37
  57. data/spec/integration_spec.rb +0 -209
  58. data/spec/matchers_spec.rb +0 -832
  59. data/spec/opts_spec.rb +0 -42
  60. data/spec/plugin/_after_hook_spec.rb +0 -19
  61. data/spec/plugin/all_verbs_spec.rb +0 -29
  62. data/spec/plugin/assets_preloading_spec.rb +0 -98
  63. data/spec/plugin/assets_spec.rb +0 -745
  64. data/spec/plugin/backtracking_array_spec.rb +0 -42
  65. data/spec/plugin/branch_locals_spec.rb +0 -106
  66. data/spec/plugin/caching_spec.rb +0 -337
  67. data/spec/plugin/chunked_spec.rb +0 -201
  68. data/spec/plugin/class_level_routing_spec.rb +0 -164
  69. data/spec/plugin/class_matchers_spec.rb +0 -40
  70. data/spec/plugin/common_logger_spec.rb +0 -85
  71. data/spec/plugin/content_for_spec.rb +0 -162
  72. data/spec/plugin/content_security_policy_spec.rb +0 -175
  73. data/spec/plugin/cookies_spec.rb +0 -51
  74. data/spec/plugin/csrf_spec.rb +0 -111
  75. data/spec/plugin/default_headers_spec.rb +0 -82
  76. data/spec/plugin/default_status_spec.rb +0 -95
  77. data/spec/plugin/delay_build_spec.rb +0 -23
  78. data/spec/plugin/delegate_spec.rb +0 -23
  79. data/spec/plugin/delete_empty_headers_spec.rb +0 -27
  80. data/spec/plugin/direct_call_spec.rb +0 -28
  81. data/spec/plugin/disallow_file_uploads_spec.rb +0 -25
  82. data/spec/plugin/drop_body_spec.rb +0 -24
  83. data/spec/plugin/early_hints_spec.rb +0 -19
  84. data/spec/plugin/empty_root_spec.rb +0 -14
  85. data/spec/plugin/environments_spec.rb +0 -42
  86. data/spec/plugin/error_email_spec.rb +0 -97
  87. data/spec/plugin/error_handler_spec.rb +0 -216
  88. data/spec/plugin/error_mail_spec.rb +0 -93
  89. data/spec/plugin/exception_page_spec.rb +0 -168
  90. data/spec/plugin/flash_spec.rb +0 -121
  91. data/spec/plugin/h_spec.rb +0 -11
  92. data/spec/plugin/halt_spec.rb +0 -119
  93. data/spec/plugin/hash_matcher_spec.rb +0 -27
  94. data/spec/plugin/hash_routes_spec.rb +0 -535
  95. data/spec/plugin/head_spec.rb +0 -52
  96. data/spec/plugin/header_matchers_spec.rb +0 -98
  97. data/spec/plugin/heartbeat_spec.rb +0 -74
  98. data/spec/plugin/hooks_spec.rb +0 -152
  99. data/spec/plugin/indifferent_params_spec.rb +0 -14
  100. data/spec/plugin/json_parser_spec.rb +0 -141
  101. data/spec/plugin/json_spec.rb +0 -83
  102. data/spec/plugin/mail_processor_spec.rb +0 -451
  103. data/spec/plugin/mailer_spec.rb +0 -282
  104. data/spec/plugin/match_affix_spec.rb +0 -43
  105. data/spec/plugin/match_hook_spec.rb +0 -79
  106. data/spec/plugin/middleware_spec.rb +0 -237
  107. data/spec/plugin/middleware_stack_spec.rb +0 -81
  108. data/spec/plugin/module_include_spec.rb +0 -48
  109. data/spec/plugin/multi_route_spec.rb +0 -268
  110. data/spec/plugin/multi_run_spec.rb +0 -87
  111. data/spec/plugin/multi_view_spec.rb +0 -50
  112. data/spec/plugin/multibyte_string_matcher_spec.rb +0 -44
  113. data/spec/plugin/named_templates_spec.rb +0 -96
  114. data/spec/plugin/not_allowed_spec.rb +0 -69
  115. data/spec/plugin/not_found_spec.rb +0 -128
  116. data/spec/plugin/optimized_string_matchers_spec.rb +0 -43
  117. data/spec/plugin/padrino_render_spec.rb +0 -34
  118. data/spec/plugin/param_matchers_spec.rb +0 -69
  119. data/spec/plugin/params_capturing_spec.rb +0 -33
  120. data/spec/plugin/partials_spec.rb +0 -43
  121. data/spec/plugin/pass_spec.rb +0 -29
  122. data/spec/plugin/path_matchers_spec.rb +0 -42
  123. data/spec/plugin/path_rewriter_spec.rb +0 -45
  124. data/spec/plugin/path_spec.rb +0 -222
  125. data/spec/plugin/placeholder_string_matchers_spec.rb +0 -126
  126. data/spec/plugin/precompile_templates_spec.rb +0 -61
  127. data/spec/plugin/public_spec.rb +0 -85
  128. data/spec/plugin/render_each_spec.rb +0 -82
  129. data/spec/plugin/render_locals_spec.rb +0 -114
  130. data/spec/plugin/render_spec.rb +0 -912
  131. data/spec/plugin/request_aref_spec.rb +0 -51
  132. data/spec/plugin/request_headers_spec.rb +0 -39
  133. data/spec/plugin/response_request_spec.rb +0 -43
  134. data/spec/plugin/route_block_args_spec.rb +0 -86
  135. data/spec/plugin/route_csrf_spec.rb +0 -305
  136. data/spec/plugin/run_append_slash_spec.rb +0 -77
  137. data/spec/plugin/run_handler_spec.rb +0 -53
  138. data/spec/plugin/sessions_spec.rb +0 -452
  139. data/spec/plugin/shared_vars_spec.rb +0 -45
  140. data/spec/plugin/sinatra_helpers_spec.rb +0 -537
  141. data/spec/plugin/slash_path_empty_spec.rb +0 -22
  142. data/spec/plugin/static_routing_spec.rb +0 -192
  143. data/spec/plugin/static_spec.rb +0 -30
  144. data/spec/plugin/status_303_spec.rb +0 -28
  145. data/spec/plugin/status_handler_spec.rb +0 -158
  146. data/spec/plugin/streaming_spec.rb +0 -246
  147. data/spec/plugin/strip_path_prefix_spec.rb +0 -24
  148. data/spec/plugin/symbol_matchers_spec.rb +0 -51
  149. data/spec/plugin/symbol_status_spec.rb +0 -25
  150. data/spec/plugin/symbol_views_spec.rb +0 -32
  151. data/spec/plugin/timestamp_public_spec.rb +0 -85
  152. data/spec/plugin/type_routing_spec.rb +0 -348
  153. data/spec/plugin/typecast_params_spec.rb +0 -1370
  154. data/spec/plugin/unescape_path_spec.rb +0 -22
  155. data/spec/plugin/view_options_spec.rb +0 -170
  156. data/spec/plugin_spec.rb +0 -71
  157. data/spec/redirect_spec.rb +0 -41
  158. data/spec/request_spec.rb +0 -97
  159. data/spec/response_spec.rb +0 -199
  160. data/spec/route_spec.rb +0 -39
  161. data/spec/session_middleware_spec.rb +0 -129
  162. data/spec/session_spec.rb +0 -37
  163. data/spec/spec_helper.rb +0 -137
  164. data/spec/version_spec.rb +0 -14
  165. data/spec/views/_test.erb +0 -1
  166. data/spec/views/a.erb +0 -1
  167. data/spec/views/a.rdoc +0 -2
  168. data/spec/views/about.erb +0 -1
  169. data/spec/views/about.str +0 -1
  170. data/spec/views/about/_test.css.gz +0 -0
  171. data/spec/views/about/_test.erb +0 -1
  172. data/spec/views/about/_test.erb.gz +0 -0
  173. data/spec/views/about/comp_test.erb +0 -1
  174. data/spec/views/b.erb +0 -1
  175. data/spec/views/c.erb +0 -1
  176. data/spec/views/comp_layout.erb +0 -1
  177. data/spec/views/comp_test.erb +0 -1
  178. data/spec/views/content-yield.erb +0 -1
  179. data/spec/views/each.str +0 -1
  180. data/spec/views/home.erb +0 -2
  181. data/spec/views/home.str +0 -2
  182. data/spec/views/iv.erb +0 -1
  183. data/spec/views/layout-alternative.erb +0 -2
  184. data/spec/views/layout-yield.erb +0 -3
  185. data/spec/views/layout.erb +0 -2
  186. data/spec/views/layout.str +0 -2
  187. data/spec/views/multiple-layout.erb +0 -1
  188. data/spec/views/multiple.erb +0 -1
@@ -1,81 +0,0 @@
1
- require_relative "../spec_helper"
2
-
3
- describe "middleware_stack plugin" do
4
- it "adds middleware_stack method for removing and inserting into middleware stack" do
5
- make_middleware = lambda do |name|
6
- Class.new do
7
- define_singleton_method(:name){name}
8
-
9
- attr_reader :app
10
- attr_reader :args
11
- attr_reader :block
12
- def initialize(app, *args, &block)
13
- @app = app
14
- @args = args
15
- @block = block
16
- end
17
-
18
- def call(env)
19
- (env[:record] ||= []) << [self.class.name, args, block]
20
- app.call(env)
21
- end
22
- end
23
- end
24
-
25
- recorded = nil
26
-
27
- app(:middleware_stack) do |r|
28
- recorded = env[:record]
29
- nil
30
- end
31
-
32
- status.must_equal 404
33
- recorded.must_be_nil
34
-
35
- called = false
36
- app.middleware_stack.before{called = true}.use(make_middleware[:m1], :a1).must_be_nil
37
- called.must_equal false
38
-
39
- status.must_equal 404
40
- recorded.must_equal [[:m1, [:a1], nil]]
41
-
42
- app.middleware_stack.before{|m, *a| m.name == :m1}.use(make_middleware[:m2]).must_be_nil
43
-
44
- status.must_equal 404
45
- recorded.must_equal [[:m2, [], nil], [:m1, [:a1], nil]]
46
-
47
- b = lambda{}
48
- app.middleware_stack.before{|m, *a| m.name == :m1}.use(make_middleware[:m3], :a2, :a3, &b).must_be_nil
49
-
50
- status.must_equal 404
51
- recorded.must_equal [[:m2, [], nil], [:m3, [:a2, :a3], b], [:m1, [:a1], nil]]
52
-
53
- app.middleware_stack.after{|m, *a| m.name == :m4}.use(make_middleware[:m4]).must_be_nil
54
- status.must_equal 404
55
- recorded.must_equal [[:m2, [], nil], [:m3, [:a2, :a3], b], [:m1, [:a1], nil], [:m4, [], nil]]
56
-
57
- app.middleware_stack.after{|m, *a| m.name == :m4}.use(make_middleware[:m5]).must_be_nil
58
- status.must_equal 404
59
- recorded.must_equal [[:m2, [], nil], [:m3, [:a2, :a3], b], [:m1, [:a1], nil], [:m4, [], nil], [:m5, [], nil]]
60
-
61
- app.middleware_stack.after{|m, *a| a == [:a1]}.use(make_middleware[:m6]).must_be_nil
62
- status.must_equal 404
63
- recorded.must_equal [[:m2, [], nil], [:m3, [:a2, :a3], b], [:m1, [:a1], nil], [:m6, [], nil], [:m4, [], nil], [:m5, [], nil]]
64
-
65
- app.middleware_stack.remove{|m, *a| a.empty?}.must_be_nil
66
- status.must_equal 404
67
- recorded.must_equal [[:m3, [:a2, :a3], b], [:m1, [:a1], nil]]
68
-
69
- sp = app.middleware_stack.after{|m, *a| m.name == :m3}
70
- sp.use(make_middleware[:m7])
71
- sp.use(make_middleware[:m8])
72
- status.must_equal 404
73
- recorded.must_equal [[:m3, [:a2, :a3], b], [:m7, [], nil], [:m8, [], nil], [:m1, [:a1], nil]]
74
-
75
- sp = app.middleware_stack.before{|m, *a| m.name == :m8}
76
- sp.use(make_middleware[:m9])
77
- sp.use(make_middleware[:m10])
78
- status.must_equal 404
79
- recorded.must_equal [[:m3, [:a2, :a3], b], [:m7, [], nil], [:m9, [], nil], [:m10, [], nil], [:m8, [], nil], [:m1, [:a1], nil]]
80
- end
81
- end
@@ -1,48 +0,0 @@
1
- require_relative "../spec_helper"
2
-
3
- describe "module_include plugin" do
4
- it "must_include given module in request or response class" do
5
- app(:bare) do
6
- plugin :module_include
7
- request_module(Module.new{def h; halt response.finish end})
8
- response_module(Module.new{def finish; [1, {}, []] end})
9
-
10
- route do |r|
11
- r.h
12
- end
13
- end
14
-
15
- req.must_equal [1, {}, []]
16
- end
17
-
18
- it "should accept blocks and turn them into modules" do
19
- app(:bare) do
20
- plugin :module_include
21
- request_module{def h; halt response.finish end}
22
- response_module{def finish; [1, {}, []] end}
23
-
24
- route do |r|
25
- r.h
26
- end
27
- end
28
-
29
- req.must_equal [1, {}, []]
30
- end
31
-
32
- it "should work if called multiple times with a block" do
33
- app(:bare) do
34
- plugin :module_include
35
- request_module{def h; halt response.f end}
36
- request_module{def i; h end}
37
- response_module{def f; finish end}
38
- response_module{def finish; [1, {}, []] end}
39
-
40
- route do |r|
41
- r.i
42
- end
43
- end
44
-
45
- req.must_equal [1, {}, []]
46
- end
47
-
48
- end
@@ -1,268 +0,0 @@
1
- require_relative "../spec_helper"
2
-
3
- describe "multi_route plugin" do
4
- before do
5
- app(:bare) do
6
- plugin :multi_route
7
-
8
- route("get") do |r|
9
- r.is "" do
10
- "get"
11
- end
12
-
13
- r.is "a" do
14
- "geta"
15
- end
16
-
17
- "getd"
18
- end
19
-
20
- route("post") do |r|
21
- r.is "" do
22
- "post"
23
- end
24
-
25
- r.is "a" do
26
- "posta"
27
- end
28
-
29
- "postd"
30
- end
31
-
32
- route(:p) do |r|
33
- r.is do
34
- 'p'
35
- end
36
- end
37
-
38
- route do |r|
39
- r.on 'foo' do
40
- r.multi_route do
41
- "foo"
42
- end
43
-
44
- r.on "p" do
45
- r.route(:p)
46
- end
47
- end
48
-
49
- r.get do
50
- r.route("get")
51
-
52
- r.is "b" do
53
- "getb"
54
- end
55
- end
56
-
57
- r.post do
58
- r.route("post")
59
-
60
- r.is "b" do
61
- "postb"
62
- end
63
- end
64
- end
65
- end
66
- end
67
-
68
- it "adds named routing support" do
69
- body.must_equal 'get'
70
- body('REQUEST_METHOD'=>'POST').must_equal 'post'
71
- body('/a').must_equal 'geta'
72
- body('/a', 'REQUEST_METHOD'=>'POST').must_equal 'posta'
73
- body('/b').must_equal 'getb'
74
- body('/b', 'REQUEST_METHOD'=>'POST').must_equal 'postb'
75
- status('/c').must_equal 404
76
- status('/c', 'REQUEST_METHOD'=>'POST').must_equal 404
77
- end
78
-
79
- it "works when freezing the app" do
80
- app.freeze
81
- body.must_equal 'get'
82
- body('REQUEST_METHOD'=>'POST').must_equal 'post'
83
- body('/a').must_equal 'geta'
84
- body('/a', 'REQUEST_METHOD'=>'POST').must_equal 'posta'
85
- body('/b').must_equal 'getb'
86
- body('/b', 'REQUEST_METHOD'=>'POST').must_equal 'postb'
87
- status('/c').must_equal 404
88
- status('/c', 'REQUEST_METHOD'=>'POST').must_equal 404
89
-
90
- proc{app.route("foo"){}}.must_raise
91
- end
92
-
93
- it "uses multi_route to dispatch to any named route" do
94
- status('/foo').must_equal 404
95
- body('/foo/get/').must_equal 'get'
96
- body('/foo/get/a').must_equal 'geta'
97
- body('/foo/post/').must_equal 'post'
98
- body('/foo/post/a').must_equal 'posta'
99
- body('/foo/post/b').must_equal 'foo'
100
- end
101
-
102
- it "does not have multi_route match non-String named routes" do
103
- body('/foo/p').must_equal 'p'
104
- status('/foo/p/2').must_equal 404
105
- end
106
-
107
- it "has multi_route pick up routes newly added" do
108
- body('/foo/get/').must_equal 'get'
109
- status('/foo/delete').must_equal 404
110
- app.route('delete'){|r| r.on{'delete'}}
111
- body('/foo/delete').must_equal 'delete'
112
- end
113
-
114
- it "makes multi_route match longest route if multiple routes have the same prefix" do
115
- app.route("post/a"){|r| r.on{"pa2"}}
116
- app.route("get/a"){|r| r.on{"ga2"}}
117
- status('/foo').must_equal 404
118
- body('/foo/get/').must_equal 'get'
119
- body('/foo/get/a').must_equal 'ga2'
120
- body('/foo/post/').must_equal 'post'
121
- body('/foo/post/a').must_equal 'pa2'
122
- body('/foo/post/b').must_equal 'foo'
123
- end
124
-
125
- it "handles loading the plugin multiple times correctly" do
126
- app.plugin :multi_route
127
- body.must_equal 'get'
128
- body('REQUEST_METHOD'=>'POST').must_equal 'post'
129
- body('/a').must_equal 'geta'
130
- body('/a', 'REQUEST_METHOD'=>'POST').must_equal 'posta'
131
- body('/b').must_equal 'getb'
132
- body('/b', 'REQUEST_METHOD'=>'POST').must_equal 'postb'
133
- status('/c').must_equal 404
134
- status('/c', 'REQUEST_METHOD'=>'POST').must_equal 404
135
- end
136
-
137
- it "handles subclassing correctly" do
138
- @app = Class.new(@app)
139
- @app.route do |r|
140
- r.get do
141
- r.route("post")
142
-
143
- r.is "b" do
144
- "1b"
145
- end
146
- end
147
- r.post do
148
- r.route("get")
149
-
150
- r.is "b" do
151
- "2b"
152
- end
153
- end
154
- end
155
-
156
- body.must_equal 'post'
157
- body('REQUEST_METHOD'=>'POST').must_equal 'get'
158
- body('/a').must_equal 'posta'
159
- body('/a', 'REQUEST_METHOD'=>'POST').must_equal 'geta'
160
- body('/b').must_equal '1b'
161
- body('/b', 'REQUEST_METHOD'=>'POST').must_equal '2b'
162
- status('/c').must_equal 404
163
- status('/c', 'REQUEST_METHOD'=>'POST').must_equal 404
164
- end
165
-
166
- it "uses the named route return value in multi_route if no block is given" do
167
- app.route{|r| r.multi_route}
168
- body('/get').must_equal 'getd'
169
- body('/post').must_equal 'postd'
170
- end
171
- end
172
-
173
- describe "multi_route plugin" do
174
- it "r.multi_route handles loading the same route more than once" do
175
- app(:multi_route) do |r|
176
- r.multi_route
177
- end
178
- app.route('foo'){'bar'}
179
- body('/foo').must_equal 'bar'
180
- app.route('foo'){'baz'}
181
- body('/foo').must_equal 'baz'
182
- end
183
- end
184
-
185
- describe "multi_route plugin" do
186
- it "r.multi_route raises error for invalid namespace" do
187
- app(:multi_route) do |r|
188
- r.is('a'){r.multi_route('foo')}
189
- r.multi_route
190
- 'a'
191
- end
192
- proc{body}.must_raise Roda::RodaError
193
- proc{body('/a')}.must_raise Roda::RodaError
194
- end
195
- end
196
-
197
- describe "multi_route plugin" do
198
- before do
199
- app(:bare) do
200
- plugin :multi_route
201
-
202
- route("foo", "foo") do |r|
203
- "#{@p}ff"
204
- end
205
-
206
- route("bar", "foo") do |r|
207
- "#{@p}fb"
208
- end
209
-
210
- route("foo", "bar") do |r|
211
- "#{@p}bf"
212
- end
213
-
214
- route("bar", "bar") do |r|
215
- "#{@p}bb"
216
- end
217
- end
218
- end
219
-
220
- it "handles namespaces in r.route" do
221
- app.route("foo") do |r|
222
- @p = 'f'
223
- r.on("foo"){r.route("foo", "foo")}
224
- r.on("bar"){r.route("bar", "foo")}
225
- @p
226
- end
227
-
228
- app.route("bar") do |r|
229
- @p = 'b'
230
- r.on("foo"){r.route("foo", "bar")}
231
- r.on("bar"){r.route("bar", "bar")}
232
- @p
233
- end
234
-
235
- app.route do |r|
236
- r.on("foo"){r.route("foo")}
237
- r.on("bar"){r.route("bar")}
238
- end
239
-
240
- body('/foo').must_equal 'f'
241
- body('/foo/foo').must_equal 'fff'
242
- body('/foo/bar').must_equal 'ffb'
243
- body('/bar').must_equal 'b'
244
- body('/bar/foo').must_equal 'bbf'
245
- body('/bar/bar').must_equal 'bbb'
246
- end
247
-
248
- it "handles namespaces in r.multi_route" do
249
- app(:multi_route) do |path|
250
- request.multi_route
251
- path
252
- end
253
- app.plugin :route_block_args do
254
- [request.path, request]
255
- end
256
- app.route("foo") do |path, r|
257
- r.multi_route("foo")
258
- "f-#{path}"
259
- end
260
- app.route("bar", "foo") do |path|
261
- "b-#{path}"
262
- end
263
-
264
- body.must_equal '/'
265
- body('/foo').must_equal 'f-/foo'
266
- body('/foo/bar').must_equal 'b-/foo/bar'
267
- end
268
- end
@@ -1,87 +0,0 @@
1
- require_relative "../spec_helper"
2
-
3
- describe "multi_run plugin" do
4
- it "adds Roda.run method for setting up prefix delegations to other rack apps" do
5
- app(:multi_run) do |r|
6
- r.multi_run
7
- "c"
8
- end
9
-
10
- app.run "a", Class.new(Roda).class_eval{route{"a1"}; app}
11
-
12
- body("/a").must_equal 'a1'
13
- body("/b").must_equal 'c'
14
- body("/b/a").must_equal 'c'
15
- body.must_equal 'c'
16
-
17
- app.run "b", Class.new(Roda).class_eval{route{"b1"}; app}
18
-
19
- body("/a").must_equal 'a1'
20
- body("/b").must_equal 'b1'
21
- body("/b/a").must_equal 'b1'
22
- body.must_equal 'c'
23
-
24
- app.run "b/a", Class.new(Roda).class_eval{route{"b2"}; app}
25
-
26
- body("/a").must_equal 'a1'
27
- body("/b").must_equal 'b1'
28
- body("/b/a").must_equal 'b2'
29
- body.must_equal 'c'
30
- end
31
-
32
- it "works when freezing the app" do
33
- app(:multi_run) do |r|
34
- r.multi_run
35
- "c"
36
- end
37
-
38
- app.run "a", Class.new(Roda).class_eval{route{"a1"}; app}
39
- app.run "b", Class.new(Roda).class_eval{route{"b1"}; app}
40
- app.run "b/a", Class.new(Roda).class_eval{route{"b2"}; app}
41
- app.freeze
42
-
43
- body("/a").must_equal 'a1'
44
- body("/b").must_equal 'b1'
45
- body("/b/a").must_equal 'b2'
46
- body.must_equal 'c'
47
-
48
- proc{app.run "a", Class.new(Roda).class_eval{route{"a1"}; app}}.must_raise
49
- end
50
-
51
- it "works when subclassing" do
52
- app(:multi_run) do |r|
53
- r.multi_run
54
- "c"
55
- end
56
-
57
- app.run "a", Class.new(Roda).class_eval{route{"a1"}; app}
58
- body("/a").must_equal 'a1'
59
-
60
- a = app
61
- @app = Class.new(a)
62
-
63
- a.run "b", Class.new(Roda).class_eval{route{"b2"}; app}
64
- app.run "b", Class.new(Roda).class_eval{route{"b1"}; app}
65
-
66
- body("/a").must_equal 'a1'
67
- body("/b").must_equal 'b1'
68
-
69
- @app = a
70
- body("/b").must_equal 'b2'
71
- end
72
-
73
- it "yields prefix" do
74
- yielded = false
75
-
76
- app(:multi_run) do |r|
77
- r.multi_run do |prefix|
78
- yielded = prefix
79
- end
80
- end
81
-
82
- app.run "a", Class.new(Roda).class_eval{route{"a1"}; app}
83
-
84
- body("/a").must_equal "a1"
85
- yielded.must_equal "a"
86
- end
87
- end