[Jifty-commit] r4158 - in jifty/trunk: lib/Jifty/Test/WWW t/TestApp/t

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Wed Sep 26 14:58:40 EDT 2007


Author: sartak
Date: Wed Sep 26 14:58:38 2007
New Revision: 4158

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Test/WWW/Declare.pm
   jifty/trunk/t/TestApp/t/18-test-www-declare.t

Log:
 r43102 at onn:  sartak | 2007-09-26 14:57:22 -0400
 Override T:W:D's get with ours which prepends the server's URL
 Start documentation


Modified: jifty/trunk/lib/Jifty/Test/WWW/Declare.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Test/WWW/Declare.pm	(original)
+++ jifty/trunk/lib/Jifty/Test/WWW/Declare.pm	Wed Sep 26 14:58:38 2007
@@ -5,7 +5,7 @@
 use base qw(Exporter);
 BEGIN { require Jifty::Test; require Test::WWW::Declare }
 
-our @EXPORT = qw($server $URL);
+our @EXPORT = qw($server $URL get);
 
 our $server;
 our $URL;
@@ -24,6 +24,8 @@
     Test::WWW::Declare->export_to_level(2);
 
     # export $server, $URL, and whatever else J:T:W:D adds
+    # note that this must come AFTER T:W:D->export because we override some
+    # of its functions
     __PACKAGE__->export_to_level(1);
 
     # create a server (which will be automatically exported)
@@ -31,5 +33,40 @@
     $URL = $server->started_ok;
 }
 
+=head1 NAME
+
+Jifty::Test::WWW::Declare - Subclass of L<Test::WWW::Declare> with
+extra Jifty features
+
+=head1 SYNOPSIS
+
+    use Jifty::Test::WWW::Declare tests => 2;
+
+    session user => run {
+        flow 'login page' => check {
+            get 'login';
+            content should match qr{Email:};
+            content should match qr{Password:};
+        };
+    };
+
+=head1 FUNCTIONS
+
+=head2 get PATH
+
+Automatically prepend the server's URL to the PATH. You may avoid this by
+specifying the full URL yourself (it checks for C</^http/>).
+
+=cut
+
+sub get
+{
+    my $url = shift;
+    $url = "$URL/$url"
+        unless $url =~ /^http/;
+
+    Test::WWW::Declare::get($url);
+}
+
 1;
 

Modified: jifty/trunk/t/TestApp/t/18-test-www-declare.t
==============================================================================
--- jifty/trunk/t/TestApp/t/18-test-www-declare.t	(original)
+++ jifty/trunk/t/TestApp/t/18-test-www-declare.t	Wed Sep 26 14:58:38 2007
@@ -13,7 +13,7 @@
 
 session user => run {
     flow "region with internal redirects" => check {
-        get "$URL/region-with-internal-redirect";
+        get "region-with-internal-redirect";
         content should match qr/redirected ok/;
         content should match qr/other region/;
         content should match qr/still going/;


More information about the Jifty-commit mailing list