Pod-Site

 view release on metacpan or  search on metacpan

t/config.t  view on Meta::CPAN

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
    main_module     => undef,
    versioned_title => undef,
    replace_css     => undef,
    replace_js      => undef,
    label           => undef,
    man             => undef,
    help            => undef,
);
 
DEFAULTS: {
    local @ARGV = ('--doc-root', $doc_root, '--base-uri', $base_uri, $mod_root );
    is_deeply $CLASS->_config, \%config, 'Should have default config';
}
 
ERRS: {
    my $mock = Test::MockModule->new($CLASS);
    my @args;
    $mock->mock(_pod2usage => sub { @args = @_} );
    local @ARGV = ($mod_root);
    ok $CLASS->_config, 'configure with no options';
    is_deeply \@args, [
        $CLASS,
        '-message', 'Missing required --doc-root and --base-uri options',
    ], 'Should have been helped';
 
    @ARGV = ('--doc-root', $doc_root, $mod_root);
    ok $CLASS->_config, 'configure with no --base_uri';
    is_deeply \@args, [
        $CLASS,

t/config.t  view on Meta::CPAN

73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
    @ARGV = ('--doc-root', $doc_root, '--base-uri', $base_uri);
    ok $CLASS->_config, 'configure with no module root';
    is_deeply \@args, [
        $CLASS,
        '-message', 'Missing path to module root',
    ], 'Should have been helped again';
}
 
MULTIPLES: {
    local @ARGV = (
        '--doc-root' => $doc_root,
        '--base-uri' => $base_uri,
        '--base-uri' => '/whatever',
        $mod_root, '/another/root'
    );
    local $config{base_uri} = [ $base_uri, '/whatever/' ];
    local $config{module_roots} = [ $mod_root, '/another/root' ];
    is_deeply $CLASS->_config, \%config, 'Allow multiple --base-uri';
}
 
HELP: {
    my $mock = Test::MockModule->new($CLASS);
    my @args;
    $mock->mock(_pod2usage => sub { @args = @_} );
    local @ARGV = ('--doc-root', $doc_root, '--base-uri', $base_uri, $mod_root, '--help' );
    ok $CLASS->_config, 'Ask for help';
    is_deeply \@args, [ $CLASS, '-exitval', 0 ], 'Should have been helped';
    @ARGV = ('--doc-root', $doc_root, '--base-uri', $base_uri, $mod_root, '-h' );
    ok $CLASS->_config, 'Ask for help short';
    is_deeply \@args, [ $CLASS, '-exitval', 0 ], 'Should have been helped again';
 
    @ARGV = ('--doc-root', $doc_root, '--base-uri', $base_uri, $mod_root, '--man' );
    ok $CLASS->_config, 'Ask for man';
    is_deeply \@args, [ $CLASS, '-sections', '.+', '-exitval', 0 ],
        'Should have been manned';
    @ARGV = ('--doc-root', $doc_root, '--base-uri', $base_uri, $mod_root, '-M' );
    ok $CLASS->_config, 'Ask for man short';
    is_deeply \@args, [ $CLASS, '-sections', '.+', '-exitval', 0 ],
        'Should have been manned again';
}
 
LOTS: {
    local @ARGV = (
        '--doc-root'      => $doc_root,
        '--base-uri'      => $base_uri,
        '--favicon-uri'   => 'my.icon',
        '--sample-module' => 'lib/Hello.pm',
        '--main-module'   => 'lib/Bye.pm',
        '--index-file'    => 'default.htm',
        '--css-path'      => '/some/file.css',
        '--js-path'       => '/some/file.js',
        '--name'          => 'Eat me',
        '--label'         => 'API Browser',

t/config.t  view on Meta::CPAN

147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
        label           => 'API Browser',
        versioned_title => 1,
        replace_css     => 1,
        replace_js      => 1,
        man             => undef,
        help            => undef,
    }, 'Lots of opts should work';
}
 
SHORT: {
    local @ARGV = (
        '-d' => $doc_root,
        '-u' => $base_uri,
        '-s' => 'lib/Hello.pm',
        '-m' => 'lib/Bye.pm',
        '-i' => 'default.htm',
        '-c' => '/some/file.css',
        '-j' => '/some/file.js',
        '-n' => 'Eat me',
        '-l' => 'API Browser',
        '-t',

t/config.t  view on Meta::CPAN

186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
        versioned_title => 1,
        replace_css     => undef,
        replace_js      => undef,
        man             => undef,
        help            => undef,
    }, 'Lots of short opts should work';
 
}
 
NEGATED: {
    local @ARGV = (
        '--doc-root'      => $doc_root,
        '--base-uri'      => $base_uri,
        '--no-versioned-title',
        $mod_root,
    );
    is_deeply $CLASS->_config, {
        %config,
        versioned_title => 0,
    }, 'Negated opts should work';
}



( run in 0.230 second using v1.01-cache-2.11-cpan-55f5a4728d2 )