ruby on rails - Rspec routing specs give failure with param id reversed? -


my routing specs rspec give unclear error back. in expected params v/s real param id param @ reversed position. why , how resolve?

require "spec_helper"  describe gamecontroller   describe "routing"      game = factorygirl.create(:game)      "routes #show"       get("/game/1").should route_to("game#show", :id => 1)     end    end end 

this throws error:

  1) gamecontroller routing routes #show      failure/error: get("/game/1").should route_to("game#show", :id => 1)        recognized options <{"action"=>"show", "controller"=>"game", "id"=>"1"}> did not match <{"id"=>1, "controller"=>"game", "action"=>"show"}>, difference:.        <{"id"=>1, "controller"=>"game", "action"=>"show"}> expected        <{"action"=>"show", "controller"=>"game", "id"=>"1"}>.      # ./spec/routing/game_routing_spec.rb:11:in `block (3 levels) in <top (required)>' 

rails parses parameters strings, not integers, params[:id] being assigned "1" instead of 1.

try expecting string instead:

get("/game/1").should route_to("game#show", :id => "1") 

Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -