I'm working with the following route:
resources :groups, :only => [:show, :create, :update, :destroy] do
get 'viewmembers' => 'groups#view_members"
end
But when I'm trying to test in RSpec:
describe "GET #viewmembers" do
context "the group members are retrieved" do
before do
@group = FactoryGirl.create :group
..
get :viewmembers, group_id: @group.id
end
it { should respond_with :ok}
# others tests...
end
I get the following error:
Failure/Error: get 'viewmembers', group_id: @group.id
ActionController::UrlGenerationError:
No route matches {:action=>"viewmembers", :controller=>"api/v1/groups", :group_id=>"1"}
Is there a different way I should be formulating the GET request in my Rspec test?
Here is what's listed in rake routes
:
GET /api/v1/groups/:group_id/viewmembers(.:format) api/v1/group#viewmembers{:format=>:json}`
If i take the get 'viewmembers'...
route OUT of the nested do-end block for the group resource like so:
resources :groups, :only => [:show, :create, :update, :destroy]
get '/groups/viewmembers' => 'groups#view_members'
then the rspec test runs fine, so it has to be a problem with the way I'm formulating the request...