[Catalyst-commits] r12562 -
Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst
rafl at dev.catalyst.perl.org
rafl at dev.catalyst.perl.org
Sat Jan 9 17:48:39 GMT 2010
Author: rafl
Date: 2010-01-09 17:48:38 +0000 (Sat, 09 Jan 2010)
New Revision: 12562
Modified:
Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst/Test.pm
Log:
Start porting Catalyst::Test to Plack::Test.
Modified: Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst/Test.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst/Test.pm 2010-01-09 17:48:31 UTC (rev 12561)
+++ Catalyst-Runtime/5.80/branches/psgi/lib/Catalyst/Test.pm 2010-01-09 17:48:38 UTC (rev 12562)
@@ -4,10 +4,12 @@
use warnings;
use Test::More ();
+use Plack::Test;
use Catalyst::Exception;
use Catalyst::Utils;
use Class::MOP;
use Sub::Exporter;
+use Carp;
my $build_exports = sub {
my ($self, $meth, $args, $defaults) = @_;
@@ -15,17 +17,21 @@
my $request;
my $class = $args->{class};
+ if (!$class) {
+ croak "Must specify a test app: use Catalyst::Test 'TestApp'";
+ }
+
if ( $ENV{CATALYST_SERVER} ) {
$request = sub { remote_request(@_) };
- } elsif (! $class) {
- $request = sub { Catalyst::Exception->throw("Must specify a test app: use Catalyst::Test 'TestApp'") };
} else {
unless (Class::MOP::is_class_loaded($class)) {
Class::MOP::load_class($class);
}
$class->import;
- $request = sub { local_request( $class, @_ ) };
+ my $app = $class->run;
+
+ $request = sub { local_request( $app, @_ ) };
}
my $get = sub { $request->(@_)->content };
@@ -218,8 +224,9 @@
=cut
sub local_request {
- my $class = shift;
+ my $app = shift;
+=for reference
require HTTP::Request::AsCGI;
my $request = Catalyst::Utils::request( shift(@_) );
@@ -231,6 +238,15 @@
my $response = $cgi->restore->response;
$response->request( $request );
return $response;
+=cut
+
+ my $request = Catalyst::Utils::request(shift);
+ _customize_request($request, @_);
+
+ my $ret;
+ test_psgi app => $app, client => sub { $ret = shift->($request) };
+
+ return $ret;
}
my $agent;
More information about the Catalyst-commits
mailing list