Redid conversion to Test::Fatal
[gitmo/Moose.git] / t / 070_native_traits / 101_remove_attribute.t
CommitLineData
e3c07b19 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
a28e50e4 6use Test::More;
b10dde3a 7use 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
26my $page = MyHomePage->new();
d50fc84a 27isa_ok( $page, 'MyHomePage' );
e3c07b19 28
d50fc84a 29can_ok( $page, $_ ) for qw[
e3c07b19 30 counter
31 dec_counter
32 inc_counter
33 reset_counter
34];
35
b10dde3a 36is( exception {
d50fc84a 37 $page->meta->remove_attribute('counter');
b10dde3a 38}, undef, '... removed the counter attribute okay' );
e3c07b19 39
d50fc84a 40ok( !$page->meta->has_attribute('counter'),
41 '... no longer has the attribute' );
e3c07b19 42
d50fc84a 43ok( !$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
50done_testing;