方法
实例公共方法
with_routing(&block) 链接
一个帮助程序,可以更轻松地测试不同的路由配置。此方法在每次测试之前使用新的 RouteSet 实例临时替换 @routes。
将新实例传递给传递的块。通常,该块将使用 set.draw { match ... }
创建一些路由
with_routing do |set|
set.draw do
resources :users
end
end
来源: 显示 | 在 GitHub 上
# File actionpack/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