Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Route with symbol for default format cannot match #454

Closed
brianhempel opened this issue Mar 18, 2014 · 2 comments
Closed

Route with symbol for default format cannot match #454

brianhempel opened this issue Mar 18, 2014 · 2 comments

Comments

@brianhempel
Copy link

In Rails 4, the default format route parameter may have been set to a symbol, but because shoulda stringifies the expected parameters given, it is impossible to match a route with a default format set to a symbol.

namespace :api, defaults: {format: :json} do
  resources :user
end

Try to match it and you will get an unhelpful error, like:

       <{"format"=>"json",
        "action"=>"show",
        "controller"=>"api/users"}> expected but was
       <{"format"=>:json,
        "action"=>"show",
        "controller"=>"api/users"}>

Even crazier, when you switch from back and forth from a symbol to a string in your tests, the error message alternates between the first and the second hash containing the symbol value.

A temporary fix is to use the RSpec route_to matcher, which does not stringify the values.

@maurogeorge
Copy link
Contributor

@mcmire I think we can close this since the #693 was merged. 😄

@mcmire
Copy link
Collaborator

mcmire commented Apr 2, 2015

Is this issue really a year old? 😬

Closed.

@mcmire mcmire closed this as completed Apr 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants