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