Ignore meta in a method provider's list of provided methods.
[gitmo/MooseX-AttributeHelpers.git] / t / 020_remove_attribute.t
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('MooseX::AttributeHelpers');   
11 }
12
13 {
14     package MyHomePage;
15     use Moose;
16
17     has 'counter' => (
18         metaclass => 'Counter',
19         is        => 'ro',
20         isa       => 'Int',
21         default   => sub { 0 },
22         provides  => {
23             inc   => 'inc_counter',
24             dec   => 'dec_counter',
25             reset => 'reset_counter',
26         }
27     );
28 }
29
30 my $page = MyHomePage->new();
31 isa_ok($page, 'MyHomePage');
32
33 can_ok($page, $_) for qw[
34     counter
35     dec_counter 
36     inc_counter
37     reset_counter
38 ];
39
40 lives_ok {
41     $page->meta->remove_attribute('counter')
42 } '... removed the counter attribute okay';
43
44 ok(!$page->meta->has_attribute('counter'), '... no longer has the attribute');
45
46 ok(!$page->can($_), "... our class no longer has the $_ method") for qw[
47     counter
48     dec_counter 
49     inc_counter
50     reset_counter
51 ];
52
53
54