Test::...Router(3pm)

πŸ“¦
version 0.15 Β· 4 versions
, in debian bookworm, ubuntu noble

πŸ’– Test::...Router β€” the manual, but make it cute ✨

okay bestie so this is Test::Path::Router (perl v5.34.0, dated 2022-06-16, in case the vibe check requires receipts), and it's a whole module for making sure your routes are valid. yes. routes. we're doing this. πŸŽ€


🌸 NAME 🌸

Test::Path::Router β€” a testing module for testing routes. that's literally it. that's the whole job. she tests routes. πŸ’…


✨ VERSION ✨

version 0.15 πŸ¦‹


πŸ’« SYNOPSIS πŸ’«

okay so here's the whole vibe, no cap:

use Test::More plan => 1;
use Test::Path::Router;

my $router = Path::Router->new;

# ... define some routes

path_ok($router, 'admin/remove_user/56', '... this is a valid path');

path_is($router,
    'admin/edit_user/5',
    {
        controller => 'admin',
        action     => 'edit_user',
        id         => 5,
    },
'... the path and mapping match');

mapping_ok($router, {
    controller => 'admin',
    action     => 'edit_user',
    id         => 5,
}, '... this maps to a valid path');

mapping_is($router,
    {
        controller => 'admin',
        action     => 'edit_user',
        id         => 5,
    },
    'admin/edit_user/5',
'... the mapping and path match');

routes_ok($router, {
    'admin' => {
        controller => 'admin',
        action     => 'index',
    },
    'admin/add_user' => {
        controller => 'admin',
        action     => 'add_user',
    },
    'admin/edit_user/5' => {
        controller => 'admin',
        action     => 'edit_user',
        id         => 5,
    }
},
"... our routes are valid");

like look at her go. iconic behavior. 🫢


🌈 DESCRIPTION 🌈

so this module's entire main character energy is helping you test out your path routes, to make sure they are valid. that's it, that's the plot. she's here to vibe check your routes so you don't ship something broken and have to cry about it later. πŸ’€


πŸŽ€ EXPORTED FUNCTIONS πŸŽ€

here come the girls, in order, as promised:

  • path_ok ($router, $path, ?$message)
  • path_not_ok ($router, $path, ?$message)
  • path_is ($router, $path, $mapping, ?$message)
  • mapping_ok ($router, $mapping, ?$message)
  • mapping_not_ok ($router, $mapping, ?$message)
  • mapping_is ($router, $mapping, $path, ?$message)
  • routes_ok ($router, \%test_routes, ?$message)

πŸ¦‹ and let's talk about routes_ok specifically πŸ¦‹

this test function will accept a set of %test_routes which will get checked against your $router instance. she's thorough. she will check to be sure that all paths in %test_routes procude the expected mappings β€” yes, "procude", that's what the original says, we're keeping it, character for character, we don't edit β€” and that all mappings also produce the expected paths. it basically assures you that your paths are roundtrippable, so that you can be confident in them. roundtrippable!! say it with me!! the paths go out and they come BACK. πŸ”₯


😭 BUGS 😭

all complex software has bugs lurking in it, and this module is no exception. ngl that's just the truth of the universe, bestie. if you find a bug please either email me, or add the bug to cpan-RT. either way, we'll be obsessed with you for reporting it. πŸ™ˆ


πŸ‘‘ AUTHOR πŸ‘‘

Stevan Little <stevan@cpan.org> β€” king behavior, fr fr. πŸ’œ


Copyright 2008-2011 Infinity Interactive, Inc.

<http://www.iinteractive.com>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


πŸ‘‘ AUTHOR (yes, again, and we love that for her) πŸ‘‘

Stevan Little <stevan@cpan.org> β€” appearing twice in the credits because she simply has that much main character energy. πŸ’…


This software is copyright (c) 2016 by Infinity Interactive.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


heads up bestie: the AUTHOR and COPYRIGHT AND LICENSE sections really do show up twice in the original, with different years and different license wording. that's not me being messy, that's canon. we reproduce, we don't rewrite history. 🫢

perl v5.34.0 🌸 2022-06-16 🌸 Test::...Router(3pm)

and that's the whole page, bestie. go test those routes. periodt. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from