[Jifty-commit] jifty branch, plack, updated. a4c5c0ce895139d9bc80b8170ed86694e84cf566

Jifty commits jifty-commit at lists.jifty.org
Wed Jan 6 08:16:19 EST 2010


The branch, plack has been updated
       via  a4c5c0ce895139d9bc80b8170ed86694e84cf566 (commit)
      from  547edb43b781403fcd18a63c36c5040df2dcc1b7 (commit)

Summary of changes:
 Makefile.PL                     |    1 +
 lib/Jifty/Test/WWW/Mechanize.pm |   51 ++++-----------------------------------
 2 files changed, 6 insertions(+), 46 deletions(-)

- Log -----------------------------------------------------------------
commit a4c5c0ce895139d9bc80b8170ed86694e84cf566
Author: Chia-liang Kao <clkao at clkao.org>
Date:   Wed Jan 6 18:03:14 2010 +0800

    use new test::www::mechanize::psgi instead of plack hook hacks.

diff --git a/Makefile.PL b/Makefile.PL
index 9815d17..ea6dc1a 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -84,6 +84,7 @@ requires('Test::More' => 0.62 );
 requires('Test::Pod::Coverage');
 requires('Test::Script::Run' => 0.03);
 requires('Test::WWW::Mechanize' => 1.04 );
+requires('Test::WWW::Mechanize::PSGI' => 0.35 );
 requires('Test::WWW::Selenium' => 1.18 );
 requires('WWW::Mechanize' => 1.51 );
 requires('UNIVERSAL::require');
diff --git a/lib/Jifty/Test/WWW/Mechanize.pm b/lib/Jifty/Test/WWW/Mechanize.pm
index 251bad5..ffce267 100644
--- a/lib/Jifty/Test/WWW/Mechanize.pm
+++ b/lib/Jifty/Test/WWW/Mechanize.pm
@@ -2,7 +2,7 @@ use strict;
 use warnings;
 
 package Jifty::Test::WWW::Mechanize;
-use base qw/Test::WWW::Mechanize/;
+use base qw/Test::WWW::Mechanize::PSGI/;
 
 delete $ENV{'http_proxy'}; # Otherwise Test::WWW::Mechanize tries to go through your HTTP proxy
 
@@ -39,53 +39,12 @@ bot a cookie jar.
 
 sub new {
     my $class = shift;
-    my $self = $class->SUPER::new(@_);
-    $self->cookie_jar(HTTP::Cookies->new);
-    $self->_plack_hook(
-        uri => Jifty->web->url,
-        handler => sub {
-            Jifty->handler->handle_request(@_);
-        },
-    );
-    return $self;
-}
-
-sub clone {
-    my $self = shift;
-    my $clone = $self->SUPER::clone($self);
-    $clone->_plack_hook(
-        uri => Jifty->web->url,
-        handler => sub {
-            Jifty->handler->handle_request(@_);
-        },
-    );
-    return $clone;
-}
+    my $app = sub { Jifty->handler->handle_request(@_) };
 
-sub _plack_hook {
-    my $self = shift;
-    my %args = (
-        uri => "http://localhost:8888/",
-        @_
-    );
-
-    die "No handler provided"
-        unless $args{handler};
-
-    my $cb;
-
-    test_psgi
-        app => $args{handler},
-        client => sub {$cb = shift};
+    my $self = $class->SUPER::new(@_, app => $app);
+    $self->cookie_jar(HTTP::Cookies->new);
 
-    my $for = URI->new( $args{uri} );
-    $self->add_handler(
-        request_send => $cb,
-        m_scheme => $for->scheme,
-        m_host => $for->host,
-        m_port => $for->port,
-        m_path_prefix => $for->path,
-    );
+    return $self;
 }
 
 =head2 moniker_for ACTION, FIELD1 => VALUE1, FIELD2 => VALUE2

-----------------------------------------------------------------------


More information about the Jifty-commit mailing list