6 use Test::More no_plan => 1;
10 use_ok('MooseX::AttributeHelpers');
18 metaclass => 'Collection::Hash',
20 isa => 'HashRef[Str]',
21 default => sub { {} },
23 'set' => 'set_option',
24 'get' => 'get_option',
25 'empty' => 'has_options',
26 'count' => 'num_options',
31 my $stuff = Stuff->new();
32 isa_ok($stuff, 'Stuff');
34 can_ok($stuff, $_) for qw[
41 ok(!$stuff->has_options, '... we have no options');
42 is($stuff->num_options, 0, '... we have no options');
44 is_deeply($stuff->options, {}, '... no options yet');
47 $stuff->set_option(foo => 'bar');
48 } '... set the option okay';
50 ok($stuff->has_options, '... we have options');
51 is($stuff->num_options, 1, '... we have 1 option(s)');
52 is_deeply($stuff->options, { foo => 'bar' }, '... got options now');
55 $stuff->set_option(bar => 'baz');
56 } '... set the option okay';
58 is($stuff->num_options, 2, '... we have 2 option(s)');
59 is_deeply($stuff->options, { foo => 'bar', bar => 'baz' }, '... got more options now');
61 is($stuff->get_option('foo'), 'bar', '... got the right option');
64 Stuff->new(options => { foo => 'BAR' });
65 } '... good constructor params';
70 $stuff->set_option(bar => {});
71 } '... could not add a hash ref where an string is expected';
74 Stuff->new(options => { foo => [] });
75 } '... bad constructor params';