To get a list of questionnaires, I use
GET "/questionnaires/user/1/public/true/mine/true/shared/true"
in routes.rb I have
/questionnaires/*myparams(.:format) {:controller=>"questionnaires", :action=>"list"}
The controller uses routing to create a request in the list method.
class QuestionnairesController < ApplicationController before_filter :authenticate def list myparams = params[:myparams].split("/").to_h end
I am trying to create test cases for all parameters in a specification file
describe "GET list" do it "returns the list of questionnaires for the user" do get :list
what i get when i run rspec
Failures: 1) QuestionnairesController List GET list returns the list of questionnaires for the user Failure/Error: get :list No route matches {:controller=>"questionnaires", :action=>"list"}
The question is how do you write the spec file to pass the globbed parameters to rspec. I like to do something like this:
describe "GET list" do it "returns the list of questionnaires for the user" do get :list, "/user/1/public/true/mine/true/shared/true" end end
and change the settings to test various cases
source share