我正在寻找为资源丰富的路线创建 DRY shoulda 风格的匹配器:
it { should resource(:users) }
it { should resource(:articles), only: 'index' }
有没有办法确定是否通过资源路由创建了一系列路由?
我考虑过的替代方法是在隔离引擎中生成预期路线以进行比较:
class RouteTestEngine < Rails::Engine; end
RouteTestEngine.routes.draw do
resources :users
end
# A *very* rough draft of the assertion that would follow:
expect(Rails.application.routes.named_routes).to include RouteTestEngine.routes.named_routes