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

Possible bug in route matcher #928

Closed
AlexVPopov opened this issue May 31, 2016 · 2 comments
Closed

Possible bug in route matcher #928

AlexVPopov opened this issue May 31, 2016 · 2 comments

Comments

@AlexVPopov
Copy link

Given the spec:

it { should route(:patch, '/notes/1').to(action: :update, foramt: :json, id: 1)

I get the following error:

should route PATCH /notes/1 to/from {:action=>"update", :foramt=>"json", :id=>"1", :controller=>"v1/notes"} (FAILED - 1)

Failures:

  1) V1::NotesController routing should route PATCH /notes/1 to/from {:action=>"update", :foramt=>"json", :id=>"1", :controller=>"v1/notes"}
     Failure/Error: it { should route(:patch, '/notes/1').to(action: :update, foramt: :json, id: 1) }

       The recognized options <{"format"=>:json, "controller"=>"v1/notes", "action"=>"update", "id"=>"1"}> did not match <{"action"=>"update", "foramt"=>"json", "id"=>"1", "controller"=>"v1/notes"}>, difference:.
       --- expected
       +++ actual
       @@ -1 +1 @@
       -{"action"=>"update", "foramt"=>"json", "id"=>"1", "controller"=>"v1/notes"}
       +{"format"=>:json, "controller"=>"v1/notes", "action"=>"update", "id"=>"1"}
     # ./spec/controllers/v1/notes_controller_spec.rb:11:in `block (3 levels) in <top (required)>'
     # ./spec/rails_helper.rb:45:in `block (3 levels) in <top (required)>'
     # ./spec/rails_helper.rb:45:in `block (2 levels) in <top (required)>'
     # -e:1:in `<main>'

As far as I can see, the only difference is that is expects the value of format as a string ("json"), but gets it as a symbol (:json). The strange thing, though, is I have a couple of other routing specs, which work as expected:

it { should route(:post, '/notes').to(action: :create, format: :json) }
it { should route(:get, '/notes/1').to(action: :show, format: :json, id: 1) }
it { should route(:get, '/notes').to(action: :index, format: :json) }

so this happens only with patch.

If I remove the json constraint from my routes and from the specs, all the specs pass.

@AlexVPopov
Copy link
Author

Somehow the problem disappeared.

@mcmire
Copy link
Collaborator

mcmire commented Jun 14, 2016

This has been reported before, so I don't think you were crazy: #809

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants