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',
27 'delete' => 'delete_option',
32 my $stuff = Stuff->new();
33 isa_ok($stuff, 'Stuff');
35 can_ok($stuff, $_) for qw[
43 ok(!$stuff->has_options, '... we have no options');
44 is($stuff->num_options, 0, '... we have no options');
46 is_deeply($stuff->options, {}, '... no options yet');
49 $stuff->set_option(foo => 'bar');
50 } '... set the option okay';
52 ok($stuff->has_options, '... we have options');
53 is($stuff->num_options, 1, '... we have 1 option(s)');
54 is_deeply($stuff->options, { foo => 'bar' }, '... got options now');
57 $stuff->set_option(bar => 'baz');
58 } '... set the option okay';
60 is($stuff->num_options, 2, '... we have 2 option(s)');
61 is_deeply($stuff->options, { foo => 'bar', bar => 'baz' }, '... got more options now');
63 is($stuff->get_option('foo'), 'bar', '... got the right option');
66 $stuff->delete_option('bar');
67 } '... deleted the option okay';
69 is($stuff->num_options, 1, '... we have 1 option(s)');
70 is_deeply($stuff->options, { foo => 'bar' }, '... got more options now');
73 Stuff->new(options => { foo => 'BAR' });
74 } '... good constructor params';
79 $stuff->set_option(bar => {});
80 } '... could not add a hash ref where an string is expected';
83 Stuff->new(options => { foo => [] });
84 } '... bad constructor params';