I forgot about init_arg oops
[gitmo/MooseX-AutoDoc.git] / t / 002-attributes.t
CommitLineData
3890b670 1#!/usr/bin/perl -w
2
3use strict;
4use warnings;
5use MooseX::AutoDoc;
6use FindBin '$Bin';
7use lib "$Bin/lib";
8
9use Test::More tests => 7;
10use AutoDocTest1;
11
12my $autodoc = MooseX::AutoDoc->new;
13my $meta = AutoDocTest1->meta;
14my %attributes = map { $_ => $meta->get_attribute($_) }
15 $meta->get_attribute_list;
16
17#attr 1
18{
19 my $target =
20 {
21 name => 'attr1',
22 info => {},
23 description => 'Optional read-only value'
24 };
25
26 my $spec = $autodoc->attribute_info($attributes{attr1});
27
28 is_deeply($spec, $target);
29}
30
31#attr 2
32{
33 my $target =
34 {
35 name => 'attr2',
36 info => {},
37 description => 'Optional read-write value of type L<HashRef|Moose::Util::TypeConstraints>'
38 };
39
40 my $spec = $autodoc->attribute_info($attributes{attr2});
41
42 is_deeply($spec, $target);
43}
44
45#attr 3
46{
47 my $target =
48 {
49 'info' => {},
50 'name' => 'attr3',
51 'description' => 'Optional read-write value of type L<ArrayRef[Str]|Moose::Util::TypeConstraints>'
52 };
53
54 my $spec = $autodoc->attribute_info($attributes{attr3});
55
56 is_deeply($spec, $target);
57}
58
59#attr 4
60{
61 my $target =
62 {
63 'info' => {},
64 'name' => 'attr4',
65 'description' => 'Required read-write value of type L<ArrayRef[Str]|Moose::Util::TypeConstraints>'
66 };
67
68 my $spec = $autodoc->attribute_info($attributes{attr4});
69
70 is_deeply($spec, $target);
71}
72
73#attr 5
74{
75 my $target =
76 {
77 'info' => {},
78 'name' => 'attr5',
79 'description' => 'Required read-write value of type L<ArrayRef[Str]|Moose::Util::TypeConstraints> that will be automatically dereferenced by the reader / accessor'
80 };
81
82 my $spec = $autodoc->attribute_info($attributes{attr5});
83
84 is_deeply($spec, $target);
85}
86
87#attr 6
88{
89 my $target =
90 {
91 'info' => {
92 'predicate' => 'has_attr6',
93 'builder' => '_build_attr6',
94 'clearer' => 'clear_attr6'
95 },
96 'name' => 'attr6',
97 'description' => 'Required read-write lazy-building value'
98 };
99
100 my $spec = $autodoc->attribute_info($attributes{attr6});
101
102 is_deeply($spec, $target);
103}
104
105#attr 7
106{
107 my $target =
108 {
109 'info' => {
110 'reader' => 'attr7',
a8676f0f 111 'writer' => '_attr7',
112 'constructor key' => '-attr7',
3890b670 113 },
114 'name' => 'attr7',
115 'description' => 'Optional value'
116 };
117
118 my $spec = $autodoc->attribute_info($attributes{attr7});
119
120 is_deeply($spec, $target);
121}