Fix pod coverage.
[gitmo/MooseX-AttributeHelpers.git] / t / 011_counter_with_defaults.t
CommitLineData
829736f9 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
9a976497 6use Test::More tests => 14;
829736f9 7
8BEGIN {
9 use_ok('MooseX::AttributeHelpers');
10}
11
12{
13 package MyHomePage;
14 use Moose;
15
16 has 'counter' => (metaclass => 'Counter');
17}
18
19my $page = MyHomePage->new();
20isa_ok($page, 'MyHomePage');
21
22can_ok($page, $_) for qw[
23 dec_counter
24 inc_counter
25 reset_counter
26];
27
28is($page->counter, 0, '... got the default value');
29
30$page->inc_counter;
31is($page->counter, 1, '... got the incremented value');
32
33$page->inc_counter;
34is($page->counter, 2, '... got the incremented value (again)');
35
36$page->dec_counter;
37is($page->counter, 1, '... got the decremented value');
38
39$page->reset_counter;
40is($page->counter, 0, '... got the original value');
41
42# check the meta ..
43
44my $counter = $page->meta->get_attribute('counter');
45isa_ok($counter, 'MooseX::AttributeHelpers::Counter');
46
47is($counter->helper_type, 'Num', '... got the expected helper type');
48
49is($counter->type_constraint->name, 'Num', '... got the expected default type constraint');
50
51is_deeply($counter->provides, {
52 inc => 'inc_counter',
53 dec => 'dec_counter',
54 reset => 'reset_counter',
028a728d 55 set => 'set_counter',
829736f9 56}, '... got the right default provides methods');
57