ruby on rails - Routing specs fails because hashes are stored differently -


my test example is:

it "routes #add_role" post("/users/1/add_role").should route_to("users#add_role",id: 1) end 

here failure message:

userscontroller routing routes #add_role failure/error: post("/users/1/add_role").should route_to("users#add_role",id: 1) recognized options <{"controller"=>"users", "action"=>"add_role", "id"=>"1"}> did not match <{"id"=>1, "controller"=>"users", "action"=>"add_role"}>, difference: <{"id"=>1}>. <{"id"=>1, "controller"=>"users", "action"=>"add_role"}> expected <{"controller"=>"users", "action"=>"add_role", "id"=>"1"}>. 

my environment:

  • ruby-1.9.3-p194
  • rails 3.2.6
  • rspec (2.10.0)

you need id in route_to string. rails not type cast numbers makes no assumptions types


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

c++ - Accessing inactive union member and undefined behavior? -

php - Get uncommon values from two or more arrays -