Commit | Line | Data |
3890b670 |
1 | #!/usr/bin/perl -w |
2 | |
3 | use strict; |
4 | use warnings; |
5 | use MooseX::AutoDoc; |
6 | use FindBin '$Bin'; |
7 | use lib "$Bin/lib"; |
8 | |
9 | use Test::More tests => 7; |
10 | use AutoDocTest1; |
11 | |
12 | my $autodoc = MooseX::AutoDoc->new; |
13 | my $meta = AutoDocTest1->meta; |
14 | my %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 | |
ec75fdb0 |
26 | my $spec = $autodoc->_attribute_info($attributes{attr1}); |
3890b670 |
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 | |
ec75fdb0 |
40 | my $spec = $autodoc->_attribute_info($attributes{attr2}); |
3890b670 |
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 | |
ec75fdb0 |
54 | my $spec = $autodoc->_attribute_info($attributes{attr3}); |
3890b670 |
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 | |
ec75fdb0 |
68 | my $spec = $autodoc->_attribute_info($attributes{attr4}); |
3890b670 |
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 | |
ec75fdb0 |
82 | my $spec = $autodoc->_attribute_info($attributes{attr5}); |
3890b670 |
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', |
f58eb320 |
97 | 'description' => 'Optional read-write lazy-building value' |
3890b670 |
98 | }; |
99 | |
ec75fdb0 |
100 | my $spec = $autodoc->_attribute_info($attributes{attr6}); |
3890b670 |
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 | |
ec75fdb0 |
118 | my $spec = $autodoc->_attribute_info($attributes{attr7}); |
3890b670 |
119 | |
120 | is_deeply($spec, $target); |
121 | } |