Commit | Line | Data |
e3c07b19 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More tests => 12; |
7 | use Test::Exception; |
8 | |
9 | BEGIN { |
10 | use_ok('Moose::AttributeHelpers'); |
11 | } |
12 | |
13 | { |
14 | package MyHomePage; |
15 | use Moose; |
16 | |
17 | has 'counter' => ( |
d50fc84a |
18 | traits => ['Counter'], |
19 | is => 'ro', |
20 | isa => 'Int', |
21 | default => 0, |
22 | handles => { |
c13596ce |
23 | inc_counter => 'inc', |
24 | dec_counter => 'dec', |
25 | reset_counter => 'reset', |
e3c07b19 |
26 | } |
27 | ); |
28 | } |
29 | |
30 | my $page = MyHomePage->new(); |
d50fc84a |
31 | isa_ok( $page, 'MyHomePage' ); |
e3c07b19 |
32 | |
d50fc84a |
33 | can_ok( $page, $_ ) for qw[ |
e3c07b19 |
34 | counter |
35 | dec_counter |
36 | inc_counter |
37 | reset_counter |
38 | ]; |
39 | |
40 | lives_ok { |
d50fc84a |
41 | $page->meta->remove_attribute('counter'); |
42 | } |
43 | '... removed the counter attribute okay'; |
e3c07b19 |
44 | |
d50fc84a |
45 | ok( !$page->meta->has_attribute('counter'), |
46 | '... no longer has the attribute' ); |
e3c07b19 |
47 | |
d50fc84a |
48 | ok( !$page->can($_), "... our class no longer has the $_ method" ) for qw[ |
e3c07b19 |
49 | counter |
50 | dec_counter |
51 | inc_counter |
52 | reset_counter |
53 | ]; |