Skip to content

Commit

Permalink
Add failing test about conflicting routes
Browse files Browse the repository at this point in the history
  • Loading branch information
ahx committed Jun 11, 2024
1 parent 25ff419 commit 1521ba8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/lib/lennarb/test_route_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,22 @@ def test_match_invalid_route
assert_nil block
assert_nil params
end

def test_different_variables_in_common_nested_routes
router = Lennarb::RouteNode.new
router.add_route(['foo', ':foo'], 'GET', proc { 'foo' })
router.add_route(%w[foo special], 'GET', proc { 'special' })
router.add_route(['foo', ':id', 'bar'], 'GET', proc { 'bar' })

_, params = router.match_route(%w[foo 23], 'GET')

assert_equal({ foo: '23' }, params)
_, params = router.match_route(%w[foo special], 'GET')

assert_empty(params)
_, params = router.match_route(%w[foo 24 bar], 'GET')

assert_equal({ id: '24' }, params)
end
end
end

0 comments on commit 1521ba8

Please sign in to comment.