summary refs log tree commit diff
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2009-05-30 11:32:44 +0200
committerfranck cuny <franck@lumberjaph.net>2009-05-30 11:32:44 +0200
commitd7bb51d41d3ae01438e2b510fe5f684915b2bb46 (patch)
tree80320115c08e039a160d77866cbaebf9d5d7ec13
parentimport (diff)
downloadcatalystx-dispatcher-asgraph-d7bb51d41d3ae01438e2b510fe5f684915b2bb46.tar.gz
add tests
-rw-r--r--bin/catalyst_graph_dispatcher.pl2
-rw-r--r--lib/CatalystX/Dispatcher/AsGraph.pm2
-rw-r--r--t/05_graph.t18
-rw-r--r--t/lib/TestApp.pm8
-rw-r--r--t/lib/TestApp/Controller/Root.pm16
5 files changed, 45 insertions, 1 deletions
diff --git a/bin/catalyst_graph_dispatcher.pl b/bin/catalyst_graph_dispatcher.pl
index e8fc5c1..6c550e4 100644
--- a/bin/catalyst_graph_dispatcher.pl
+++ b/bin/catalyst_graph_dispatcher.pl
@@ -1,10 +1,10 @@
 #!/usr/bin/perl -w
 use strict;
-use lib('/home/franck/code/git/CatalystX-Dispatcher-AsGraph/lib');
 use CatalystX::Dispatcher::AsGraph;
 
 my $graph = CatalystX::Dispatcher::AsGraph->new_with_options();
 $graph->run;
+
 if ( open( my $png, '|-', 'dot -Tpng -o ' . $graph->output ) ) {
     print $png $graph->graph->as_graphviz;
     close($png);
diff --git a/lib/CatalystX/Dispatcher/AsGraph.pm b/lib/CatalystX/Dispatcher/AsGraph.pm
index ceb372d..695d8ca 100644
--- a/lib/CatalystX/Dispatcher/AsGraph.pm
+++ b/lib/CatalystX/Dispatcher/AsGraph.pm
@@ -52,6 +52,8 @@ CatalystX::Dispatcher::AsGraph - Create a graph from Catalyst dispatcher
 CatalystX::Dispatcher::AsGraph create a graph for a Catalyst application
 using his dispatcher.
 
+At the time, only private actions are graphed.
+
 =head1 AUTHOR
 
 Franck Cuny E<lt>franck@lumberjaph.netE<gt>
diff --git a/t/05_graph.t b/t/05_graph.t
new file mode 100644
index 0000000..e995e75
--- /dev/null
+++ b/t/05_graph.t
@@ -0,0 +1,18 @@
+use strict;
+use warnings;
+use Test::More tests => 1;
+use lib ('t/lib');
+use CatalystX::Dispatcher::AsGraph;
+
+my $graph = CatalystX::Dispatcher::AsGraph->new(
+    appname => 'TestApp',
+    output  => 'test'
+);
+$graph->run;
+is $graph->graph->as_txt, <<'...';
+[ / ] --> [ \[action\] edit ]
+[ / ] --> [ \[action\] index ]
+[ / ] --> [ \[action\] root ]
+[ / ] --> [ \[action\] view ]
+[ / ] --> [ \[action\] view_user ]
+...
diff --git a/t/lib/TestApp.pm b/t/lib/TestApp.pm
new file mode 100644
index 0000000..49f7db5
--- /dev/null
+++ b/t/lib/TestApp.pm
@@ -0,0 +1,8 @@
+package TestApp;
+
+use Catalyst::Runtime '5.70';
+use parent 'Catalyst';
+
+__PACKAGE__->setup;
+
+1;
diff --git a/t/lib/TestApp/Controller/Root.pm b/t/lib/TestApp/Controller/Root.pm
new file mode 100644
index 0000000..0d44865
--- /dev/null
+++ b/t/lib/TestApp/Controller/Root.pm
@@ -0,0 +1,16 @@
+package TestApp::Controller::Root;
+use parent Catalyst::Controller;
+
+__PACKAGE__->config->{namespace} = '';
+
+sub root : Chained('/') PathPart() CaptureArgs(0) { }
+
+sub index : Chained('root') PathPart('') Args(0) { }
+
+sub view : Chained('root') PathPart('view') Args(1) { }
+
+sub view_user : Chained('root') PathPart('view/user') Args(1) { }
+
+sub edit : Chained('root') PathPart('edit') Args(1) { }
+
+1;