Skip to content

Commit 524c91a

Browse files
committed
Add another test about ambigous paths
1 parent 49e2358 commit 524c91a

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ GEM
153153
racc (~> 1.4)
154154
nokogiri (1.18.10-x86_64-linux-musl)
155155
racc (~> 1.4)
156-
openapi_parameters (0.7.0)
156+
openapi_parameters (0.8.0)
157157
rack (>= 2.2)
158158
parallel (1.27.0)
159159
parser (3.3.9.0)

spec/router_spec.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,34 @@
4141
expect(router.match('DELETE', '/b').error).to have_attributes(type: :method_not_allowed)
4242
end
4343

44+
context 'with ambiguous paths' do
45+
let(:requests) do
46+
[
47+
double(path: '/api/{tenant_id}/tickets/extra', request_method: 'get'),
48+
double(path: '/api/{tenant_id}/tickets/{id}', request_method: 'get')
49+
]
50+
end
51+
52+
it 'matches the exact path' do
53+
match = router.match('GET', '/api/42/tickets/extra')
54+
expect(match.request_definition.path).to eq('/api/{tenant_id}/tickets/extra')
55+
end
56+
end
57+
58+
context 'with ambiguous paths reversed' do
59+
let(:requests) do
60+
[
61+
double(path: '/api/{tenant_id}/tickets/{id}', request_method: 'get'),
62+
double(path: '/api/{tenant_id}/tickets/extra', request_method: 'get')
63+
]
64+
end
65+
66+
it 'matches the exact path' do
67+
match = router.match('GET', '/api/42/tickets/extra')
68+
expect(match.request_definition.path).to eq('/api/{tenant_id}/tickets/extra')
69+
end
70+
end
71+
4472
context 'with matching content_type' do
4573
subject(:router) do
4674
described_class.new.tap do |router|

0 commit comments

Comments
 (0)