I’m trying to test my namespaced controller and not having much luck. I have the following route setup:
namespace :api do
get 'organization/:id/questions/:number', controller: 'questions', action: 'index', as: 'organization_questions'
end
which produces the following route:
api_organization_questions GET /api/organization/:id/questions/:number(.:format) {:controller=>"api/questions", :action=>"index"}
that route works, and I’m able to successfully make a request to it with the following url: http://localhost:3000/api/organization/1/questions/1234567890
However when I try to make a get request to it in my unit test I get the following error:
No route matches {:controller=>”api/questions”, :action=>”/api/organization/1/questions/1234567890″}
my get request looks like this:
get api_organization_questions_path(@organization.id, '1234567890')
Not sure what I’m doing wrong!?
What are you using for testing ? RSpec? The first parameter for the get method is the action. The code below should make the request you want: