Module: Spec::Rails::Example::RoutingHelpers
- Includes:
- ParamsFromQueryString
- Included in:
- ActionController::TestCase
- Defined in:
- lib/spec/rails/example/routing_helpers.rb
Defined Under Namespace
Modules: ParamsFromQueryString Classes: RouteFor
Instance Method Summary collapse
-
#params_from(method, path) ⇒ Object
Uses ActionController::Routing::Routes to parse an incoming path so the parameters it generates can be checked == Example params_from(:get, ‘/registrations/1/edit’) => :controller => ‘registrations’, :action => ‘edit’, :id => 1.
-
#route_for(options) ⇒ Object
Uses ActionController::Routing::Routes to generate the correct route for a given set of options.
Methods included from ParamsFromQueryString
Instance Method Details
#params_from(method, path) ⇒ Object
Uses ActionController::Routing::Routes to parse an incoming path so the parameters it generates can be checked
Example
params_from(:get, '/registrations/1/edit')
=> :controller => 'registrations', :action => 'edit', :id => 1
50 51 52 53 54 55 |
# File 'lib/spec/rails/example/routing_helpers.rb', line 50 def params_from(method, path) ensure_that_routes_are_loaded path, querystring = path.split('?') params = ActionController::Routing::Routes.recognize_path(path, :method => method) querystring.blank? ? params : params.merge(params_from_querystring(querystring)) end |
#route_for(options) ⇒ Object
Uses ActionController::Routing::Routes to generate the correct route for a given set of options.
Example
route_for(:controller => 'registrations', :action => 'edit', :id => 1)
=> '/registrations/1;edit'
41 42 43 |
# File 'lib/spec/rails/example/routing_helpers.rb', line 41 def route_for() RouteFor.new(self, ) end |