Routes not matching in Rspec tests

Viewed 30

I can't seem to get a matching route in my rspec tests and I am not quite sure why.

routes.rb

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

Rspec response

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

I run rails routes | grep config and this is the response so I think I am using the correct route

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

You defined '/admins/configs' (plural) but you're trying to access '/admins/config' (singular).

Related