edit .gitignore
[gitmo/MooseX-Runnable.git] / t / basic-mx-getopt.t
CommitLineData
780724cb 1use strict;
2use warnings;
3use Test::Exception;
4use Test::More tests => 5;
5
6use MooseX::Runnable::Invocation;
7use ok 'MooseX::Runnable::Invocation::Scheme::MooseX::Getopt';
8
9my $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
28my $invocation = MooseX::Runnable::Invocation->new(
29 class => 'Class',
30);
31
32ok $invocation;
33
34my $code;
35lives_ok {
36 $code = $invocation->run('--foo', '42', 0);
37} 'run lived';
38
39is $foo, '42', 'got foo from cmdline';
40
41is $code, 0, 'exit status ok';