[Jifty-commit] r3778 - in Test-WWW-Declare: lib/Test/WWW lib/Test/WWW/Declare t

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Fri Aug 3 16:40:09 EDT 2007


Author: sartak
Date: Fri Aug  3 16:40:06 2007
New Revision: 3778

Added:
   Test-WWW-Declare/t/03-mech.t
Modified:
   Test-WWW-Declare/   (props changed)
   Test-WWW-Declare/Makefile.PL
   Test-WWW-Declare/lib/Test/WWW/Declare.pm
   Test-WWW-Declare/lib/Test/WWW/Declare/Tester.pm

Log:
 r29880 at caladan:  sartak | 2007-08-03 16:39:57 -0400
 Test dropping down into mech, and switch to using Test::WWW::Mechanize


Modified: Test-WWW-Declare/Makefile.PL
==============================================================================
--- Test-WWW-Declare/Makefile.PL	(original)
+++ Test-WWW-Declare/Makefile.PL	Fri Aug  3 16:40:06 2007
@@ -4,7 +4,7 @@
 license      'perl';
 version_from 'lib/Test/WWW/Declare.pm';
 
-requires 'WWW::Mechanize';
+requires 'Test::WWW::Mechanize';
 requires 'Test::Builder';
 requires 'Test::More';
 

Modified: Test-WWW-Declare/lib/Test/WWW/Declare.pm
==============================================================================
--- Test-WWW-Declare/lib/Test/WWW/Declare.pm	(original)
+++ Test-WWW-Declare/lib/Test/WWW/Declare.pm	Fri Aug  3 16:40:06 2007
@@ -2,7 +2,7 @@
 use warnings;
 use strict;
 use base 'Test::More';
-use WWW::Mechanize;
+use Test::WWW::Mechanize;
 use Test::Builder;
 
 our $VERSION  = '0.00';
@@ -156,7 +156,7 @@
     my $title = shift;
     my $coderef = shift;
 
-    local $WWW_MECHANIZE = WWW::Mechanize->new();
+    local $WWW_MECHANIZE = Test::WWW::Mechanize->new();
     eval { $coderef->() };
 
     if ($@ =~/^SKIP: (.*)$/) {

Modified: Test-WWW-Declare/lib/Test/WWW/Declare/Tester.pm
==============================================================================
--- Test-WWW-Declare/lib/Test/WWW/Declare/Tester.pm	(original)
+++ Test-WWW-Declare/lib/Test/WWW/Declare/Tester.pm	Fri Aug  3 16:40:06 2007
@@ -21,18 +21,20 @@
 
 );
 
-for (values %content)
+for my $url (keys %content)
 {
-    s/^/        /mg;
+    $content{$url} =~ s/^/        /mg;
 
-    $_ = << "WRAPPER";
+    $content{$url} = << "WRAPPER";
 <html>
+    <head>
+        <title>\U$url\E</title>
+    </head>
     <body>
-$_
+$content{$url}
     </body>
 </html>
 WRAPPER
-
 }
 
 sub handle_request {

Added: Test-WWW-Declare/t/03-mech.t
==============================================================================
--- (empty file)
+++ Test-WWW-Declare/t/03-mech.t	Fri Aug  3 16:40:06 2007
@@ -0,0 +1,27 @@
+#!perl
+use Test::WWW::Declare::Tester tests => 7;
+use warnings;
+use strict;
+
+my @results = run_tests(
+    sub {
+        session "check logins" => run {
+            flow "basic connectivity" => check {
+                get "http://localhost:$PORT/";
+                mech()->title_is("INDEX", "drop down to mech for checking title");
+            };
+        };
+    }
+);
+
+shift @results; # Test::Tester gives 1-based arrays
+is(@results, 3, "had three tests");
+ok($results[0]{ok}, "1st test passed");
+ok($results[1]{ok}, "2nd test passed");
+ok($results[2]{ok}, "3rd test passed");
+
+is($results[0]{name}, "drop down to mech for checking title", "1st test was by mech");
+is($results[1]{name}, "basic connectivity", "2nd test was flow");
+is($results[2]{name}, "check logins", "2nd test was session");
+
+


More information about the Jifty-commit mailing list