I have a fairly simple controller 'ActivityLogsController' in an 'Admin' namespace. When running rails server
everything works as expected and I can access routes like /admin/activity_logs. When I run RSpec controller specs, every action test returns a failure. For example:
Failure/Error: get :index
ActionController::UrlGenerationError:
No route matches {:action=>"index", :controller=>"activity_logs"}
OK, I admit this looks a little strange, not showing the :controller value being namespaced. That is obviously part of the issue.
The routes.rb has the activity_logs entry correctly namespaced:
namespace :admin do
resources :activity_logs, except: [:show, :destroy]
end
Of course, running rake routes
gives me the expected namespaced routes, which reflects the fact that the server runs correctly.
The controller is defined in 'app/controllers/admin/activity_logs_controller.rb', reflecting its namespace. It is defined as:
class Admin::ActivityLogsController < ApplicationController
...
end
So, why does the RSpec controller spec fail to resolve the routes correctly?
I'm posting this one with an answer, in case others have failed to find what they need in other questions.