File: 020_remove_attribute.t

package info (click to toggle)
libmoosex-attributehelpers-perl 0.23-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 412 kB
  • ctags: 217
  • sloc: perl: 3,890; makefile: 5
file content (54 lines) | stat: -rw-r--r-- 961 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/perl

use strict;
use warnings;

use Test::More tests => 12;
use Test::Exception;

BEGIN {
    use_ok('MooseX::AttributeHelpers');   
}

{
    package MyHomePage;
    use Moose;

    has 'counter' => (
        metaclass => 'Counter',
        is        => 'ro',
        isa       => 'Int',
        default   => sub { 0 },
        provides  => {
            inc   => 'inc_counter',
            dec   => 'dec_counter',
            reset => 'reset_counter',
        }
    );
}

my $page = MyHomePage->new();
isa_ok($page, 'MyHomePage');

can_ok($page, $_) for qw[
    counter
    dec_counter 
    inc_counter
    reset_counter
];

lives_ok {
    $page->meta->remove_attribute('counter')
} '... removed the counter attribute okay';

ok(!$page->meta->has_attribute('counter'), '... no longer has the attribute');

ok(!$page->can($_), "... our class no longer has the $_ method") for qw[
    counter
    dec_counter 
    inc_counter
    reset_counter
];