Rspec 测试中的路由不匹配

Routes not matching in Rspec tests

我似乎无法在我的 rspec 测试中获得匹配的路线,我不太清楚为什么。

routes.rb

resources :admins, only: [:index] do
  get 'configs', on: :collection, to: 'admins#configs'
end

Rspec 回应

Failure/Error: get '/admins/config'
     
ActionController::RoutingError:
  No route matches [GET] "/admins/config"

我 运行 rails routes | grep config 这是回复所以我认为我使用了正确的路线

configs_admins GET /admins/configs(.:format) admins#configs

您定义了 '/admins/configs'(复数),但您正在尝试访问 '/admins/config'(单数)。