[rspec-users] passing parameters when testing controller actions

norm codehacker at comcast.net
Tue Jul 28 13:44:37 EDT 2009

My grad_surveys_controller has a student_edit method. An id parameter
is passed in the url and a token is passed in a query string. For
so the params hash should contain
"student_id"=>"34", "id"=>"21", "token"=>"ab56e1b47"}

I am trying to test using the following example:

  it "should permit student access with the correct token supplied" do
(:id=>"1", :token=>"ab56e1b47")

    get :student_edit, {:id=>"1", :token=>"ab56e1b47"}

which fails with the message:
<GradSurvey(... snip... all the fields listed) (class)>
expected :accepts_as_authorized with ({:token=>"ab56e1b47", :id=>"1"})
but received it with ("1", "ab56e1b47")

What is the error in my example syntax that is causing the parameters
not to be correctly recognized.

thanks in advance for any assistance you are able to providd

More information about the rspec-users mailing list