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