6 use Test::More no_plan => 1;
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'
32 package Foo::MetaDescription::Attribute;
35 extends 'MooseX::MetaDescription::Meta::Attribute';
36 with 'Foo::MetaDescription::Trait';
38 has '+metadescription_classname' => (
39 default => 'Foo::Description'
48 metaclass => 'Foo::MetaDescription::Attribute',
51 default => sub { 'Foo::bar' },
53 baz => 'Foo::bar::baz',
54 gorch => 'Foo::bar::gorch',
59 traits => [ 'Foo::MetaDescription::Trait' ],
62 default => sub { 'Foo::baz' },
64 bar => 'Foo::baz::bar',
65 gorch => 'Foo::baz::gorch',
72 my $bar_attr = Foo->meta->get_attribute('bar');
73 isa_ok($bar_attr->metadescription, 'MooseX::MetaDescription::Description');
74 isa_ok($bar_attr->metadescription, 'Foo::Description');
75 is($bar_attr->metadescription->descriptor, $bar_attr, '... got the circular ref');
77 my $baz_attr = Foo->meta->get_attribute('baz');
78 isa_ok($baz_attr->metadescription, 'MooseX::MetaDescription::Description');
79 isa_ok($baz_attr->metadescription, 'Foo::Description');
80 is($baz_attr->metadescription->descriptor, $baz_attr, '... got the circular ref');
82 # check the actual descs
84 foreach my $foo ('Foo', Foo->new) {
87 $foo->meta->get_attribute('bar')->description,
89 baz => 'Foo::bar::baz',
90 gorch => 'Foo::bar::gorch',
92 '... got the right class description'
95 my $bar_meta_desc = $foo->meta->get_attribute('bar')->metadescription;
96 is($bar_meta_desc->baz, 'Foo::bar::baz', '... we have methods');
97 is($bar_meta_desc->gorch, 'Foo::bar::gorch', '... we have methods');
100 $foo->meta->get_attribute('baz')->description,
102 bar => 'Foo::baz::bar',
103 gorch => 'Foo::baz::gorch',
105 '... got the right class description'
108 my $baz_meta_desc = $foo->meta->get_attribute('baz')->metadescription;
109 is($baz_meta_desc->bar, 'Foo::baz::bar', '... we have methods');
110 is($baz_meta_desc->gorch, 'Foo::baz::gorch', '... we have methods');