Module: Spec::Rails::Example::RoutingHelpers
- Included in:
- ActionController::TestCase
- Defined in:
- lib/vendor/plugins/rspec-rails/lib/spec/rails/example/routing_helpers.rb
Defined Under Namespace
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.
-
#route_for(options) ⇒ Object
Uses ActionController::Routing::Routes to generate the correct route for a given set of options.
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
Note that this method is obsoleted by the route_to matcher.
Example
params_from(:get, '/registrations/1/edit')
=> :controller => 'registrations', :action => 'edit', :id => '1'
50 51 52 53 54 55 |
# File 'lib/vendor/plugins/rspec-rails/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(Rack::Utils.parse_query(querystring).symbolize_keys!) 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}
39 40 41 |
# File 'lib/vendor/plugins/rspec-rails/lib/spec/rails/example/routing_helpers.rb', line 39 def route_for() RouteFor.new(self, ) end |