Rip the testapp embedded in the test out, this isn't supported and doesn't work for me
t0m [Mon, 29 Jun 2009 21:29:23 +0000 (22:29 +0100)]
t/catalyst-action-rest.t
t/lib/Test/Catalyst/Action/REST/Controller/Root.pm [new file with mode: 0644]

index b65fa1f..535ac4e 100644 (file)
@@ -1,104 +1,3 @@
-package Test::Catalyst::Action::REST;
-
-use FindBin;
-
-use lib ("$FindBin::Bin/../lib");
-
-use strict;
-use warnings;
-
-use Catalyst::Runtime '5.70';
-
-use Catalyst;
-
-__PACKAGE__->config( name => 'Test::Catalyst::Action::REST' );
-__PACKAGE__->setup;
-
-sub test : Local : ActionClass('REST') {
-    my ( $self, $c ) = @_;
-    $c->stash->{'entity'} = 'something';
-}
-
-sub test_GET : Local : ActionClass('REST') {
-    my ( $self, $c ) = @_;
-
-    $c->stash->{'entity'} .= " GET";
-    $c->forward('ok');
-}
-
-sub test_POST : Local : ActionClass('REST') {
-    my ( $self, $c ) = @_;
-
-    $c->stash->{'entity'} .= " POST";
-    $c->forward('ok');
-}
-
-sub test_PUT : Local : ActionClass('REST') {
-    my ( $self, $c ) = @_;
-
-    $c->stash->{'entity'} .= " PUT";
-    $c->forward('ok');
-}
-
-sub test_DELETE : Local : ActionClass('REST') {
-    my ( $self, $c ) = @_;
-
-    $c->stash->{'entity'} .= " DELETE";
-    $c->forward('ok');
-}
-
-sub test_OPTIONS : Local : ActionClass('REST') {
-    my ( $self, $c ) = @_;
-
-    $c->stash->{'entity'} .= " OPTIONS";
-    $c->forward('ok');
-}
-
-sub notreally : Local : ActionClass('REST') {
-}
-
-sub notreally_GET {
-    my ( $self, $c ) = @_;
-
-    $c->stash->{'entity'} = "notreally GET";
-    $c->forward('ok');
-}
-
-sub not_implemented : Local : ActionClass('REST') {
-}
-
-sub not_implemented_GET {
-    my ( $self, $c ) = @_;
-
-    $c->stash->{'entity'} = "not_implemented GET";
-    $c->forward('ok');
-}
-
-sub not_implemented_not_implemented {
-    my ( $self, $c ) = @_;
-
-    $c->stash->{'entity'} = "Not Implemented Handler";
-    $c->forward('ok');
-}
-
-sub not_modified : Local : ActionClass('REST') { }
-
-sub not_modified_GET {
-    my ( $self, $c ) = @_;
-    $c->res->status(304);
-    return 1;
-}
-
-
-sub ok : Private {
-    my ( $self, $c ) = @_;
-
-    $c->res->content_type('text/plain');
-    $c->res->body( $c->stash->{'entity'} );
-}
-
-package main;
-
 use strict;
 use warnings;
 use Test::More tests => 18;
@@ -122,7 +21,7 @@ foreach my $method (qw(GET DELETE POST PUT OPTIONS)) {
         $res = request(
             $t->$run_method(
                 url  => '/test',
-                data => { foo => 'bar' }
+                data => '',
             )
         );
     }
diff --git a/t/lib/Test/Catalyst/Action/REST/Controller/Root.pm b/t/lib/Test/Catalyst/Action/REST/Controller/Root.pm
new file mode 100644 (file)
index 0000000..1ebbee6
--- /dev/null
@@ -0,0 +1,96 @@
+package Test::Catalyst::Action::REST::Controller::Root;
+use strict;
+use warnings;
+
+use base qw/Catalyst::Controller::REST/;
+
+__PACKAGE__->config( namespace => '' );
+
+sub begin {}  # Don't need serialization..
+
+sub test : Local : ActionClass('REST') {
+    my ( $self, $c ) = @_;
+    $c->stash->{'entity'} = 'something';
+}
+
+sub test_GET {
+    my ( $self, $c ) = @_;
+
+    $c->stash->{'entity'} .= " GET";
+    $c->forward('ok');
+}
+
+sub test_POST {
+    my ( $self, $c ) = @_;
+
+    $c->stash->{'entity'} .= " POST";
+    $c->forward('ok');
+}
+
+sub test_PUT {
+    my ( $self, $c ) = @_;
+
+    $c->stash->{'entity'} .= " PUT";
+    $c->forward('ok');
+}
+
+sub test_DELETE {
+    my ( $self, $c ) = @_;
+
+    $c->stash->{'entity'} .= " DELETE";
+    $c->forward('ok');
+}
+
+sub test_OPTIONS {
+    my ( $self, $c ) = @_;
+
+    $c->stash->{'entity'} .= " OPTIONS";
+    $c->forward('ok');
+}
+
+sub notreally : Local : ActionClass('REST') {
+}
+
+sub notreally_GET {
+    my ( $self, $c ) = @_;
+
+    $c->stash->{'entity'} = "notreally GET";
+    $c->forward('ok');
+}
+
+sub not_implemented : Local : ActionClass('REST') {
+}
+
+sub not_implemented_GET {
+    my ( $self, $c ) = @_;
+
+    $c->stash->{'entity'} = "not_implemented GET";
+    $c->forward('ok');
+}
+
+sub not_implemented_not_implemented {
+    my ( $self, $c ) = @_;
+
+    $c->stash->{'entity'} = "Not Implemented Handler";
+    $c->forward('ok');
+}
+
+sub not_modified : Local : ActionClass('REST') { }
+
+sub not_modified_GET {
+    my ( $self, $c ) = @_;
+    $c->res->status(304);
+    return 1;
+}
+
+sub ok : Private {
+    my ( $self, $c ) = @_;
+
+    $c->res->content_type('text/plain');
+    $c->res->body( $c->stash->{'entity'} );
+}
+
+sub end : Private {} # Don't need serialization..
+
+1;
+