6 use Test::More tests => 18;
7 use Test::Moose 'does_ok';
10 use_ok('Moose::AttributeHelpers');
18 traits => [qw/Counter/],
25 reset_counter => 'reset',
31 my $page = MyHomePage->new();
32 isa_ok($page, 'MyHomePage');
34 can_ok($page, $_) for qw[
41 is($page->counter, 0, '... got the default value');
44 is($page->counter, 1, '... got the incremented value');
47 is($page->counter, 2, '... got the incremented value (again)');
50 is($page->counter, 1, '... got the decremented value');
53 is($page->counter, 0, '... got the original value');
55 $page->set_counter(5);
56 is($page->counter, 5, '... set the value');
58 $page->inc_counter(2);
59 is($page->counter, 7, '... increment by arg');
61 $page->dec_counter(5);
62 is($page->counter, 2, '... decrement by arg');
66 my $counter = $page->meta->get_attribute('counter');
67 does_ok($counter, 'Moose::AttributeHelpers::Trait::Counter');
69 is($counter->helper_type, 'Num', '... got the expected helper type');
71 is($counter->type_constraint->name, 'Int', '... got the expected type constraint');
73 is_deeply($counter->handles, {
76 reset_counter => 'reset',
78 }, '... got the right handles methods');