~ubuntu-branches/debian/sid/libpod-readme-perl/sid

« back to all changes in this revision

Viewing changes to t/10-pod-readme-filter.t

  • Committer: Package Import Robot
  • Author(s): Lucas Kanashiro, Ansgar Burchardt, Salvatore Bonaccorso, gregor herrmann, Lucas Kanashiro
  • Date: 2015-07-26 17:45:04 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20150726174504-5haaxjsryb6wefgl
Tags: 1.1.2-1
* Team upload.

[ Ansgar Burchardt ]
* debian/control: Convert Vcs-* fields to Git.

[ Salvatore Bonaccorso ]
* debian/copyright: Replace DEP5 Format-Specification URL from
  svn.debian.org to anonscm.debian.org URL.
* Change Vcs-Git to canonical URI (git://anonscm.debian.org)
* Change search.cpan.org based URIs to metacpan.org based URIs

[ gregor herrmann ]
* Strip trailing slash from metacpan URLs.

[ Salvatore Bonaccorso ]
* Update Vcs-Browser URL to cgit web frontend

[ Lucas Kanashiro ]
* Add debian/upstream/metadata
* Import upstream version 1.1.2
* Update dependencies
* Add autopkgtest-pkg-perl
* Declare compliance with Debian policy 3.9.6
* Set debhelper >= 9
* Update date of upstream copyright and file structure
* Add patch fixing spelling error in manpages
* Remove comments from debian/watch
* Update long description
* Update upstream metadata

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
use strict;
 
2
use warnings;
 
3
 
 
4
use Test::More;
 
5
use Test::Deep;
 
6
use Test::Exception;
 
7
 
 
8
use Cwd;
 
9
use File::Compare qw/ compare_text /;
 
10
use File::Temp qw/ tempfile /;
 
11
use Path::Tiny qw/ path /;
 
12
 
 
13
use lib 't/lib';
 
14
use Pod::Readme::Test;
 
15
 
 
16
# use Pod::Readme::Test::Kit;
 
17
 
 
18
my $class = 'Pod::Readme::Filter';
 
19
use_ok $class;
 
20
 
 
21
isa_ok $prf = $class->new( output_fh => $io, ), 'Pod::Readme::Filter';
 
22
 
 
23
{
 
24
    can_ok( $prf, "cmd_" . $_ ) for qw/ stop start continue plugin /;
 
25
 
 
26
    ok $prf->in_target, 'default in target';
 
27
    is $prf->mode, 'default', 'mode';
 
28
 
 
29
    is $prf->base_dir->stringify, '.', 'base_dir';
 
30
}
 
31
 
 
32
{
 
33
    ok !$prf->cmd_stop,  'cmd_stop';
 
34
    ok !$prf->in_target, 'not in target';
 
35
 
 
36
    ok $prf->cmd_start, 'cmd_start';
 
37
    ok $prf->in_target, 'in target';
 
38
 
 
39
    ok !$prf->cmd_stop,  'cmd_stop';
 
40
    ok !$prf->in_target, 'not in target';
 
41
 
 
42
    ok $prf->cmd_continue, 'cmd_continue';
 
43
    ok $prf->in_target,    'in target';
 
44
};
 
45
 
 
46
{
 
47
    filter_lines('=pod');
 
48
    is $out, "=pod\n", 'expected output';
 
49
    is $prf->mode, 'pod', 'mode';
 
50
    ok $prf->in_target, 'in target';
 
51
    reset_out();
 
52
};
 
53
 
 
54
{
 
55
    filter_lines('=for readme stop');
 
56
    is $prf->mode, 'pod:for', 'mode';
 
57
 
 
58
    filter_lines('');
 
59
    is $prf->mode, 'pod', 'mode';
 
60
 
 
61
    is $out, '', 'no output';
 
62
    ok !$prf->in_target, 'not in target';
 
63
 
 
64
    filter_lines( 'This should not be copied.', '', 'Boop!', '' );
 
65
 
 
66
    is $out, '', 'no output';
 
67
 
 
68
    filter_lines('=for readme continue');
 
69
    is $prf->mode, 'pod:for', 'mode';
 
70
 
 
71
    filter_lines('');
 
72
    is $prf->mode, 'pod', 'mode';
 
73
    ok $prf->in_target, 'in target';
 
74
 
 
75
    is $out, '', 'no output';
 
76
};
 
77
 
 
78
{
 
79
    filter_lines('=for readme stop');
 
80
    is $prf->mode, 'pod:for', 'mode';
 
81
 
 
82
    filter_lines('');
 
83
    is $prf->mode, 'pod', 'mode';
 
84
 
 
85
    is $out, '', 'no output';
 
86
 
 
87
    ok !$prf->in_target, 'not in target';
 
88
 
 
89
    filter_lines( 'This should not be copied.', '', 'Boop!', '' );
 
90
 
 
91
    is $out, '', 'no output';
 
92
 
 
93
    filter_lines('=for readme start');
 
94
    is $prf->mode, 'pod:for', 'mode';
 
95
 
 
96
    filter_lines('');
 
97
    is $prf->mode, 'pod', 'mode';
 
98
    ok $prf->in_target, 'in target';
 
99
 
 
100
    is $out, '', 'no output';
 
101
};
 
102
 
 
103
{
 
104
    throws_ok {
 
105
        filter_lines('=for readme plugin noop::invalid');
 
106
        is $prf->mode, 'pod:for', 'mode';
 
107
        filter_lines('');
 
108
    }
 
109
    qr/Unable to locate plugin 'noop::invalid'/, 'bad plugin';
 
110
 
 
111
    is $prf->mode('pod'), 'pod', 'mode reset';
 
112
};
 
113
 
 
114
{
 
115
    filter_lines('=cut');
 
116
    is $prf->mode, 'default', 'default mode';
 
117
    filter_lines('');
 
118
 
 
119
    is $out, '', 'no content';
 
120
 
 
121
    filter_lines('=head1 TEST');
 
122
    is $prf->mode, 'pod', 'pod mode';
 
123
    filter_lines('');
 
124
 
 
125
    is $out, "=head1 TEST\n\n", 'expected content';
 
126
    reset_out();
 
127
};
 
128
 
 
129
{
 
130
    filter_lines( "This should be copied.", '' );
 
131
 
 
132
    is $out, "This should be copied.\n\n", 'output';
 
133
    reset_out();
 
134
};
 
135
 
 
136
{
 
137
    filter_lines('=begin text');
 
138
    is $prf->mode, 'target:text', 'mode';
 
139
    filter_lines( '', 'Something', '', '=end text', '' );
 
140
    is $out, '', 'no content';
 
141
    reset_out();
 
142
}
 
143
 
 
144
{
 
145
    filter_lines('=begin readme');
 
146
    is $prf->mode, 'pod:begin', 'mode';
 
147
    filter_lines( '', 'Something', '', '=end readme', '' );
 
148
 
 
149
    like $out, qr/^Something\n/, 'expected content (minimal)';
 
150
  TODO: {
 
151
        local $TODO = 'extra newline';
 
152
        is $out, "Something\n", 'expected content';
 
153
    }
 
154
    reset_out();
 
155
}
 
156
 
 
157
{
 
158
    filter_lines('=begin readme text');
 
159
    is $prf->mode, 'pod:begin', 'mode';
 
160
    filter_lines( '', 'Something', '', '=end readme', '' );
 
161
 
 
162
  TODO: {
 
163
        is $out, "=begin text\n\nSomething\n\n=end text\n\n",
 
164
          'expected content';
 
165
    }
 
166
    reset_out();
 
167
}
 
168
 
 
169
{
 
170
    filter_lines('=begin :readme');
 
171
    is $prf->mode, 'pod:begin', 'mode';
 
172
    filter_lines( '', 'Something', '', '=end :readme', '' );
 
173
 
 
174
    like $out, qr/^Something\n/, 'expected content (minimal)';
 
175
  TODO: {
 
176
        local $TODO = 'extra newline';
 
177
        is $out, "Something\n", 'expected content';
 
178
    }
 
179
    reset_out();
 
180
}
 
181
 
 
182
{
 
183
    can_ok $prf, qw/ parse_cmd_args /;
 
184
 
 
185
    lives_ok {
 
186
        my $res = $prf->parse_cmd_args( undef, 'arg1', 'no-arg2',
 
187
            'arg3="This is a string"', 'arg4=value', );
 
188
 
 
189
        note( explain $res);
 
190
 
 
191
        is_deeply $res,
 
192
          {
 
193
            'arg1' => 1,
 
194
            'arg2' => 0,
 
195
            'arg3' => 'This is a string',
 
196
            'arg4' => 'value'
 
197
          },
 
198
          'expected parsing of arguments list';
 
199
 
 
200
    }
 
201
    'parse_cmd_args';
 
202
 
 
203
    throws_ok {
 
204
        my $res =
 
205
          $prf->parse_cmd_args( [qw/ arg1 arg2 arg3 /], 'arg1', 'no-arg2',
 
206
            'arg3="This is a string"', 'arg4=value', );
 
207
    }
 
208
    qr/Invalid argument key 'arg4'/, 'bad arguments';
 
209
 
 
210
}
 
211
 
 
212
{
 
213
    can_ok $prf, qw/ depends_on /;
 
214
    is_deeply [ $prf->depends_on ], [], 'depends_on';
 
215
}
 
216
 
 
217
done_testing;