6 use Test::More tests => 18;
9 use_ok('Moose::AttributeHelpers');
17 metaclass => 'Counter',
24 reset => 'reset_counter',
30 my $page = MyHomePage->new();
31 isa_ok($page, 'MyHomePage');
33 can_ok($page, $_) for qw[
40 is($page->counter, 0, '... got the default value');
43 is($page->counter, 1, '... got the incremented value');
46 is($page->counter, 2, '... got the incremented value (again)');
49 is($page->counter, 1, '... got the decremented value');
52 is($page->counter, 0, '... got the original value');
54 $page->set_counter(5);
55 is($page->counter, 5, '... set the value');
57 $page->inc_counter(2);
58 is($page->counter, 7, '... increment by arg');
60 $page->dec_counter(5);
61 is($page->counter, 2, '... decrement by arg');
65 my $counter = $page->meta->get_attribute('counter');
66 isa_ok($counter, 'Moose::AttributeHelpers::Counter');
68 is($counter->helper_type, 'Num', '... got the expected helper type');
70 is($counter->type_constraint->name, 'Int', '... got the expected type constraint');
72 is_deeply($counter->provides, {
75 reset => 'reset_counter',
77 }, '... got the right provides methods');