Module: ActionDispatch::Assertions::RoutingAssertions::ClassMethods
- Defined in:
 - lib/action_dispatch/testing/assertions/routing.rb
 
Instance Method Summary collapse
- 
  
    
      #with_routing(&block)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
A helper to make it easier to test different route configurations.
 
Instance Method Details
#with_routing(&block) ⇒ Object
A helper to make it easier to test different route configurations. This method temporarily replaces @routes with a new RouteSet instance before each test.
The new instance is yielded to the passed block. Typically the block will create some routes using set.draw { match ... }:
with_routing do |set|
  set.draw do
    resources :users
  end
end
  
      28 29 30 31 32 33 34 35 36 37 38 39  | 
    
      # File 'lib/action_dispatch/testing/assertions/routing.rb', line 28 def with_routing(&block) old_routes, old_controller = nil setup do old_routes, old_controller = @routes, @controller create_routes(&block) end teardown do reset_routes(old_routes, old_controller) end end  |