Commit | Line | Data |
2828ce0c |
1 | use strict; |
2 | use warnings; |
3 | use Test::Exception; |
4 | use Test::More tests => 4; |
5 | |
6 | use MooseX::Runnable::Invocation; |
7 | |
8 | my $initargs; |
9 | |
10 | { package Class; |
11 | use Moose; |
12 | with 'MooseX::Runnable'; |
13 | sub run { 42 } |
14 | } |
15 | |
16 | { package Plugin; |
17 | use Moose::Role; |
18 | with 'MooseX::Runnable::Invocation::Plugin::Role::CmdlineArgs'; |
19 | |
20 | has 'init' => ( is => 'ro', required => 1 ); |
21 | |
22 | sub _build_initargs_from_cmdline { |
23 | my $class = shift; |
24 | $initargs = join ',', @_; |
25 | return { init => 'args' }; |
26 | } |
27 | } |
28 | |
29 | my $i; |
30 | lives_ok { |
31 | $i = MooseX::Runnable::Invocation->new( |
32 | class => 'Class', |
33 | plugins => { |
34 | '+Plugin' => [qw/foo bar baz/], |
35 | }, |
36 | ); |
37 | } 'created invocation without dying'; |
38 | |
39 | ok $i, 'created invocation ok'; |
40 | ok $i->run, 'ran ok'; |
41 | is $initargs, 'foo,bar,baz', 'got initargs'; |
42 | |
43 | |
44 | |