6 use Test::More no_plan => 1;
10 use_ok('MooseX::AttributeHelpers');
16 use MooseX::AttributeHelpers;
19 metaclass => 'Collection::Hash',
21 isa => 'HashRef[Str]',
22 default => sub { {} },
24 'set' => 'set_option',
25 'get' => 'get_option',
26 'empty' => 'has_options',
27 'count' => 'num_options',
28 'delete' => 'delete_option',
33 my $stuff = Stuff->new();
34 isa_ok($stuff, 'Stuff');
36 can_ok($stuff, $_) for qw[
44 ok(!$stuff->has_options, '... we have no options');
45 is($stuff->num_options, 0, '... we have no options');
47 is_deeply($stuff->options, {}, '... no options yet');
50 $stuff->set_option(foo => 'bar');
51 } '... set the option okay';
53 ok($stuff->has_options, '... we have options');
54 is($stuff->num_options, 1, '... we have 1 option(s)');
55 is_deeply($stuff->options, { foo => 'bar' }, '... got options now');
58 $stuff->set_option(bar => 'baz');
59 } '... set the option okay';
61 is($stuff->num_options, 2, '... we have 2 option(s)');
62 is_deeply($stuff->options, { foo => 'bar', bar => 'baz' }, '... got more options now');
64 is($stuff->get_option('foo'), 'bar', '... got the right option');
67 $stuff->delete_option('bar');
68 } '... deleted the option okay';
70 is($stuff->num_options, 1, '... we have 1 option(s)');
71 is_deeply($stuff->options, { foo => 'bar' }, '... got more options now');
74 Stuff->new(options => { foo => 'BAR' });
75 } '... good constructor params';
80 $stuff->set_option(bar => {});
81 } '... could not add a hash ref where an string is expected';
84 Stuff->new(options => { foo => [] });
85 } '... bad constructor params';