On Tue, Jul 28, 2009 at 1:44 PM, norm<codehac...@comcast.net> wrote: > 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 > example: > > http://www.example.com/students/34/grad_surveys/21/student_edit?token=ab56e1b47 > so the params hash should contain > {"controller"=>"grad_surveys","action"=>"student_edit", > "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 > GradSurvey.stub!(:accepts_as_authorized).with > (:id=>"1",:token=>"ab56e1b47").and_return(true) > GradSurvey.should_receive(:accepts_as_authorized).with > (:id=>"1", :token=>"ab56e1b47")
Why are you using both stub!() and should_receive() here? The should_receive() call essentially overrides stub!(), so stub!() has no effect in this example. > get :student_edit, {:id=>"1", :token=>"ab56e1b47"} > end > > 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 provide The error says that it's expecting {:token=>"ab56e1b47", :id=>"1"}, which looks correct based on the line that's setting up the expectation. So I think the problem may be with the code, not the spec. Can you post the controller code? _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users