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'
52 53 54 55 56 57 |
# File 'lib/spec/rails/example/routing_helpers.rb', line 52 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.
Examples
route_for(:controller => 'registrations', :action => 'edit', :id => '1')
=> '/registrations/1/edit'
route_for(:controller => 'registrations', :action => 'create')
=> {:path => "/registrations", :method => :post}
43 44 45 |
# File 'lib/spec/rails/example/routing_helpers.rb', line 43 def route_for() RouteFor.new(self, ) end |