6 use Test::More no_plan => 1;
11 use_ok('MooseX::MetaDescription');
15 package Foo::Description::Trait;
18 has 'bar' => (is => 'ro', isa => 'Str');
19 has 'baz' => (is => 'ro', isa => 'Str');
20 has 'gorch' => (is => 'ro', isa => 'Str');
29 metaclass => 'MooseX::MetaDescription::Meta::Attribute',
32 default => sub { 'Foo::bar' },
34 traits => [qw[Foo::Description::Trait]],
35 baz => 'Foo::bar::baz',
36 gorch => 'Foo::bar::gorch',
41 traits => [ 'MooseX::MetaDescription::Meta::Trait' ],
44 default => sub { 'Foo::baz' },
46 traits => [qw[Foo::Description::Trait]],
47 bar => 'Foo::baz::bar',
48 gorch => 'Foo::baz::gorch',
55 my $bar_attr = Foo->meta->get_attribute('bar');
56 isa_ok($bar_attr->metadescription, 'MooseX::MetaDescription::Description');
57 does_ok($bar_attr->metadescription, 'Foo::Description::Trait');
58 is($bar_attr->metadescription->descriptor, $bar_attr, '... got the circular ref');
60 my $baz_attr = Foo->meta->get_attribute('baz');
61 isa_ok($baz_attr->metadescription, 'MooseX::MetaDescription::Description');
62 does_ok($baz_attr->metadescription, 'Foo::Description::Trait');
63 is($baz_attr->metadescription->descriptor, $baz_attr, '... got the circular ref');
65 # check the actual descs
67 foreach my $foo ('Foo', Foo->new) {
70 $foo->meta->get_attribute('bar')->description,
72 baz => 'Foo::bar::baz',
73 gorch => 'Foo::bar::gorch',
75 '... got the right class description'
78 my $bar_meta_desc = $foo->meta->get_attribute('bar')->metadescription;
79 is($bar_meta_desc->baz, 'Foo::bar::baz', '... we have methods');
80 is($bar_meta_desc->gorch, 'Foo::bar::gorch', '... we have methods');
83 $foo->meta->get_attribute('baz')->description,
85 bar => 'Foo::baz::bar',
86 gorch => 'Foo::baz::gorch',
88 '... got the right class description'
91 my $baz_meta_desc = $foo->meta->get_attribute('baz')->metadescription;
92 is($baz_meta_desc->bar, 'Foo::baz::bar', '... we have methods');
93 is($baz_meta_desc->gorch, 'Foo::baz::gorch', '... we have methods');