Commit | Line | Data |
d91504e3 |
1 | use warnings; |
2 | use strict; |
3 | use Test::More; |
4 | use HTTP::Request::Common; |
5 | |
6 | { |
7 | package MyApp::Controller::Root; |
8 | $INC{'MyApp/Controller/Root.pm'} = __FILE__; |
9 | |
10 | use Moose; |
11 | use MooseX::MethodAttributes; |
12 | |
13 | extends 'Catalyst::Controller'; |
14 | |
6d62355b |
15 | sub an_int :Local Args(Int) { |
16 | my ($self, $c, $int) = @_; |
6d62355b |
17 | $c->res->body('an_int'); |
18 | } |
19 | |
4a0218ca |
20 | sub many_ints :Local Args(ArrayRef[Int]) { |
21 | my ($self, $c, $int) = @_; |
22 | $c->res->body('many_ints'); |
23 | } |
24 | |
6d62355b |
25 | sub default :Default { |
26 | my ($self, $c, $int) = @_; |
27 | $c->res->body('default'); |
d91504e3 |
28 | } |
29 | |
30 | MyApp::Controller::Root->config(namespace=>''); |
31 | |
32 | package MyApp; |
33 | use Catalyst; |
34 | |
35 | MyApp->setup; |
36 | } |
37 | |
38 | use Catalyst::Test 'MyApp'; |
39 | |
40 | { |
6d62355b |
41 | my $res = request '/an_int/1'; |
42 | is $res->content, 'an_int'; |
43 | } |
44 | |
45 | { |
337a627a |
46 | my $res = request '/an_int/aa'; |
47 | is $res->content, 'default'; |
48 | } |
49 | |
50 | { |
4a0218ca |
51 | my $res = request '/many_ints/1'; |
52 | is $res->content, 'many_ints'; |
53 | } |
54 | |
55 | { |
56 | my $res = request '/many_ints/1/2'; |
57 | is $res->content, 'many_ints'; |
58 | } |
59 | |
60 | { |
61 | my $res = request '/many_ints/1/2/3'; |
62 | is $res->content, 'many_ints'; |
63 | } |
64 | |
65 | { |
66 | my $res = request '/many_ints/1/2/a'; |
67 | is $res->content, 'default'; |
68 | } |
69 | |
d91504e3 |
70 | done_testing; |
81436df9 |
71 | |