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
  describe "request_headers plugin" do
4
4
  def header_app(header_name)
@@ -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_request plugin" do
4
4
  it "gives the response access to the request" 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 "run_append_slash 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 "run_handler plugin" do
4
4
  it "makes r.run :not_found=>:pass keep going on 404" 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 "shared_vars plugin" do
4
4
  it "adds shared method for sharing variables across multiple apps" 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
  require 'uri'
4
4
 
@@ -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 "slash_path_empty" do
4
4
  it "considers a / path as 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
  describe "static_routing plugin" do
4
4
  it "adds support for static routes that are taken before normal routes" 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 "static plugin" do
4
4
  it "adds support for serving static files" 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 "status_303 plugin" do
4
4
  it 'uses a 302 for get requests' 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 "status_handler plugin" do
4
4
  it "executes on no arguments" 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 "streaming plugin" do
4
4
  it "adds stream method for streaming responses" do
@@ -113,109 +113,4 @@ describe "streaming plugin" do
113
113
  b.each{|v| a << v}
114
114
  a.must_equal %w'a 1 b 1 c 1 e'
115
115
  end
116
-
117
- deprecated "should handle errors when streaming, and run callbacks" do
118
- a = []
119
- app(:streaming) do |r|
120
- stream(:callback=>proc{a << 'e'}) do |out|
121
- %w'a b'.each{|v| out << v}
122
- raise Roda::RodaError, 'foo'
123
- out << 'c'
124
- end
125
- end
126
-
127
- s, h, b = req
128
- s.must_equal 200
129
- h.must_equal('Content-Type'=>'text/html')
130
- b.callback{a << 'd'}
131
- proc{b.each{|v| a << v}}.must_raise(Roda::RodaError)
132
- a.must_equal %w'a b e d'
133
- end
134
-
135
- deprecated "should handle :loop option to loop" do
136
- a = []
137
- app(:streaming) do |r|
138
- b = %w'a b c'
139
- stream(:loop=>true, :callback=>proc{a << 'e'}) do |out|
140
- out << b.shift
141
- raise Roda::RodaError, 'foo' if b.length == 1
142
- end
143
- end
144
-
145
- s, h, b = req
146
- s.must_equal 200
147
- h.must_equal('Content-Type'=>'text/html')
148
- b.callback{a << 'd'}
149
- proc{b.each{|v| a << v}}.must_raise(Roda::RodaError)
150
- a.must_equal %w'a b e d'
151
- end
152
-
153
- deprecated "uses handle_stream_error for handling errors when streaming" do
154
- a = []
155
- app(:streaming) do |r|
156
- b = %w'a b c'
157
- stream(:loop=>true, :callback=>proc{a << 'e'}) do |out|
158
- out << b.shift
159
- raise Roda::RodaError, 'foo' if b.length == 1
160
- end
161
- end
162
-
163
- app.send(:define_method, :handle_stream_error) do |error, out|
164
- out << '1'
165
- raise error
166
- end
167
-
168
- s, h, b = req
169
- s.must_equal 200
170
- h.must_equal('Content-Type'=>'text/html')
171
- b.callback{a << 'd'}
172
- proc{b.each{|v| a << v}}.must_raise(Roda::RodaError)
173
- a.must_equal %w'a b 1 e d'
174
- end
175
-
176
- deprecated "should allow closing the stream when handling an error" do
177
- a = []
178
- app(:streaming) do |r|
179
- b = %w'a b c'
180
- stream(:loop=>true, :callback=>proc{a << 'e'}) do |out|
181
- out << b.shift
182
- raise Roda::RodaError, 'foo' if b.length == 1
183
- end
184
- end
185
-
186
- app.send(:define_method, :handle_stream_error) do |error, out|
187
- out.close
188
- end
189
-
190
- s, h, b = req
191
- s.must_equal 200
192
- h.must_equal('Content-Type'=>'text/html')
193
- b.callback{a << 'd'}
194
- b.each{|v| a << v}
195
- a.must_equal %w'a b e d'
196
- end
197
-
198
- deprecated "should allow ignoring errors when streaming" do
199
- a = []
200
- b2 = %w'a b c'
201
-
202
- app(:streaming) do |r|
203
- stream(:loop=>true, :callback=>proc{a << 'e'}) do |out|
204
- out << b2.shift
205
- raise Roda::RodaError
206
- end
207
- end
208
-
209
- app.send(:define_method, :handle_stream_error) do |error, out|
210
- out << '1'
211
- out.close if b2.empty?
212
- end
213
-
214
- s, h, b = req
215
- s.must_equal 200
216
- h.must_equal('Content-Type'=>'text/html')
217
- b.callback{a << 'd'}
218
- b.each{|v| a << v}
219
- a.must_equal %w'a 1 b 1 c 1 e d'
220
- end
221
116
  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 "strip_path_prefix plugin" do
4
4
  it "strips path prefix when expanding paths" 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 "symbol_matchers plugin" do
4
4
  it "allows symbol specific regexps for symbol matchers" do
@@ -48,80 +48,4 @@ describe "symbol_matchers plugin" do
48
48
  body('/q/').must_equal 'rest'
49
49
  body('/thing2/q').must_equal 'thing2q'
50
50
  end
51
-
52
- deprecated "works with placeholder string matchers" do
53
- app(:bare) do
54
- opts[:verbatim_string_matcher] = false
55
- plugin :symbol_matchers
56
- symbol_matcher(:f, /(f+)/)
57
-
58
- route do |r|
59
- r.is ":d" do |d|
60
- "d#{d}"
61
- end
62
-
63
- r.is "foo:optd" do |o|
64
- "foo#{o.inspect}"
65
- end
66
-
67
- r.is "bar:opt" do |o|
68
- "bar#{o.inspect}"
69
- end
70
-
71
- r.is "format:format" do |f|
72
- "format#{f.inspect}"
73
- end
74
-
75
- r.is "thing/:thing" do |d|
76
- "thing#{d}"
77
- end
78
-
79
- r.is "thing2", ":thing" do |d|
80
- "thing2#{d}"
81
- end
82
-
83
- r.is ":f" do |f|
84
- "f#{f}"
85
- end
86
-
87
- r.is 'q:rest' do |rest|
88
- "rest#{rest}"
89
- end
90
-
91
- r.is ":w" do |w|
92
- "w#{w}"
93
- end
94
-
95
- r.is ':d/:w/:f' do |d, w, f|
96
- "dwf#{d}#{w}#{f}"
97
- end
98
- end
99
- end
100
-
101
- status.must_equal 404
102
- body("/1").must_equal 'd1'
103
- body("/11232135").must_equal 'd11232135'
104
- body("/a").must_equal 'wa'
105
- body("/1az0").must_equal 'w1az0'
106
- body("/f").must_equal 'ff'
107
- body("/foo").must_equal 'foonil'
108
- body("/foo/123").must_equal 'foo"123"'
109
- status("/foo/bar").must_equal 404
110
- status("/foo/123/a").must_equal 404
111
- body("/bar").must_equal 'barnil'
112
- body("/bar/foo").must_equal 'bar"foo"'
113
- status("/bar/foo/baz").must_equal 404
114
- body("/format").must_equal 'formatnil'
115
- body("/format.json").must_equal 'format"json"'
116
- status("/format.").must_equal 404
117
- body("/ffffffffffffffff").must_equal 'fffffffffffffffff'
118
- status("/-").must_equal 404
119
- body("/1/1a/f").must_equal 'dwf11af'
120
- body("/12/1azy/fffff").must_equal 'dwf121azyfffff'
121
- status("/1/f/a").must_equal 404
122
- body("/qa/b/c/d//f/g").must_equal 'resta/b/c/d//f/g'
123
- body('/q').must_equal 'rest'
124
- body('/thing/q').must_equal 'thingq'
125
- body('/thing2/q').must_equal 'thing2q'
126
- end
127
51
  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 "symbol_status plugin" do
4
4
  it "accepts a symbol" 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 "symbol_views plugin" do
4
4
  before do
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
3
+ require_relative "../spec_helper"
4
4
 
5
5
  describe "type_routing plugin" do
6
6
  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 "unescape_path_path plugin" do
4
4
  it "decodes URL-encoded routing 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
  begin
4
4
  require 'tilt/erb'
@@ -45,6 +45,21 @@ describe "view_options plugin view subdirs" do
45
45
  end
46
46
 
47
47
  describe "view_options plugin" do
48
+ it "should not use :views view option for layout" do
49
+ app(:bare) do
50
+ plugin :render, :views=>'spec/views', :allowed_paths=>['spec/views']
51
+ plugin :view_options
52
+
53
+ route do
54
+ set_view_options :views=>'spec/views/about'
55
+ set_layout_options :template=>'layout-alternative'
56
+ view('_test', :locals=>{:title=>'About Roda'}, :layout_opts=>{:locals=>{:title=>'Home'}})
57
+ end
58
+ end
59
+
60
+ body.strip.must_equal "<title>Alternative Layout: Home</title>\n<h1>Subdir: About Roda</h1>"
61
+ end
62
+
48
63
  it "should set view and layout options to use" do
49
64
  app(:bare) do
50
65
  plugin :render, :allowed_paths=>['spec/views']
@@ -80,114 +95,5 @@ describe "view_options plugin" do
80
95
 
81
96
  body.strip.must_equal "About Roda:A::Home:B"
82
97
  end
83
-
84
- deprecated "should set view and layout options and locals to use" do
85
- app(:view_options) do
86
- set_view_options :views=>'spec/views'
87
- set_view_locals :title=>'About Roda'
88
- set_layout_options :views=>'spec/views', :template=>'layout-alternative'
89
- set_layout_locals :title=>'Home'
90
- view('about')
91
- end
92
-
93
- body.strip.must_equal "<title>Alternative Layout: Home</title>\n<h1>About Roda</h1>"
94
- end
95
-
96
- deprecated "should merge multiple calls to set view and layout options and locals" do
97
- app(:view_options) do
98
- set_layout_options :views=>'spec/views', :template=>'multiple-layout', :engine=>'str'
99
- set_view_options :views=>'spec/views', :engine=>'str'
100
- set_layout_locals :title=>'About Roda'
101
- set_view_locals :title=>'Home'
102
-
103
- set_layout_options :engine=>'erb'
104
- set_view_options :engine=>'erb'
105
- set_layout_locals :a=>'A'
106
- set_view_locals :b=>'B'
107
-
108
- view('multiple')
109
- end
110
-
111
- body.strip.must_equal "About Roda:A::Home:B"
112
- end
113
-
114
- deprecated "should have set_view_locals have more precedence than plugin options, but less than view/render method options" do
115
- app(:bare) do
116
- plugin :render, :views=>"./spec/views", :locals=>{:title=>'Home', :b=>'B'}, :layout_opts=>{:template=>'multiple-layout', :locals=>{:title=>'About Roda', :a=>'A'}}
117
- plugin :view_options
118
-
119
- route do |r|
120
- r.is 'c' do
121
- view(:multiple)
122
- end
123
-
124
- set_view_locals :b=>'BB'
125
- set_layout_locals :a=>'AA'
126
-
127
- r.on 'b' do
128
- set_view_locals :title=>'About'
129
- set_layout_locals :title=>'Roda'
130
-
131
- r.is 'a' do
132
- view(:multiple)
133
- end
134
-
135
- view("multiple", :locals=>{:b => "BBB"}, :layout_opts=>{:locals=>{:a=>'AAA'}})
136
- end
137
-
138
- r.is 'a' do
139
- view(:multiple)
140
- end
141
-
142
- view("multiple", :locals=>{:b => "BBB"}, :layout_opts=>{:locals=>{:a=>'AAA'}})
143
- end
144
- end
145
-
146
- body('/c').strip.must_equal "About Roda:A::Home:B"
147
- body('/b/a').strip.must_equal "Roda:AA::About:BB"
148
- body('/b').strip.must_equal "Roda:AAA::About:BBB"
149
- body('/a').strip.must_equal "About Roda:AA::Home:BB"
150
- body.strip.must_equal "About Roda:AAA::Home:BBB"
151
- end
152
-
153
- deprecated "should have set_view_locals have more precedence than plugin options, but less than view/render method options" do
154
- app(:bare) do
155
- plugin :render, :views=>"./spec/views", :layout_opts=>{:template=>'multiple-layout'}
156
- plugin :render_locals, :render=>{:title=>'Home', :b=>'B'}, :layout=>{:title=>'About Roda', :a=>'A'}
157
- plugin :view_options
158
-
159
- route do |r|
160
- r.is 'c' do
161
- view(:multiple)
162
- end
163
-
164
- set_view_locals :b=>'BB'
165
- set_layout_locals :a=>'AA'
166
-
167
- r.on 'b' do
168
- set_view_locals :title=>'About'
169
- set_layout_locals :title=>'Roda'
170
-
171
- r.is 'a' do
172
- view(:multiple)
173
- end
174
-
175
- view("multiple", :locals=>{:b => "BBB"}, :layout_opts=>{:locals=>{:a=>'AAA'}})
176
- end
177
-
178
- r.is 'a' do
179
- view(:multiple)
180
- end
181
-
182
- view("multiple", :locals=>{:b => "BBB"}, :layout_opts=>{:locals=>{:a=>'AAA'}})
183
- end
184
- end
185
-
186
- body('/c').strip.must_equal "About Roda:A::Home:B"
187
- body('/b/a').strip.must_equal "Roda:AA::About:BB"
188
- body('/b').strip.must_equal "Roda:AAA::About:BBB"
189
- body('/a').strip.must_equal "About Roda:AA::Home:BB"
190
- body.strip.must_equal "About Roda:AAA::Home:BBB"
191
- end
192
98
  end
193
99
  end