MooseX::Getopt::Dashes: Document how ::Dashes interacts with the cmd_flag argument
[gitmo/MooseX-Getopt.git] / t / 010_dashes.t
index 4ec1248..2927dae 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 3;
+use Test::More tests => 5;
 
 use Test::Exception;
 
@@ -19,14 +19,25 @@ BEGIN {
        with 'MooseX::Getopt::Dashes';
 
        has 'some_thingy' => ( is => 'ro', isa => 'Str', default => 'foo' );
+       has 'another_thingy'   => ( is => 'ro', isa => 'Str', default => 'foo', cmd_flag => 'another_thingy', traits => [ 'Getopt' ], );
 }
 
 {
        local @ARGV = (qw/--some-thingy bar/);
-    lives_and { is( App->new_with_options->some_thingy, 'bar') } 'Dash in option name';
+       lives_and { is( App->new_with_options->some_thingy, 'bar') } 'Dash in option name';
 }
 
 {
-    local @ARGV = (qw/--some_thingy bar/);
-    throws_ok { App->new_with_options } qr/Unknown option: some_thingy/;
+       local @ARGV = (qw/--some_thingy bar/);
+       throws_ok { App->new_with_options } qr/Unknown option: some_thingy/;
+}
+
+{
+       local @ARGV = (qw/--another_thingy bar/);
+       lives_and { is( App->new_with_options->another_thingy, 'bar' ) } 'Underscore in option name';
+}
+
+{
+       local @ARGV = (qw/--another-thingy bar/);
+       throws_ok { App->new_with_options } qr/Unknown option: another-thingy/;
 }