don't test private methods, but just what happens in each case
[gitmo/MooseX-Getopt.git] / t / 104_override_usage.t
1 use strict;
2 use warnings;
3
4 use Test::More tests => 5;
5 use Test::Trap;
6 use Test::NoWarnings 1.04 ':early';
7
8 {
9     package MyScript;
10     use Moose;
11
12     with 'MooseX::Getopt';
13
14     has foo => ( isa => 'Int', is => 'ro', documentation => 'A foo' );
15 }
16
17 # FIXME - it looks like we have a spacing issue in Getopt::Long?
18 my $usage = <<USAGE;
19 usage: 104_override_usage.t [-?h] [long options...]
20 \t-h -? --usage --help  Prints this usage information.
21 \t--foo                A foo
22 USAGE
23
24 {
25     local @ARGV = ('--foo', '1');
26     my $i = trap { MyScript->new_with_options };
27     is($i->foo, 1, 'attr is set');
28     is($trap->stdout, '', 'nothing printed when option is accepted');
29 }
30
31 {
32     local @ARGV = ('--help');
33     trap { MyScript->new_with_options };
34     is($trap->stdout, $usage, 'usage is printed on --help');
35 }
36
37 {
38     local @ARGV = ('-q'); # Does not exist
39     trap { MyScript->new_with_options };
40     is($trap->die, join("\n", 'Unknown option: q', $usage), 'usage is printed on unknown option');
41 }
42