convert all uses of Test::Exception to Test::Fatal.
[gitmo/MooseX-Getopt.git] / t / 010_dashes.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 7;
7 use Test::Fatal;
8
9
10 BEGIN {
11     use_ok('MooseX::Getopt');
12 }
13
14 {
15     package App;
16     use Moose;
17
18     with 'MooseX::Getopt::Dashes';
19
20     has 'some_thingy' => ( is => 'ro', isa => 'Str', default => 'foo' );
21     has 'another_thingy'   => ( is => 'ro', isa => 'Str', default => 'foo', cmd_flag => 'another_thingy', traits => [ 'Getopt' ], );
22 }
23
24 {
25     local @ARGV = (qw/--some-thingy bar/);
26     ok ! exception { is( App->new_with_options->some_thingy, 'bar') }, 'Dash in option name';
27 }
28
29 {
30     local @ARGV = (qw/--some_thingy bar/);
31     like exception { App->new_with_options }, qr/Unknown option: some_thingy/;
32 }
33
34 {
35     local @ARGV = (qw/--another_thingy bar/);
36     ok ! exception { is( App->new_with_options->another_thingy, 'bar' ) }, 'Underscore in option name';
37 }
38
39 {
40     local @ARGV = (qw/--another-thingy bar/);
41     like exception { App->new_with_options }, qr/Unknown option: another-thingy/;
42 }