expose print_usage_text() as public method
[gitmo/MooseX-Getopt.git] / t / 104_override_usage.t
index 9820614..517d8aa 100644 (file)
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 5;
+use Test::More tests => 6;
 use Test::Trap;
 use Test::NoWarnings 1.04 ':early';
 
@@ -40,3 +40,19 @@ USAGE
     is($trap->die, join("\n", 'Unknown option: q', $usage), 'usage is printed on unknown option');
 }
 
+{
+    Class::MOP::class_of('MyScript')->add_before_method_modifier(
+        print_usage_text => sub {
+            print "--- DOCUMENTATION ---\n";
+        },
+    );
+
+    local @ARGV = ('--help');
+    trap { MyScript->new_with_options };
+    is(
+        $trap->stdout,
+        join("\n", '--- DOCUMENTATION ---', $usage),
+        'additional text included before normal usage string',
+    );
+}
+