Skip to content

Commit

Permalink
fix(ruby-grape#2415): Failed spec when recognizing two paths with the…
Browse files Browse the repository at this point in the history
… same route and different methods
  • Loading branch information
jcagarcia committed Oct 4, 2024
1 parent 5b0066c commit 919f5f3
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions spec/grape/api/recognize_path_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,24 @@
expect(actual).to eq('/books/:id/loans/:loan_id')
end
end

context 'when same path for different methods' do
subject do
Class.new(described_class) do
resource :books do
post do
end

get do
end
end
end
end

it 'allows to recognize both endpoints' do
actual = subject.recognize_path('/books')
expect(actual.routes.size).to eq(2)
end
end
end
end

1 comment on commit 919f5f3

@jcagarcia
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Result of the test before commenting on the original issue:

Failures:

  1) Grape::API.recognize_path when same path for different methods allows to recognize both endpoints
     Failure/Error: expect(actual.routes.size).to eq(2)

       expected: 2
            got: 1

       (compared using ==)
     # ./spec/grape/api/recognize_path_spec.rb:91:in `block (4 levels) in <top (required)>'

Finished in 0.02134 seconds (files took 0.36949 seconds to load)
8 examples, 1 failure

Please sign in to comment.