Skip to content

Commit

Permalink
added help tests
Browse files Browse the repository at this point in the history
  • Loading branch information
barbie committed Sep 13, 2014
1 parent c556c31 commit 3fe92d8
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -3,6 +3,7 @@ Revision history for CPAN-Testers-Data-Addresses

- fixed skip numbers.
- added version option.
- added help tests.

0.13 2014-09-10
- fixed license fields in META.json to be lists.
Expand Down
1 change: 1 addition & 0 deletions MANIFEST
Expand Up @@ -24,6 +24,7 @@ t/23clean.t
t/24backups.t
t/25updates.t
t/26search.t
t/27help.t
t/50logging.t
t/59cleanup.t
t/90podtest.t
Expand Down
51 changes: 51 additions & 0 deletions t/27help.t
@@ -0,0 +1,51 @@
#!/usr/bin/perl -w
use strict;

use Test::More tests => 10;
use Test::Trap;

{
use CPAN::Testers::Data::Addresses;

my $VERSION = '0.14';

my $obj;
my $stdout;
my $config = 't/20attributes.ini';

{
trap { $obj = CPAN::Testers::Data::Addresses->new() };

like($trap->stdout,qr/Must specify the configuration file/,'.. no file name');
like($trap->stdout,qr/Usage:.*--config|c=<file>/,'.. got help');
}

{
trap { $obj = CPAN::Testers::Data::Addresses->new( config => 'bogus.file' ) };

like($trap->stdout,qr/Configuration file .*? not found/,'.. no file found');
like($trap->stdout,qr/Usage:.*--config|c=<file>/,'.. got help');
}

{
trap { $obj = CPAN::Testers::Data::Addresses->new( config => $config, help => 1 ) };

like($trap->stdout,qr/Usage:.*--config|c=<file>/,'.. got help');
like($trap->stdout,qr/$0 v$VERSION/,'.. got version');
}

{
trap { $obj = CPAN::Testers::Data::Addresses->new( config => $config, version => 1 ) };

unlike($trap->stdout,qr/Usage:.*--config|c=<file>/,'.. no help');
like($trap->stdout,qr/$0 v$VERSION/,'.. got version');
}

{
unshift @ARGV, '--help';
trap { $obj = CPAN::Testers::Data::Addresses->new( config => $config ) };

like($trap->stdout,qr/Usage:.*--config|c=<file>/,'.. got help');
like($trap->stdout,qr/$0 v$VERSION/,'.. got version');
}
}

0 comments on commit 3fe92d8

Please sign in to comment.