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