Commit | Line | Data |
780724cb |
1 | use strict; |
2 | use warnings; |
3 | use Test::Exception; |
4 | use Test::More tests => 5; |
5 | |
6 | use MooseX::Runnable::Invocation; |
7 | use ok 'MooseX::Runnable::Invocation::Scheme::MooseX::Getopt'; |
8 | |
9 | my $foo; |
10 | |
11 | { package Class; |
12 | use Moose; |
13 | with 'MooseX::Runnable', 'MooseX::Getopt'; |
14 | |
15 | has 'foo' => ( |
16 | is => 'ro', |
17 | isa => 'Str', |
18 | required => 1, |
19 | ); |
20 | |
21 | sub run { |
22 | my ($self, $code) = @_; |
23 | $foo = $self->foo; |
24 | return $code; |
25 | } |
26 | } |
27 | |
28 | my $invocation = MooseX::Runnable::Invocation->new( |
29 | class => 'Class', |
30 | ); |
31 | |
32 | ok $invocation; |
33 | |
34 | my $code; |
35 | lives_ok { |
36 | $code = $invocation->run('--foo', '42', 0); |
37 | } 'run lived'; |
38 | |
39 | is $foo, '42', 'got foo from cmdline'; |
40 | |
41 | is $code, 0, 'exit status ok'; |