module Spec::Rails::Example::RoutingHelpers
def ensure_that_routes_are_loaded
def ensure_that_routes_are_loaded ActionController::Routing::Routes.reload if ActionController::Routing::Routes.empty? end
def params_from(method, path)
params_from(:get, '/registrations/1/edit')
== Example
an incoming path so the parameters it generates can be checked
Uses ActionController::Routing::Routes to parse
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
def route_for(options)
route_for(:controller => 'registrations', :action => 'create')
=> '/registrations/1/edit'
route_for(:controller => 'registrations', :action => 'edit', :id => '1')
== Examples
the correct route for a given set of options.
Uses ActionController::Routing::Routes to generate
def route_for(options) RouteFor.new(self, options) end