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