|
41 | 41 | expect(router.match('DELETE', '/b').error).to have_attributes(type: :method_not_allowed) |
42 | 42 | end |
43 | 43 |
|
| 44 | + it 'does not match a dynamic path with a trailing slash' do |
| 45 | + match = router.match('GET', '/42/') |
| 46 | + expect(match.request_definition).to be_nil |
| 47 | + end |
| 48 | + |
| 49 | + it 'does not match a static path with a trailing slash' do |
| 50 | + match = router.match('GET', '/a/') |
| 51 | + expect(match.request_definition).to be_nil |
| 52 | + end |
| 53 | + |
44 | 54 | context 'with ambiguous paths' do |
45 | 55 | let(:requests) do |
46 | 56 | [ |
|
55 | 65 | end |
56 | 66 | end |
57 | 67 |
|
| 68 | + context 'with trailing slashes in path definitions' do |
| 69 | + let(:requests) do |
| 70 | + [ |
| 71 | + double(path: '/{id}/', request_method: 'get'), |
| 72 | + double(path: '/a/', request_method: 'get') |
| 73 | + ] |
| 74 | + end |
| 75 | + |
| 76 | + it 'matches a dynamic path' do |
| 77 | + match = router.match('GET', '/42/') |
| 78 | + expect(match.request_definition.path).to eq('/{id}/') |
| 79 | + end |
| 80 | + |
| 81 | + it 'does not match a dynamic path with missing trailing slash' do |
| 82 | + match = router.match('GET', '/42') |
| 83 | + expect(match.error.type).to eq(:not_found) |
| 84 | + end |
| 85 | + |
| 86 | + it 'matches a static path' do |
| 87 | + match = router.match('GET', '/a/') |
| 88 | + expect(match.request_definition.path).to eq('/a/') |
| 89 | + end |
| 90 | + |
| 91 | + it 'does not match a static path with missing trailing slash' do |
| 92 | + match = router.match('GET', '/a') |
| 93 | + expect(match.error.type).to eq(:not_found) |
| 94 | + end |
| 95 | + end |
| 96 | + |
58 | 97 | context 'with ambiguous paths reversed' do |
59 | 98 | let(:requests) do |
60 | 99 | [ |
|
0 commit comments