public
Rubygem
Description: Merb Core: All you need. None you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-core.git
Search Repo:
Merge branch 'master' of git@github.com:wycats/merb-core
wycats (author)
Tue Mar 04 13:30:04 -0800 2008
commit  4faa93bc6561fa9366dcb97e89775a08d29c086d
tree    4827bfa468245954d5ac2d9c8b1c5480c3fc5600
parent  7a1c3e23354621f680554ee0bd3e873dff4b22c7 parent  bf38f7948cdcb9a05a1177604d80b87558777987
...
28
29
30
31
32
33
34
35
36
...
36
37
38
39
40
 
41
42
43
44
 
45
46
47
48
49
50
51
52
53
54
55
 
 
56
57
58
...
69
70
71
 
72
73
74
...
28
29
30
 
31
32
33
34
35
...
35
36
37
 
 
38
39
40
41
 
42
43
44
45
46
47
 
 
 
 
 
 
48
49
50
51
52
...
63
64
65
66
67
68
69
0
@@ -28,7 +28,6 @@
0
       start = Time.now
0
       request = Merb::Request.new(rack_env)
0
       Merb.logger.info("Params: #{request.params.inspect}")
0
- Merb.logger.info("Cookies: #{request.cookies.inspect}")
0
       
0
       route_index, route_params = Merb::Router.match(request)
0
       
0
0
0
@@ -36,23 +35,18 @@
0
         raise ::Merb::ControllerExceptions::NotFound, "No routes match the request, #{request.uri}"
0
       end
0
       request.route_params = route_params
0
- request.reset_params!
0
- route = Merb::Router.routes[route_index]
0
+ request.params.merge! route_params
0
       
0
       controller_name = (route_params[:namespace] ? route_params[:namespace] + '/' : '') + route_params[:controller]
0
       
0
- if controller_name.nil?
0
+ unless controller_name
0
         raise Merb::ControllerExceptions::NotFound, "Route matched, but route did not specify a controller"
0
       end
0
       
0
       Merb.logger.debug("Routed to: #{request.route_params.inspect}")
0
 
0
- begin
0
- cnt = controller_name.snake_case.to_const_string
0
- rescue ::String::InvalidPathConversion
0
- raise Merb::ControllerExceptions::NotFound,
0
- "Controller '#{controller_name}' could not be converted to a class"
0
- end
0
+ cnt = controller_name.snake_case.to_const_string
0
+
0
       if !Merb::Controller._subclasses.include?(cnt)
0
         raise Merb::ControllerExceptions::NotFound, "Controller '#{cnt}' not found"
0
       end
0
@@ -69,6 +63,7 @@
0
       action = route_params[:action]
0
 
0
       controller = dispatch_action(klass, action, request)
0
+ controller._benchmarks[:dispatch_time] = Time.now - start
0
       Merb.logger.info controller._benchmarks.inspect
0
       Merb.logger.flush
0
 
...
1
2
3
4
5
6
 
 
7
 
 
 
8
9
10
11
 
 
 
 
 
 
12
13
14
15
16
 
 
 
 
 
17
18
19
20
 
 
 
 
 
21
22
23
24
25
26
27
 
 
 
 
 
 
 
 
28
29
30
31
32
33
34
 
 
 
 
 
 
 
 
35
36
37
38
39
40
 
 
 
 
 
 
 
 
41
42
43
44
45
46
 
 
 
 
 
 
 
47
48
49
50
51
52
 
 
 
 
 
 
 
 
 
53
54
55
...
60
61
62
63
64
65
 
 
 
66
67
68
...
1
2
3
 
 
 
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
 
 
 
43
44
45
46
47
48
49
50
51
52
53
 
 
 
 
54
55
56
57
58
59
60
61
62
63
64
 
 
 
65
66
67
68
69
70
71
72
73
74
75
76
 
 
77
78
79
80
81
82
83
84
85
86
87
88
 
89
90
91
92
93
94
95
96
97
98
99
100
...
105
106
107
 
 
 
108
109
110
111
112
113
0
@@ -1,55 +1,100 @@
0
 module Merb
0
   module Test
0
     module ViewHelper
0
-
0
- # small utility class for working with
0
- # the Hpricot parser class
0
+
0
+ # Small utility class for working with the Hpricot parser class
0
       class DocumentOutput
0
+
0
+ # ==== Parameters
0
+ # response_body<String>:: The response body to parse with Hpricot.
0
         def initialize(response_body)
0
           @parser = Hpricot.parse(response_body)
0
         end
0
 
0
+ # ==== Parameters
0
+ # css_query<String>::
0
+ # A CSS query to find the element for, e.g. "ul.links".
0
+ #
0
+ # ==== Returns
0
+ # String:: The content of the first tag matching the query.
0
         def content_for(css_query)
0
           match = @parser.search(css_query).first
0
           match.inner_text unless match.nil?
0
         end
0
 
0
+ # ==== Parameters
0
+ # css_query<String>:: A CSS query to find the elements for.
0
+ #
0
+ # ==== Returns
0
+ # Array[String]:: Content of all tags matching the query.
0
         def content_for_all(css_query)
0
           matches = @parser.search(css_query).collect{|ele| ele.inner_text}
0
         end
0
 
0
+ # ==== Parameters
0
+ # css_query<String>:: A CSS query to find the elements for.
0
+ #
0
+ # ==== Returns
0
+ # Hpricot::Elements:: All tags matching the query.
0
         def [](css_query)
0
           @parser.search(css_query)
0
         end
0
       end
0
-
0
- # returns the inner content of
0
- # the first tag found by the css query
0
+
0
+ # ==== Parameters
0
+ # css_query<String>:: A CSS query to find the element for.
0
+ # output<DocumentOutput>::
0
+ # The output to look for the element in. Defaults to process_output.
0
+ #
0
+ # ==== Returns
0
+ # String:: The content of the first tag matching the query.
0
       def tag(css_query, output = process_output)
0
         output.content_for(css_query)
0
       end
0
-
0
- # returns an array of tag contents
0
- # for all of the tags found by the
0
- # css query
0
+
0
+ # ==== Parameters
0
+ # css_query<String>:: A CSS query to find the elements for.
0
+ # output<DocumentOutput>::
0
+ # The output to look for the element in. Defaults to process_output.
0
+ #
0
+ # ==== Returns
0
+ # Array[String]:: Content of all tags matching the query.
0
       def tags(css_query, output = process_output)
0
         output.content_for_all(css_query)
0
       end
0
-
0
- # returns a raw Hpricot::Elem object
0
- # for the first result found by the query
0
+
0
+ # ==== Parameters
0
+ # css_query<String>:: A CSS query to find the element for.
0
+ # output<DocumentOutput>::
0
+ # The output to look for the element in. Defaults to process_output.
0
+ #
0
+ # ==== Returns
0
+ # Hpricot::Elem:: The first tag matching the query.
0
       def element(css_query, output = process_output)
0
         output[css_query].first
0
       end
0
   
0
- # returns an array of Hpricot::Elem objects
0
- # for the results found by the query
0
+ # ==== Parameters
0
+ # css_query<String>:: A CSS query to find the elements for.
0
+ # output<DocumentOutput>::
0
+ # The output to look for the elements in. Defaults to process_output.
0
+ #
0
+ # ==== Returns
0
+ # Array[Hpricot::Elem]:: All tags matching the query.
0
       def elements(css_query, output = process_output)
0
         Hpricot::Elements[*css_query.to_s.split(",").map{|s| s.strip}.map do |query|
0
           output[query]
0
         end.flatten]
0
       end
0
-
0
+
0
+ # ==== Parameters
0
+ # css_query<String>:: A CSS query to find the elements for.
0
+ # text<String, Regexp>:: A pattern to match tag contents for.
0
+ # output<DocumentOutput>::
0
+ # The output to look for the elements in. Defaults to process_output.
0
+ #
0
+ # ==== Returns
0
+ # Array[Hpricot::Elem]:: All tags matching the query and pattern.
0
       def get_elements(css_query, text, output = nil)
0
         els = elements(*[css_query, output].compact)
0
         case text
0
@@ -60,9 +105,9 @@
0
       end
0
   
0
       protected
0
- # creates a new DocumentOutput object from the response
0
- # body if hasn't already been created. This is
0
- # called automatically by the element and tag methods
0
+
0
+ # ==== Returns
0
+ # DocumentOutput:: Document output from the response body.
0
         def process_output
0
           return @output unless @output.nil?
0
           return @output = DocumentOutput.new(@response_output) unless @response_output.nil?
...
1
2
 
3
 
 
 
 
 
 
 
4
5
6
7
 
 
 
8
9
10
 
 
 
11
12
13
14
 
 
 
15
16
17
18
19
 
20
 
 
 
21
22
23
24
 
 
 
 
 
 
 
25
26
27
28
29
30
 
 
 
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
...
36
37
38
39
 
 
 
40
41
42
43
 
 
 
44
45
46
47
 
 
 
48
49
50
51
52
 
53
54
 
 
 
 
 
 
 
55
56
57
58
59
 
 
 
60
61
62
63
 
 
 
64
65
66
67
 
 
 
68
69
70
71
 
 
 
72
73
74
75
76
 
77
 
 
 
 
 
 
 
78
79
80
81
82
 
 
 
83
84
85
86
 
 
 
87
88
89
90
 
 
 
91
92
93
94
 
 
 
95
96
97
98
99
100
 
 
 
101
102
 
103
104
105
106
107
108
109
 
110
111
112
113
114
115
116
117
118
119
...
121
122
123
124
 
125
126
 
127
128
129
130
131
132
 
 
 
133
134
135
136
137
138
139
 
140
141
142
143
 
 
 
144
145
 
146
147
148
149
150
151
152
 
153
154
155
156
157
158
...
164
165
166
167
 
168
169
170
171
 
 
 
172
173
 
174
175
176
177
178
179
180
 
181
182
183
...
203
204
205
206
 
207
208
...
1
 
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 
27
28
29
30
31
32
33
 
34
35
36
37
38
39
40
41
 
42
43
44
45
46
47
48
49
50
51
52
53
 
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
...
62
63
64
 
65
66
67
68
69
70
 
71
72
73
74
75
76
 
77
78
79
80
81
82
83
 
84
85
 
86
87
88
89
90
91
92
93
94
95
96
 
97
98
99
100
101
102
 
103
104
105
106
107
108
 
109
110
111
112
113
114
 
115
116
117
118
119
120
121
 
122
123
124
125
126
127
128
129
130
131
132
133
134
 
135
136
137
138
139
140
 
141
142
143
144
145
146
 
147
148
149
150
151
152
 
153
154
155
156
157
158
159
 
 
160
161
162
163
 
164
165
166
167
168
169
170
 
171
172
173
174
175
176
177
178
179
180
181
...
183
184
185
 
186
187
 
188
189
190
191
 
 
 
192
193
194
195
196
 
197
198
199
 
200
201
 
 
 
202
203
204
205
 
206
207
208
209
210
211
212
 
213
214
215
216
217
218
219
...
225
226
227
 
228
229
 
 
 
230
231
232
233
 
234
235
236
237
238
239
240
 
241
242
243
244
...
264
265
266
 
267
268
269
0
@@ -1,33 +1,59 @@
0
 module Merb::Test::Rspec::ControllerMatchers
0
-
0
+
0
   class BeRedirect
0
+
0
+ # ==== Parameters
0
+ # target<Fixnum, ~status>::
0
+ # Either the status code or a controller with a status code.
0
+ #
0
+ # ==== Returns
0
+ # Boolean:: True if the status code is in the range 300..305 or 307.
0
     def matches?(target)
0
       @target = target
0
       [307, *(300..305)].include?(target.respond_to?(:status) ? target.status : target)
0
     end
0
+
0
+ # ==== Returns
0
+ # String:: The failure message.
0
     def failure_message
0
       "expected#{inspect_target} to redirect"
0
     end
0
+
0
+ # ==== Returns
0
+ # String:: The failure message to be displayed in negative matches.
0
     def negative_failure_message
0
       "expected#{inspect_target} not to redirect"
0
     end
0
-
0
+
0
+ # ==== Returns
0
+ # String:: The controller and action name.
0
     def inspect_target
0
       " #{@target.controller_name}##{@target.action_name}" if @target.respond_to?(:controller_name) && @target.respond_to?(:action_name)
0
     end
0
   end
0
-
0
+
0
   class RedirectTo
0
+
0
+ # === Parameters
0
+ # String:: The expected location
0
     def initialize(expected)
0
       @expected = expected
0
     end
0
-
0
+
0
+ # ==== Parameters
0
+ # target<Merb::Controller>:: The controller to match
0
+ #
0
+ # ==== Returns
0
+ # Boolean::
0
+ # True if the controller status is redirect and the locations match.
0
     def matches?(target)
0
       @target, @location = target, target.headers['Location']
0
       @redirected = BeRedirect.new.matches?(target.status)
0
       @location == @expected && @redirected
0
     end
0
-
0
+
0
+ # ==== Returns
0
+ # String:: The failure message.
0
     def failure_message
0
       msg = "expected #{inspect_target} to redirect to <#{@expected}>, but "
0
       if @redirected
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
@@ -36,77 +62,113 @@
0
         msg << "there was no redirection"
0
       end
0
     end
0
-
0
+
0
+ # ==== Returns
0
+ # String:: The failure message to be displayed in negative matches.
0
     def negative_failure_message
0
       "expected #{inspect_target} not to redirect to <#{@expected}>, but did anyway"
0
     end
0
-
0
+
0
+ # ==== Returns
0
+ # String:: The controller and action name.
0
     def inspect_target
0
       "#{@target.controller_name}##{@target.action_name}"
0
     end
0
-
0
+
0
+ # ==== Returns
0
+ # String:: Either the target's location header or the target itself.
0
     def target_location
0
       @target.respond_to?(:headers) ? @target.headers['Location'] : @target
0
     end
0
   end
0
-
0
+
0
   class BeSuccess
0
-
0
+
0
+ # ==== Parameters
0
+ # target<Fixnum, ~status>::
0
+ # Either the status code or a controller with a status code.
0
+ #
0
+ # ==== Returns
0
+ # Boolean:: True if the status code is in the range 200..207.
0
     def matches?(target)
0
       @target = target
0
       (200..207).include?(status_code)
0
     end
0
-
0
+
0
+ # ==== Returns
0
+ # String:: The failure message.
0
     def failure_message
0
       "expected#{inspect_target} to be successful but was #{status_code}"
0
     end
0
-
0
+
0
+ # ==== Returns
0
+ # String:: The failure message to be displayed in negative matches.
0
     def negative_failure_message
0
       "expected#{inspect_target} not to be successful but it was #{status_code}"
0
     end
0
-
0
+
0
+ # ==== Returns
0
+ # String:: The controller and action name.
0
     def inspect_target
0
       " #{@target.controller_name}##{@target.action_name}" if @target.respond_to?(:controller_name) && @target.respond_to?(:action_name)
0
     end
0
-
0
+
0
+ # ==== Returns
0
+ # Fixnum:: Either the target's status or the target itself.
0
     def status_code
0
       @target.respond_to?(:status) ? @target.status : @target
0
     end
0
   end
0
-
0
+
0
   class BeMissing
0
+
0
+ # ==== Parameters
0
+ # target<Fixnum, ~status>::
0
+ # Either the status code or a controller with a status code.
0
+ #
0
+ # ==== Returns
0
+ # Boolean:: True if the status code is in the range 400..417.
0
     def matches?(target)
0
       @target = target
0
       (400..417).include?(status_code)
0
     end
0
-
0
+
0
+ # ==== Returns
0
+ # String:: The failure message.
0
     def failure_message
0
       "expected#{inspect_target} to be missing but was #{status_code}"
0
     end
0
-
0
+
0
+ # ==== Returns
0
+ # String:: The failure message to be displayed in negative matches.
0
     def negative_failure_message
0
       "expected#{inspect_target} not to be missing but it was #{status_code}"
0
     end
0
-
0
+
0
+ # ==== Returns
0
+ # String:: The controller and action name.
0
     def inspect_target
0
       " #{@target.controller_name}##{@target.action_name}" if @target.respond_to?(:controller_name) && @target.respond_to?(:action_name)
0
     end
0
-
0
+
0
+ # ==== Returns
0
+ # Fixnum:: Either the target's status or the target itself.
0
     def status_code
0
       @target.respond_to?(:status) ? @target.status : @target
0
     end
0
   end
0
-
0
- # Passes if the target was redirected, or the target is a redirection (300 level) response code.
0
+
0
+ # Passes if the target was redirected, or the target is a redirection (300
0
+ # level) response code.
0
   #
0
- # ==== Example
0
+ # ==== Examples
0
   # # Passes if the controller was redirected
0
   # controller.should redirect
0
   #
0
   # # Also works if the target is the response code
0
   # controller.status.should redirect
0
   #
0
- # ==== Note
0
+ # ==== Notes
0
   # valid HTTP Redirection codes:
0
   # * 300: Multiple Choices
0
   # * 301: Moved Permanently
0
0
0
0
0
0
0
0
@@ -121,35 +183,34 @@
0
   def redirect
0
     BeRedirect.new
0
   end
0
-
0
+
0
   alias_method :be_redirection, :redirect
0
-
0
+
0
   # Passes if the target was redirected to the expected location.
0
   #
0
   # ==== Paramters
0
- # expected<String>::
0
- # A relative or absolute url.
0
- # ==== Example
0
+ # expected<String>:: A relative or absolute url.
0
+ #
0
+ # ==== Examples
0
   # # Passes if the controller was redirected to http://example.com/
0
   # controller.should redirect_to('http://example.com/')
0
- #
0
   def redirect_to(expected)
0
     RedirectTo.new(expected)
0
   end
0
-
0
+
0
   alias_method :be_redirection_to, :redirect_to
0
-
0
- # Passes if the request that generated the target was successful,
0
- # or the target is a success (200 level) response code.
0
+
0
+ # Passes if the request that generated the target was successful, or the
0
+ # target is a success (200 level) response code.
0
   #
0
- # ==== Example
0
+ # ==== Examples
0
   # # Passes if the controller call was successful
0
   # controller.should respond_successfully
0
   #
0
   # # Also works if the target is the response code
0
   # controller.status.should respond_successfully
0
   #
0
- # ==== Note
0
+ # ==== Notes
0
   # valid HTTP Success codes:
0
   # * 200: OK
0
   # * 201: Created
0
0
0
0
@@ -164,20 +225,20 @@
0
   def respond_successfully
0
     BeSuccess.new
0
   end
0
-
0
+
0
   alias_method :be_successful, :respond_successfully
0
-
0
- # Passes if the request that generated the target was missing,
0
- # or the target is a client-side error (400 level) response code.
0
+
0
+ # Passes if the request that generated the target was missing, or the target
0
+ # is a client-side error (400 level) response code.
0
   #
0
- # ==== Example
0
+ # ==== Examples
0
   # # Passes if the controller call was unknown or not understood
0
   # controller.should be_missing
0
   #
0
   # # Also passes if the target is a response code
0
   # controller.status.should be_missing
0
   #
0
- # ==== Note
0
+ # ==== Notes
0
   # valid HTTP Client Error codes:
0
   # * 400: Bad Request
0
   # * 401: Unauthorized
0
@@ -203,7 +264,7 @@
0
   def be_missing
0
     BeMissing.new
0
   end
0
-
0
+
0
   alias_method :be_client_error, :be_missing
0
 end
...
1
2
 
3
 
 
 
 
 
4
5
6
7
8
 
 
 
 
 
 
9
10
11
12
13
14
15
16
...
14
15
16
17
 
 
 
 
 
 
 
 
18
19
20
21
 
 
 
 
 
 
 
 
 
 
 
 
22
23
24
25
26
27
 
 
 
28
29
30
31
 
 
32
33
34
35
 
 
 
 
 
 
36
37
38
39
40
41
 
 
 
 
 
 
 
42
43
44
45
46
47
48
49
50
51
...
46
47
48
49
 
 
 
 
 
 
50
51
52
53
54
55
 
 
 
56
57
58
59
 
 
 
60
61
62
63
64
65
66
 
 
 
67
68
 
69
70
71
 
 
 
72
73
 
 
74
75
76
77
78
79
80
81
...
1
 
2
3
4
5
6
7
8
9
10
11
12
 
13
14
15
16
17
18
19
20
21
22
23
24
25
26
...
24
25
26
 
27
28
29
30
31
32
33
34
35
36
37
 
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
 
55
56
57
58
59
60
61
62
63
64
65
66
 
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
...
90
91
92
 
93
94
95
96
97
98
99
100
101
102
103
 
104
105
106
107
108
109
 
110
111
112
113
114
115
116
 
 
 
117
118
119
120
 
121
122
 
 
123
124
125
126
 
127
128
129
130
131
132
 
133
134
135
0
@@ -1,11 +1,21 @@
0
 module Merb::Test::Rspec::RouteMatchers
0
-
0
+
0
   class RouteToMatcher
0
+
0
+ # ==== Parameters
0
+ # klass_or_name<Class, String>::
0
+ # The controller class or class name to match routes for.
0
+ # action<~to_s>:: The name of the action to match routes for.
0
     def initialize(klass_or_name, action)
0
       @expected_controller = Class === klass_or_name ? klass_or_name.name : klass_or_name
0
       @expected_action = action.to_s
0
     end
0
-
0
+
0
+ # ==== Parameters
0
+ # target<Hash>:: The route parameters to match.
0
+ #
0
+ # ==== Returns
0
+ # Boolean:: True if the controller action and parameters match.
0
     def matches?(target)
0
       @target_env = target.dup
0
       @target_controller, @target_action = @target_env.delete(:controller).to_s, @target_env.delete(:action).to_s
0
0
0
0
0
0
@@ -14,31 +24,65 @@
0
       
0
       @expected_controller.snake_case == @target_controller.snake_case && @expected_action == @target_action && match_parameters(@target_env)
0
     end
0
-
0
+
0
+ # ==== Parameters
0
+ # target<Hash>:: The route parameters to match.
0
+ #
0
+ # ==== Returns
0
+ # Boolean::
0
+ # True if the parameter matcher created with #with matches or if no
0
+ # parameter matcher exists.
0
     def match_parameters(target)
0
       @parameter_matcher.nil? ? true : @parameter_matcher.matches?(target)
0
     end
0
-
0
+
0
+ # Creates a new paramter matcher.
0
+ #
0
+ # ==== Parameters
0
+ # parameters<Hash, ~to_param>:: The parameters to match.
0
+ #
0
+ # ==== Returns
0
+ # RouteToMatcher:: This matcher.
0
+ #
0
+ # ==== Alternatives
0
+ # If parameters is an object, then a new expected hash will be constructed
0
+ # with the key :id set to parameters.to_param.
0
     def with(parameters)
0
       @paramter_matcher = ParameterMatcher.new(parameters)
0
       
0
       self
0
     end
0
-
0
+
0
+ # ==== Returns
0
+ # String:: The failure message.
0
     def failure_message
0
       "expected the request to route to #{camelize(@expected_controller)}##{@expected_action}, but was #{camelize(@target_controller)}##{@target_action}"
0
     end
0
   
0
+ # ==== Returns
0
+ # String:: The failure message to be displayed in negative matches.
0
     def negative_failure_message
0
       "expected the request not to route to #{camelize(@expected_controller)}##{@expected_action}, but it did"
0
     end
0
-
0
+
0
+ # ==== Parameters
0
+ # word<~to_s>:: The word to camelize.
0
+ #
0
+ # ==== Returns
0
+ # String:: The word camelized.
0
     def camelize(word)
0
       word.to_s.gsub(/^[a-z]|(\_[a-z])/) { |a| a.upcase.gsub("_", "") }
0
     end
0
   end
0
 
0
   class ParameterMatcher
0
+
0
+ # ==== Parameters
0
+ # hash_or_object<Hash, ~to_param>:: The parameters to match.
0
+ #
0
+ # ==== Alternatives
0
+ # If hash_or_object is an object, then a new expected hash will be
0
+ # constructed with the key :id set to hash_or_object.to_param.
0
     def initialize(hash_or_object)
0
       @expected = {}
0
       case hash_or_object
0
0
0
0
0
0
0
0
@@ -46,36 +90,46 @@
0
       else @expected[:id] = hash_or_object.to_param
0
       end
0
     end
0
-
0
+
0
+ # ==== Parameters
0
+ # parameter_hash<Hash>:: The route parameters to match.
0
+ #
0
+ # ==== Returns
0
+ # Boolean:: True if the route parameters match the expected ones.
0
     def matches?(parameter_hash)
0
       @actual = parameter_hash.dup.except(:controller, :action)
0
     
0
       @expected.all? {|(k, v)| @actual.has_key?(k) && @actual[k] == v}
0
     end
0
-
0
+
0
+ # ==== Returns
0
+ # String:: The failure message.
0
     def failure_message
0
       "expected the route to contain parameters #{@expected.inspect}, but instead contained #{@actual.inspect}"
0
     end
0
-
0
+
0
+ # ==== Returns
0
+ # String:: The failure message to be displayed in negative matches.
0
     def negative_failure_message
0
       "expected the route not to contain parameters #{@expected.inspect}, but it did"
0
     end
0
   end
0
-
0
- # Passes when the actual route parameters match the expected controller class and
0
- # controller action. Exposes a +with+ method for specifying parameters.
0
+
0
+ # Passes when the actual route parameters match the expected controller class
0
+ # and controller action. Exposes a +with+ method for specifying parameters.
0
   #
0
- # ==== Paramters
0
+ # ==== Parameters
0
   # klass_or_name<Class, String>::
0
- # The type or type name of the expected controller.
0
- # action<Symbol, String>:: Method name of the action. Works with strings or symbols.
0
+ # The controller class or class name to match routes for.
0
+ # action<~to_s>:: The name of the action to match routes for.
0
+ #
0
   # ==== Example
0
- # # Passes if a GET request to "/" is routed to the Widgets controller's index action.
0
+ # # Passes if a GET request to "/" is routed to the Widgets controller's
0
+ # # index action.
0
   # request_to("/", :get).should route_to(Widgets, :index)
0
   #
0
   # # Use the 'with' method for parameter checks
0
   # request_to("/123").should route_to(widgets, :show).with(:id => "123")
0
- #
0
   def route_to(klass_or_name, action)
0
     RouteToMatcher.new(klass_or_name, action)