From: Karen Etheridge Date: Sat, 14 Apr 2012 17:00:35 +0000 (-0700) Subject: Stay out of the guts of Getopt::Long::Descriptive::Usage when testing its text X-Git-Tag: v0.42~13 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3aaa34a1cf97648e9704fc9c73abc4ebd8f90b39;p=gitmo%2FMooseX-Getopt.git Stay out of the guts of Getopt::Long::Descriptive::Usage when testing its text --- diff --git a/t/109_help_flag.t b/t/109_help_flag.t index 70a95ab..580884e 100644 --- a/t/109_help_flag.t +++ b/t/109_help_flag.t @@ -35,17 +35,18 @@ use Test::Fatal; #usage: test1.t [-?] [long options...] # -? --usage --help Prints this usage information. +my $obj = MyClass->new_with_options; +ok($obj->meta->has_attribute('usage'), 'class has usage attribute'); +isa_ok($obj->usage, 'Getopt::Long::Descriptive::Usage'); +my $usage_text = $obj->usage->text; + foreach my $args ( ['--help'], ['--usage'], ['--?'], ['-?'] ) { local @ARGV = @$args; - like exception { MyClass->new_with_options() }, - qr/^usage: (?:[\d\w]+)\Q.t [-?] [long options...]\E.^\t\Q-? --usage --help Prints this usage information.\E$/ms, + is exception { MyClass->new_with_options() }, + $usage_text, 'Help request detected; usage information properly printed'; } -# now call again, and ensure we got the usage info. -my $obj = MyClass->new_with_options(); -ok($obj->meta->has_attribute('usage'), 'class has usage attribute'); -isa_ok($obj->usage, 'Getopt::Long::Descriptive::Usage');