roda 2.29.0 → 3.0.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 (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
@@ -7,7 +7,7 @@ class Roda
7
7
  # turning them to relative paths. Roda by default stores internal paths as absolute paths.
8
8
  # The main reason to use this plugin is when the internal absolute path could change at
9
9
  # runtime, either due to a symlink change or chroot call, or you really want to use
10
- # relative links instead of absolute links.
10
+ # relative paths instead of absolute paths.
11
11
  #
12
12
  # Examples:
13
13
  #
@@ -46,32 +46,14 @@ class Roda
46
46
  app.symbol_matcher(:d, /(\d+)/)
47
47
  app.symbol_matcher(:w, /(\w+)/)
48
48
  app.symbol_matcher(:rest, /(.*)/)
49
-
50
- if !app.opts[:verbatim_string_matcher]
51
- # RODA3: Remove
52
- app::RodaRequest.class_eval do
53
- def match_symbol_format
54
- Roda::RodaPlugins.warn('Implicit use of the :format symbol matcher is deprecated and will be removed in Roda 3. If you want to use the :format symbol matcher, add the following code to your Roda class: symbol_matcher(:format, /(?:\.(\w+))?/)')
55
- /(?:\.(\w+))?/
56
- end
57
-
58
- def match_symbol_opt
59
- Roda::RodaPlugins.warn('Implicit use of the :opt symbol matcher is deprecated and will be removed in Roda 3. If you want to use the :opt symbol matcher, add the following code to your Roda class: symbol_matcher(:opt, /(?:\/([^\/]+))?/)')
60
- /(?:\/([^\/]+))?/
61
- end
62
-
63
- def match_symbol_optd
64
- Roda::RodaPlugins.warn('Implicit use of the :optd symbol matcher is deprecated and will be removed in Roda 3. If you want to use the :optd symbol matcher, add the following code to your Roda class: symbol_matcher(:optd, /(?:\/(\d+))?/)')
65
- /(?:\/(\d+))?/
66
- end
67
- end
68
- end
69
49
  end
70
50
 
71
51
  module ClassMethods
72
52
  # Set the regexp to use for the given symbol, instead of the default.
73
53
  def symbol_matcher(s, re)
74
- self::RodaRequest.send(:define_method, :"match_symbol_#{s}"){re}
54
+ meth = :"match_symbol_#{s}"
55
+ self::RodaRequest.send(:define_method, meth){re}
56
+ self::RodaRequest.send(:private, meth)
75
57
  end
76
58
  end
77
59
 
@@ -83,7 +65,8 @@ class Roda
83
65
  # behavior.
84
66
  def _match_symbol(s)
85
67
  meth = :"match_symbol_#{s}"
86
- if respond_to?(meth)
68
+ if respond_to?(meth, true)
69
+ # Allow calling private match methods
87
70
  re = send(meth)
88
71
  consume(self.class.cached_matcher(re){re})
89
72
  else
@@ -95,7 +78,8 @@ class Roda
95
78
  # Otherwise, call super for the default behavior.
96
79
  def _match_symbol_regexp(s)
97
80
  meth = :"match_symbol_#{s}"
98
- if respond_to?(meth)
81
+ if respond_to?(meth, true)
82
+ # Allow calling private match methods
99
83
  send(meth)
100
84
  else
101
85
  super
@@ -3,7 +3,7 @@
3
3
  #
4
4
  class Roda
5
5
  module RodaPlugins
6
- # Allows to respond to specific request data types. User agents can request
6
+ # This plugin makes it easier to to respond to specific request data types. User agents can request
7
7
  # specific data types by either supplying an appropriate +Accept+ header
8
8
  # or by appending it as file extension to the path.
9
9
  #
@@ -48,9 +48,9 @@ class Roda
48
48
  #
49
49
  # To match custom extensions, use the :types option:
50
50
  #
51
- # plugin :type_routing, :types => {
52
- # :yaml => 'application/x-yaml',
53
- # :js => 'application/javascript; charset=utf-8',
51
+ # plugin :type_routing, types: {
52
+ # yaml: 'application/x-yaml',
53
+ # js: 'application/javascript; charset=utf-8'
54
54
  # }
55
55
  #
56
56
  # route do |r|
@@ -81,11 +81,6 @@ class Roda
81
81
  # :use_header :: Whether to take the +Accept+ header into account.
82
82
  # Default is +true+.
83
83
  module TypeRouting
84
- ACCEPT_HEADER = 'HTTP_ACCEPT'.freeze
85
- RodaPlugins.deprecate_constant(self, :ACCEPT_HEADER)
86
- CONTENT_TYPE_HEADER = 'Content-Type'.freeze
87
- RodaPlugins.deprecate_constant(self, :CONTENT_TYPE_HEADER)
88
-
89
84
  CONFIGURATION = {
90
85
  :mimes => {
91
86
  'text/json' => :json,
@@ -11,8 +11,8 @@ class Roda
11
11
  #
12
12
  # route do |r|
13
13
  # r.on "users" do
14
- # set_layout_options :template=>'users_layout'
15
- # set_view_options :engine=>'haml'
14
+ # set_layout_options template: 'users_layout'
15
+ # set_view_options engine: 'haml'
16
16
  #
17
17
  # # ...
18
18
  # end
@@ -31,7 +31,7 @@ class Roda
31
31
  # use, and template names that do not contain a slash will
32
32
  # automatically use that view subdirectory. Example:
33
33
  #
34
- # plugin :render, :layout=>'./layout'
34
+ # plugin :render, layout: './layout'
35
35
  # plugin :view_options
36
36
  #
37
37
  # route do |r|
@@ -59,22 +59,22 @@ class Roda
59
59
  #
60
60
  # If you have an existing Roda application that doesn't use
61
61
  # automatic HTML escaping for <tt><%= %></tt> tags via the
62
- # :render plugin's :escape=>:erubi option, but you want to switch to
63
- # using the :escape option, you can now do so without making
62
+ # render plugin's +:escape+ option, but you want to switch to
63
+ # using the +:escape+ option, you can now do so without making
64
64
  # all changes at once. With set_view_options, you can now
65
65
  # specify escaping or not on a per branch basis in the routing
66
66
  # tree:
67
67
  #
68
- # plugin :render, :escape=>:erubi
68
+ # plugin :render, escape: true
69
69
  # plugin :view_options
70
70
  #
71
71
  # route do |r|
72
72
  # # Don't escape <%= %> by default
73
- # set_view_options :template_opts=>{:escape=>false}
73
+ # set_view_options template_opts: {escape: false}
74
74
  #
75
75
  # r.on "users" do
76
76
  # # Escape <%= %> in this branch
77
- # set_view_options :template_opts=>{:escape=>true}
77
+ # set_view_options template_opts: {escape: true}
78
78
  # end
79
79
  # end
80
80
  module ViewOptions
@@ -122,63 +122,16 @@ class Roda
122
122
  end
123
123
  end
124
124
 
125
- # RODA3: Remove
126
- def set_layout_locals(opts)
127
- RodaPlugins.warn "The set_layout_locals method in the view_options plugin is deprecated and will be removed in Roda 3. This feature has been moved to the branch_locals plugin."
128
- if locals = @_layout_locals
129
- @_layout_locals = Hash[locals].merge!(opts)
130
- else
131
- @_layout_locals = opts
132
- end
133
- end
134
-
135
- # RODA3: Remove
136
- def set_view_locals(opts)
137
- RodaPlugins.warn "The set_view_locals method in the view_options plugin is deprecated and will be removed in Roda 3. This feature has been moved to the branch_locals plugin."
138
- if locals = @_view_locals
139
- @_view_locals = Hash[locals].merge!(opts)
140
- else
141
- @_view_locals = opts
142
- end
143
- end
144
-
145
125
  private
146
126
 
147
- def render_locals
148
- locals = super
149
- if @_view_locals
150
- locals = Hash[locals].merge!(@_view_locals)
151
- end
152
- locals
153
- end
154
-
155
- def layout_locals
156
- locals = super
157
- if @_view_locals
158
- locals = Hash[locals].merge!(@_layout_locals)
159
- end
160
- locals
161
- end
162
-
163
127
  # If view options or locals have been set and this
164
128
  # template isn't a layout template, merge the options
165
129
  # and locals into the returned hash.
166
130
  def parse_template_opts(template, opts)
167
131
  t_opts = super
168
132
 
169
- unless t_opts[:_is_layout]
170
- if v_opts = @_view_options
171
- t_opts.merge!(v_opts)
172
- end
173
-
174
- # RODA3: Remove
175
- if v_locals = @_view_locals
176
- t_opts[:locals] = if t_locals = t_opts[:locals]
177
- Hash[v_locals].merge!(t_locals)
178
- else
179
- v_locals
180
- end
181
- end
133
+ if !t_opts[:_is_layout] && (v_opts = @_view_options)
134
+ t_opts.merge!(v_opts)
182
135
  end
183
136
 
184
137
  t_opts
@@ -193,15 +146,6 @@ class Roda
193
146
  opts.merge!(l_opts)
194
147
  end
195
148
 
196
- # RODA3: Remove
197
- if l_locals = @_layout_locals
198
- opts[:locals] = if o_locals = opts[:locals]
199
- Hash[o_locals].merge!(l_locals)
200
- else
201
- l_locals
202
- end
203
- end
204
-
205
149
  opts
206
150
  end
207
151
 
data/lib/roda/version.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  class Roda
2
2
  # The major version of Roda, updated only for major changes that are
3
3
  # likely to require modification to Roda apps.
4
- RodaMajorVersion = 2
4
+ RodaMajorVersion = 3
5
5
 
6
6
  # The minor version of Roda, updated for new feature releases of Roda.
7
- RodaMinorVersion = 29
7
+ RodaMinorVersion = 0
8
8
 
9
9
  # The patch version of Roda, updated only for bug fixes from the last
10
10
  # feature release.
data/spec/all.rb CHANGED
@@ -1,3 +1 @@
1
- $:.unshift(File.expand_path("../lib", File.dirname(__FILE__)))
2
- require 'rubygems'
3
1
  (Dir['./spec/*_spec.rb'] + Dir['./spec/plugin/*_spec.rb']).each{|f| require f}
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(__FILE__))
1
+ require_relative "spec_helper"
2
2
 
3
3
  describe "r.run" do
4
4
  it "should allow composition of apps" do
data/spec/env_spec.rb CHANGED
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(__FILE__))
1
+ require_relative "spec_helper"
2
2
 
3
3
  describe "Roda#env" do
4
4
  it "should return the environment" do
data/spec/freeze_spec.rb CHANGED
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(__FILE__))
1
+ require_relative "spec_helper"
2
2
 
3
3
  describe "Roda.freeze" do
4
4
  before do
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(__FILE__))
1
+ require_relative "spec_helper"
2
2
 
3
3
  describe "integration" do
4
4
  before do
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(__FILE__))
1
+ require_relative "spec_helper"
2
2
 
3
3
  describe "capturing" do
4
4
  it "doesn't yield the verb for verb matcher" do
@@ -87,7 +87,7 @@ describe "capturing" do
87
87
  body("/user/a").must_equal 'b'
88
88
  end
89
89
 
90
- it "yields the segment for symbol matcher" do
90
+ it "yields the segment for String class matcher" do
91
91
  app do |r|
92
92
  r.get "user", String do |id|
93
93
  id
@@ -96,6 +96,16 @@ describe "capturing" do
96
96
 
97
97
  body("/user/johndoe").must_equal 'johndoe'
98
98
  end
99
+
100
+ it "raises error for unsupported class matcher" do
101
+ app do |r|
102
+ r.get Hash do |id|
103
+ id
104
+ end
105
+ end
106
+
107
+ proc{status}.must_raise Roda::RodaError
108
+ end
99
109
  end
100
110
 
101
111
  describe "r.is" do
@@ -145,36 +155,31 @@ describe "r.is" do
145
155
  status("/123/").must_equal 404
146
156
  end
147
157
 
148
- it "matches segments" do
158
+ it "matches regexps" do
149
159
  app do |r|
150
- r.is :id do |id|
151
- id
160
+ r.on(/foo/) do |id|
161
+ 'a'
152
162
  end
153
163
  end
154
164
 
155
- body("/123").must_equal '123'
156
- status("/123/").must_equal 404
165
+ body("/foo").must_equal 'a'
166
+ body("/foo/").must_equal 'a'
167
+ status("/food").must_equal 404
157
168
  end
158
- end
159
169
 
160
- describe "matchers" do
161
- deprecated "should handle string with embedded param" do
170
+ it "matches segments" do
162
171
  app do |r|
163
- r.on "posts/:id" do |id|
164
- id
165
- end
166
-
167
- r.on "responses-:id" do |id|
172
+ r.is :id do |id|
168
173
  id
169
174
  end
170
175
  end
171
- app.opts[:verbatim_string_matcher] = false
172
176
 
173
- body('/posts/123').must_equal '123'
174
- status('/post/123').must_equal 404
175
- body('/responses-123').must_equal '123'
177
+ body("/123").must_equal '123'
178
+ status("/123/").must_equal 404
176
179
  end
180
+ end
177
181
 
182
+ describe "matchers" do
178
183
  it "should not handle string with embedded param if :verbatim_string_matcher option is set" do
179
184
  app do |r|
180
185
  r.on "posts/:id" do
@@ -185,8 +190,6 @@ describe "matchers" do
185
190
  '2'
186
191
  end
187
192
  end
188
- # RODA3: remove option
189
- app.opts[:verbatim_string_matcher] = true
190
193
 
191
194
  status('/post/123').must_equal 404
192
195
  status('/posts/123').must_equal 404
@@ -195,42 +198,6 @@ describe "matchers" do
195
198
  body('/responses-:id').must_equal '2'
196
199
  end
197
200
 
198
- deprecated "should handle multiple params in single string" do
199
- app do |r|
200
- r.on "u/:uid/posts/:id" do |uid, id|
201
- uid + id
202
- end
203
- end
204
- app.opts[:verbatim_string_matcher] = false
205
-
206
- body("/u/jdoe/posts/123").must_equal 'jdoe123'
207
- status("/u/jdoe/pots/123").must_equal 404
208
- end
209
-
210
- deprecated "should escape regexp metacharaters in string" do
211
- app do |r|
212
- r.on "u/:uid/posts?/:id" do |uid, id|
213
- uid + id
214
- end
215
- end
216
- app.opts[:verbatim_string_matcher] = false
217
-
218
- body("/u/jdoe/posts?/123").must_equal 'jdoe123'
219
- status("/u/jdoe/post/123").must_equal 404
220
- end
221
-
222
- deprecated "should handle colons by themselves" do
223
- app do |r|
224
- r.on "u/:/:uid/posts/::id" do |uid, id|
225
- uid + id
226
- end
227
- end
228
- app.opts[:verbatim_string_matcher] = false
229
-
230
- body("/u/:/jdoe/posts/:123").must_equal 'jdoe123'
231
- status("/u/a/jdoe/post/b123").must_equal 404
232
- end
233
-
234
201
  it "should handle regexes and nesting" do
235
202
  app do |r|
236
203
  r.on(/u\/(\w+)/) do |uid|
@@ -332,7 +299,7 @@ describe "matchers" do
332
299
 
333
300
  it "should allow regexp to match optional segments with separate arguments" do
334
301
  app do |r|
335
- r.on /(\d+)(?:\/(\d+))?/ do |f, b|
302
+ r.on(/(\d+)(?:\/(\d+))?/) do |f, b|
336
303
  [f, b].inspect
337
304
  end
338
305
  end
@@ -395,19 +362,8 @@ describe "r.on" do
395
362
  status.must_equal 404
396
363
  end
397
364
 
398
- deprecated "executes on arbitrary object" do
399
- app do |r|
400
- r.on Object.new do
401
- "+1"
402
- end
403
- end
404
-
405
- body.must_equal '+1'
406
- end
407
-
408
- it "raises on arbitrary object if :unsupported_matcher => :raise" do
365
+ it "raises on arbitrary object" do
409
366
  app(:bare) do
410
- opts[:unsupported_matcher] = :raise
411
367
  route do |r|
412
368
  r.on Object.new do
413
369
  "+1"
data/spec/opts_spec.rb CHANGED
@@ -1,4 +1,4 @@
1
- require File.expand_path("spec_helper", File.dirname(__FILE__))
1
+ require_relative "spec_helper"
2
2
 
3
3
  describe "opts" do
4
4
  it "is inheritable and allows overriding" 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 "all_verbs plugin" do
4
4
  it "adds method for each http verb" do