方法
執行個體公開方法
with_routing(&區塊) 連結
一個用來更輕鬆測試不同路由組態的輔助程式。此方法會在每個測試前將 @routes 臨時替換為一個新的 RouteSet 實例。
新的實例會讓渡給傳遞的區塊。通常區塊會使用 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 89 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