6 use Test::More 'no_plan';
10 use_ok('MooseX::MetaDescription');
14 package Foo::Description;
17 extends 'MooseX::MetaDescription::Description';
19 has 'bar' => (is => 'ro', isa => 'Str');
20 has 'baz' => (is => 'ro', isa => 'Str');
21 has 'gorch' => (is => 'ro', isa => 'Str');
23 package Foo::MetaDescription::Trait;
26 with 'MooseX::MetaDescription::Meta::Trait';
28 has 'metadescription_classname' => (
29 default => 'Foo::Description',
33 package Foo::MetaDescription::Attribute;
36 extends 'MooseX::MetaDescription::Meta::Attribute';
38 has 'metadescription_classname' => (
39 default => 'Foo::Description',
49 metaclass => 'Foo::MetaDescription::Attribute',
52 default => sub { 'Foo::bar' },
54 baz => 'Foo::bar::baz',
55 gorch => 'Foo::bar::gorch',
60 traits => [ 'Foo::MetaDescription::Trait' ],
63 default => sub { 'Foo::baz' },
65 bar => 'Foo::baz::bar',
66 gorch => 'Foo::baz::gorch',
73 my $bar_attr = Foo->meta->get_attribute('bar');
74 isa_ok($bar_attr->metadescription, 'MooseX::MetaDescription::Description');
75 isa_ok($bar_attr->metadescription, 'Foo::Description');
76 is($bar_attr->metadescription->descriptor, $bar_attr, '... got the circular ref');
78 my $baz_attr = Foo->meta->get_attribute('baz');
79 isa_ok($baz_attr->metadescription, 'MooseX::MetaDescription::Description');
80 isa_ok($baz_attr->metadescription, 'Foo::Description');
81 is($baz_attr->metadescription->descriptor, $baz_attr, '... got the circular ref');
83 # check the actual descs
85 foreach my $foo ('Foo', Foo->new) {
88 $foo->meta->get_attribute('bar')->description,
90 baz => 'Foo::bar::baz',
91 gorch => 'Foo::bar::gorch',
93 '... got the right class description'
96 my $bar_meta_desc = $foo->meta->get_attribute('bar')->metadescription;
97 is($bar_meta_desc->baz, 'Foo::bar::baz', '... we have methods');
98 is($bar_meta_desc->gorch, 'Foo::bar::gorch', '... we have methods');
101 $foo->meta->get_attribute('baz')->description,
103 bar => 'Foo::baz::bar',
104 gorch => 'Foo::baz::gorch',
106 '... got the right class description'
109 my $baz_meta_desc = $foo->meta->get_attribute('baz')->metadescription;
110 is($baz_meta_desc->bar, 'Foo::baz::bar', '... we have methods');
111 is($baz_meta_desc->gorch, 'Foo::baz::gorch', '... we have methods');