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');
24 package Foo::MetaDescription::Attribute;
27 extends 'MooseX::MetaDescription::Meta::Attribute';
29 sub prepare_traits_for_application {
30 my ($self, $traits) = @_;
31 [ map { "${_}::Description::Trait" } @$traits ]
40 metaclass => 'Foo::MetaDescription::Attribute',
43 default => sub { 'Foo::baz' },
46 bar => 'Foo::baz::bar',
47 gorch => 'Foo::baz::gorch',
54 my $baz_attr = Foo->meta->get_attribute('baz');
55 isa_ok($baz_attr->metadescription, 'MooseX::MetaDescription::Description');
56 does_ok($baz_attr->metadescription, 'Foo::Description::Trait');
57 is($baz_attr->metadescription->descriptor, $baz_attr, '... got the circular ref');
59 # check the actual descs
61 foreach my $foo ('Foo', Foo->new) {
64 $foo->meta->get_attribute('baz')->description,
66 bar => 'Foo::baz::bar',
67 gorch => 'Foo::baz::gorch',
69 '... got the right class description'
72 my $baz_meta_desc = $foo->meta->get_attribute('baz')->metadescription;
73 is($baz_meta_desc->bar, 'Foo::baz::bar', '... we have methods');
74 is($baz_meta_desc->gorch, 'Foo::baz::gorch', '... we have methods');