X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F104_override_usage.t;h=8e7a1ff842d173694ae4a2453a51d1c394940fce;hb=c885acae4797dc3ce50e91445ceb96c971e87671;hp=173c632c932bfb8bf420d7bf0595ab6f71b81952;hpb=9b7f80a24b181933ad2cb3242f14b366b2d45ec1;p=gitmo%2FMooseX-Getopt.git diff --git a/t/104_override_usage.t b/t/104_override_usage.t index 173c632..8e7a1ff 100644 --- a/t/104_override_usage.t +++ b/t/104_override_usage.t @@ -1,7 +1,7 @@ use strict; use warnings; use Test::More 0.88; -use Test::Exception; +use Test::Trap; { package MyScript; @@ -10,7 +10,6 @@ use Test::Exception; with 'MooseX::Getopt'; has foo => ( isa => 'Int', is => 'ro', documentation => 'A foo' ); - has help => ( isa => 'Bool', is => 'ro', default => 0, documentation => 'Help'); our $usage = 0; before _getopt_full_usage => sub { $usage++; }; @@ -30,13 +29,15 @@ use Test::Exception; { local $MyScript::usage; local @MyScript::warnings; local @MyScript::exception; local @ARGV = ('--help'); - throws_ok { MyScript->new_with_options } qr/A foo/; + trap { MyScript->new_with_options }; + like($trap->stdout, qr/A foo/); is $MyScript::usage, 1; } { local $MyScript::usage; local @MyScript::warnings; local @MyScript::exception; local @ARGV = ('-q'); # Does not exist - throws_ok { MyScript->new_with_options } qr/A foo/; + trap { MyScript->new_with_options }; + like($trap->die, qr/A foo/); is_deeply \@MyScript::warnings, [ 'Unknown option: q ' @@ -44,9 +45,9 @@ use Test::Exception; my $exp = [ 'Unknown option: q ', - qq{usage: 104_override_usage.t [long options...] -\t--help Help -\t--foo A foo + qq{usage: 104_override_usage.t [-?] [long options...] +\t-? --usage --help Prints this usage information. +\t--foo A foo } ];