Commit | Line | Data |
e3c07b19 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
a28e50e4 |
6 | use Test::More; |
b10dde3a |
7 | use Test::Fatal; |
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 | |
b10dde3a |
36 | is( exception { |
d50fc84a |
37 | $page->meta->remove_attribute('counter'); |
b10dde3a |
38 | }, undef, '... removed the counter attribute okay' ); |
e3c07b19 |
39 | |
d50fc84a |
40 | ok( !$page->meta->has_attribute('counter'), |
41 | '... no longer has the attribute' ); |
e3c07b19 |
42 | |
d50fc84a |
43 | ok( !$page->can($_), "... our class no longer has the $_ method" ) for qw[ |
e3c07b19 |
44 | counter |
45 | dec_counter |
46 | inc_counter |
47 | reset_counter |
48 | ]; |
a28e50e4 |
49 | |
50 | done_testing; |