Module Spec::Rails::Example::RoutingHelpers

  1. lib/spec/rails/example/routing_helpers.rb

Methods

public instance

  1. params_from
  2. route_for

Included modules

  1. ParamsFromQueryString

Public instance methods

params_from (method, path)

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
[show source]
# 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)

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'
[show source]
# File lib/spec/rails/example/routing_helpers.rb, line 41
        def route_for(options)
          RouteFor.new(self, options)
        end