7 use lib "$FindBin::Bin/../lib";
9 use Test::More tests => 14;
10 use Catalyst::Test 'TestApp';
14 my $uri_base = 'http://localhost/priorities';
18 'Local vs. Path 1', { path => '/loc_vs_path1', expect => 'local' },
19 'Local vs. Path 2', { path => '/loc_vs_path2', expect => 'path' },
22 'index vs. Local', { path => '/loc_vs_index', expect => 'index' },
23 'index vs. Path', { path => '/path_vs_index', expect => 'index' },
25 'multimethod zero', { path => '/multimethod', expect => 'zero' },
26 'multimethod one', { path => '/multimethod/1', expect => 'one 1' },
27 'multimethod two', { path => '/multimethod/1/2',
28 expect => 'two 1 2' },
33 my $name = shift @tests;
34 my $data = shift @tests;
36 # Run tests for path with trailing slash and without
39 join( '' => $uri_base, $data->{ path } ), # Without trailing path
40 join( '' => $uri_base, $data->{ path }, '/' ), # With trailing path
42 my $end_slash = ( $req_uri =~ qr(/$) ? 1 : 0 );
44 # use slash_expect argument if URI ends with slash
45 # and the slash_expect argument is defined
46 my $expect = $data->{ expect } || '';
47 if ( $end_slash and exists $data->{ slash_expect } ) {
48 $expect = $data->{ slash_expect };
51 # Call the URI on the TestApp
52 my $response = request( $req_uri );
54 # Leave expect out to see the result
56 skip 'Nothing expected, winner is ' . $response->content, 1;
59 # Show error if response was no success
60 if ( not $response->is_success ) {
61 diag 'Error: ' . $response->headers->{ 'x-catalyst-error' };
64 # Test if content matches expectations.
65 # TODO This might flood the screen with the catalyst please-come-later
66 # page. So I don't know it is a good idea.
67 is( $response->content, $expect,
68 "$name: @{[ $data->{ expect } ]} wins"
69 . ( $end_slash ? ' (trailing slash)' : '' )