Commit | Line | Data |
009b5b23 |
1 | use Test::More tests => 6; |
2 | use strict; |
3 | use warnings; |
4 | use Moose::Meta::Class; |
5 | #use Moose::Meta::Attribute; |
6 | use Catalyst::Request; |
7 | |
8 | use_ok('Catalyst::Action'); |
9 | |
10 | my $action_1 = Catalyst::Action->new( |
11 | name => 'foo', |
12 | code => sub { "DUMMY" }, |
13 | reverse => 'bar/foo', |
14 | namespace => 'bar', |
15 | attributes => { |
16 | Args => [ 1 ], |
17 | attr2 => [ 2 ], |
18 | }, |
19 | ); |
20 | |
21 | my $action_2 = Catalyst::Action->new( |
22 | name => 'foo', |
23 | code => sub { "DUMMY" }, |
24 | reverse => 'bar/foo', |
25 | namespace => 'bar', |
26 | attributes => { |
27 | Args => [ 2 ], |
28 | attr2 => [ 2 ], |
29 | }, |
30 | ); |
31 | |
32 | is("${action_1}", $action_1->reverse, 'overload string'); |
33 | is($action_1->(), 'DUMMY', 'overload code'); |
34 | |
35 | my $anon_meta = Moose::Meta::Class->create_anon_class( |
36 | attributes => [ |
37 | Moose::Meta::Attribute->new( |
38 | request => ( |
39 | reader => 'request', |
40 | required => 1, |
41 | default => sub { Catalyst::Request->new(arguments => [qw/one two/]) }, |
42 | ), |
43 | ), |
44 | ], |
45 | methods => { req => sub { shift->request(@_) } } |
46 | ); |
47 | |
48 | my $mock_c = $anon_meta->new_object(); |
49 | $mock_c->request; |
50 | |
51 | ok(!$action_1->match($mock_c), 'bad match fails'); |
52 | ok($action_2->match($mock_c), 'good match works'); |
53 | |
54 | ok($action_2->compare( $action_1 ), 'compare works'); |