X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F104_override_usage.t;h=091b47bbfafaeaec0c08380cb8bbd95c385af042;hb=aec092482d5b90b8279e4a5f92165868a78ddf32;hp=517d8aa4323a5780e2c7b8f10977c22cef7ea68b;hpb=83446b781bbe89f41f87f2c03f07065bda919f43;p=gitmo%2FMooseX-Getopt.git diff --git a/t/104_override_usage.t b/t/104_override_usage.t index 517d8aa..091b47b 100644 --- a/t/104_override_usage.t +++ b/t/104_override_usage.t @@ -1,7 +1,7 @@ use strict; -use warnings; +use warnings FATAL => 'all'; -use Test::More tests => 6; +use Test::More tests => 7; use Test::Trap; use Test::NoWarnings 1.04 ':early'; @@ -56,3 +56,30 @@ USAGE ); } +{ + package MyScript2; + use Moose; + + with 'MooseX::Getopt'; + has foo => ( isa => 'Int', is => 'ro', documentation => 'A foo' ); +} + +{ + # some classes (e.g. ether's darkpan and Catalyst::Runtime) overrode + # _getopt_full_usage, so we need to keep it in the call stack so we don't + # break them. + Class::MOP::class_of('MyScript2')->add_before_method_modifier( + _getopt_full_usage => sub { + print "--- DOCUMENTATION ---\n"; + }, + ); + + local @ARGV = ('--help'); + trap { MyScript2->new_with_options }; + is( + $trap->stdout, + join("\n", '--- DOCUMENTATION ---', $usage), + 'additional text included before normal usage string', + ); +} +