Commit | Line | Data |
d91504e3 |
1 | use warnings; |
2 | use strict; |
842180f7 |
3 | |
4 | BEGIN { |
5 | use Test::More; |
6 | eval "use Types::Standard; 1;" || do { |
7 | plan skip_all => "Trouble loading Types::Standard => $@"; |
8 | }; |
9 | } |
d91504e3 |
10 | |
11 | { |
12 | package MyApp::Controller::Root; |
13 | $INC{'MyApp/Controller/Root.pm'} = __FILE__; |
14 | |
15 | use Moose; |
16 | use MooseX::MethodAttributes; |
842180f7 |
17 | use Types::Standard qw/Tuple Int Str/; |
d91504e3 |
18 | |
19 | extends 'Catalyst::Controller'; |
20 | |
6d62355b |
21 | sub an_int :Local Args(Int) { |
22 | my ($self, $c, $int) = @_; |
6d62355b |
23 | $c->res->body('an_int'); |
24 | } |
25 | |
4a0218ca |
26 | sub many_ints :Local Args(ArrayRef[Int]) { |
27 | my ($self, $c, $int) = @_; |
28 | $c->res->body('many_ints'); |
29 | } |
30 | |
842180f7 |
31 | sub tuple :Local Args(Tuple[Str,Int]) { |
32 | my ($self, $c, $int) = @_; |
33 | $c->res->body('tuple'); |
34 | } |
35 | |
36 | |
e5604544 |
37 | sub any_priority :Path('priority_test') Args(1) { $_[1]->res->body('any_priority') } |
842180f7 |
38 | |
b7791bd7 |
39 | sub int_priority :Path('priority_test') Args(Int) { $_[1]->res->body('int_priority') } |
e5604544 |
40 | |
6d62355b |
41 | sub default :Default { |
42 | my ($self, $c, $int) = @_; |
43 | $c->res->body('default'); |
d91504e3 |
44 | } |
45 | |
46 | MyApp::Controller::Root->config(namespace=>''); |
47 | |
48 | package MyApp; |
49 | use Catalyst; |
50 | |
e5604544 |
51 | #MyApp->config(show_internal_actions => 1); |
d91504e3 |
52 | MyApp->setup; |
53 | } |
54 | |
55 | use Catalyst::Test 'MyApp'; |
56 | |
57 | { |
6d62355b |
58 | my $res = request '/an_int/1'; |
59 | is $res->content, 'an_int'; |
60 | } |
61 | |
62 | { |
337a627a |
63 | my $res = request '/an_int/aa'; |
64 | is $res->content, 'default'; |
65 | } |
66 | |
67 | { |
4a0218ca |
68 | my $res = request '/many_ints/1'; |
69 | is $res->content, 'many_ints'; |
70 | } |
71 | |
72 | { |
73 | my $res = request '/many_ints/1/2'; |
74 | is $res->content, 'many_ints'; |
75 | } |
76 | |
77 | { |
78 | my $res = request '/many_ints/1/2/3'; |
79 | is $res->content, 'many_ints'; |
80 | } |
81 | |
82 | { |
83 | my $res = request '/many_ints/1/2/a'; |
84 | is $res->content, 'default'; |
85 | } |
86 | |
e5604544 |
87 | { |
88 | my $res = request '/priority_test/1'; |
89 | is $res->content, 'int_priority'; |
90 | } |
842180f7 |
91 | |
e5604544 |
92 | { |
93 | my $res = request '/priority_test/a'; |
94 | is $res->content, 'any_priority'; |
95 | } |
96 | |
842180f7 |
97 | { |
98 | my $res = request '/tuple/aaa/111'; |
99 | is $res->content, 'tuple'; |
100 | } |
101 | |
102 | { |
103 | my $res = request '/tuple/aaa/aaa'; |
104 | is $res->content, 'default'; |
105 | } |
106 | |
d91504e3 |
107 | done_testing; |
81436df9 |
108 | |