add MX::Getopt scheme
[gitmo/MooseX-Runnable.git] / t / basic-mx-getopt.t
diff --git a/t/basic-mx-getopt.t b/t/basic-mx-getopt.t
new file mode 100644 (file)
index 0000000..6bafdb9
--- /dev/null
@@ -0,0 +1,41 @@
+use strict;
+use warnings;
+use Test::Exception;
+use Test::More tests => 5;
+
+use MooseX::Runnable::Invocation;
+use ok 'MooseX::Runnable::Invocation::Scheme::MooseX::Getopt';
+
+my $foo;
+
+{ package Class;
+  use Moose;
+  with 'MooseX::Runnable', 'MooseX::Getopt';
+
+  has 'foo' => (
+      is       => 'ro',
+      isa      => 'Str',
+      required => 1,
+  );
+
+  sub run {
+      my ($self, $code) = @_;
+      $foo = $self->foo;
+      return $code;
+  }
+}
+
+my $invocation = MooseX::Runnable::Invocation->new(
+    class => 'Class',
+);
+
+ok $invocation;
+
+my $code;
+lives_ok {
+    $code = $invocation->run('--foo', '42', 0);
+} 'run lived';
+
+is $foo, '42', 'got foo from cmdline';
+
+is $code, 0, 'exit status ok';