Basic tests for ScriptRunner, more needed
Tomas Doran [Sat, 5 Sep 2009 15:16:48 +0000 (15:16 +0000)]
TODO.scripts
t/lib/Catalyst/Script/Bar.pm [new file with mode: 0644]
t/lib/Catalyst/Script/Baz.pm [new file with mode: 0644]
t/lib/ScriptTestApp/Script/Bar.pm [new file with mode: 0644]
t/lib/ScriptTestApp/Script/Foo.pm [new file with mode: 0644]
t/unit_core_scriptrunner.t [new file with mode: 0644]

index b178ccf..f6a69c0 100644 (file)
@@ -1,5 +1,6 @@
 * Fix the fucking help to be consistent again!
 * Documentation
 * Proper test of all the options on all the scripts
-* Tests for ScriptRunner
+* ScriptRunner tests for MyApp::Script::DoesNotCompile
+
 * Tests for Scripts / Role
diff --git a/t/lib/Catalyst/Script/Bar.pm b/t/lib/Catalyst/Script/Bar.pm
new file mode 100644 (file)
index 0000000..18e699c
--- /dev/null
@@ -0,0 +1,9 @@
+package Catalyst::Script::Bar;
+use Moose;
+use namespace::autoclean;
+
+with 'Catalyst::ScriptRole';
+
+sub run { __PACKAGE__ }
+
+1;
diff --git a/t/lib/Catalyst/Script/Baz.pm b/t/lib/Catalyst/Script/Baz.pm
new file mode 100644 (file)
index 0000000..d699fe6
--- /dev/null
@@ -0,0 +1,16 @@
+package Catalyst::Script::Baz;
+use Moose;
+use namespace::autoclean;
+
+use Test::More;
+
+with 'Catalyst::ScriptRole';
+
+sub run { __PACKAGE__ }
+
+after new_with_options => sub {
+    my ($self, %args) = @_;
+    is_deeply \%args, { application_name => 'ScriptTestApp' }, 'App name correct';
+};
+
+1;
diff --git a/t/lib/ScriptTestApp/Script/Bar.pm b/t/lib/ScriptTestApp/Script/Bar.pm
new file mode 100644 (file)
index 0000000..1d01fad
--- /dev/null
@@ -0,0 +1,9 @@
+package ScriptTestApp::Script::Bar;
+use Moose;
+use namespace::autoclean;
+
+with 'Catalyst::ScriptRole';
+
+sub run { __PACKAGE__ }
+
+1;
\ No newline at end of file
diff --git a/t/lib/ScriptTestApp/Script/Foo.pm b/t/lib/ScriptTestApp/Script/Foo.pm
new file mode 100644 (file)
index 0000000..8d61c63
--- /dev/null
@@ -0,0 +1,9 @@
+package ScriptTestApp::Script::Foo;
+use Moose;
+use namespace::autoclean;
+
+with 'Catalyst::ScriptRole';
+
+sub run { __PACKAGE__ }
+
+1;
diff --git a/t/unit_core_scriptrunner.t b/t/unit_core_scriptrunner.t
new file mode 100644 (file)
index 0000000..b87afeb
--- /dev/null
@@ -0,0 +1,16 @@
+use strict;
+use warnings;
+use Test::More tests => 5;
+use FindBin qw/$Bin/;
+use lib "$Bin/lib";
+
+use_ok('Catalyst::ScriptRunner');
+
+is Catalyst::ScriptRunner->run('ScriptTestApp', 'Foo'), 'ScriptTestApp::Script::Foo',
+    'Script existing only in app';
+is Catalyst::ScriptRunner->run('ScriptTestApp', 'Bar'), 'ScriptTestApp::Script::Bar',
+    'Script existing in both app and Catalyst - prefers app';
+is Catalyst::ScriptRunner->run('ScriptTestApp', 'Baz'), 'Catalyst::Script::Baz',
+    'Script existing only in Catalyst';
+# +1 test for the params passed to new_with_options in t/lib/Catalyst/Script/Baz.pm
+