[Jifty-commit] r3786 - in Test-WWW-Declare: lib/Test/WWW t
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Fri Aug 3 19:42:30 EDT 2007
Author: sartak
Date: Fri Aug 3 19:42:29 2007
New Revision: 3786
Added:
Test-WWW-Declare/t/07-alt-names.t
Modified:
Test-WWW-Declare/ (props changed)
Test-WWW-Declare/lib/Test/WWW/Declare.pm
Log:
r29892 at caladan: sartak | 2007-08-03 19:03:30 -0400
Add some alternate names for things, e.g. "foo matches bar" vs "foo should match bar"
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 19:42:29 2007
@@ -9,7 +9,8 @@
our @EXPORT = qw(flow run get session check mech match follow link content
should shouldnt click href button fill form SKIP _twd_dummy
- title equal caselessly contain);
+ title equal caselessly contain matches equals contains
+ never always);
our $BUILDER = Test::Builder->new();
our $WWW_MECHANIZE;
@@ -84,6 +85,14 @@
return $coderef;
}
+# alternates (e.g. "foo matches bar" instead of "foo should match bar")
+sub contains { contain $_[0] }
+sub equals { equal $_[0] }
+sub matches { match $_[0] }
+
+sub always { should $_[0] }
+sub never { shouldnt $_[0] }
+
# Mech interactions
sub mech {
return $WWW_MECHANIZE;
@@ -145,6 +154,8 @@
my $match;
my @output;
+ $args{negative} ||= 0;
+
push @output, $args{name};
push @output, $args{positive} ? "does not"
: "";
Added: Test-WWW-Declare/t/07-alt-names.t
==============================================================================
--- (empty file)
+++ Test-WWW-Declare/t/07-alt-names.t Fri Aug 3 19:42:29 2007
@@ -0,0 +1,33 @@
+#!perl
+use Test::WWW::Declare::Tester tests => 5;
+use warnings;
+use strict;
+
+my @results = run_tests(
+ sub {
+ session "check logins" => run {
+ flow "basic connectivity" => check {
+ get "http://localhost:$PORT/";
+ title matches qr{in.ex}i;
+ click href qr{good};
+ title always equals 'GOOD';
+ click href qr{index};
+ title caselessly equals 'InDeX';
+ title contains 'DEX';
+ title never contains 'dEX';
+ title contains caselessly 'dEX';
+ };
+ };
+ }
+);
+
+shift @results; # Test::Tester gives 1-based arrays
+is(@results, 2, "had two tests");
+ok($results[0]{ok}, "1st test passed");
+ok($results[1]{ok}, "2nd test passed");
+
+is($results[0]{name}, "basic connectivity", "1st test was flow");
+is($results[1]{name}, "check logins", "2nd test was session");
+
+
+
More information about the Jifty-commit
mailing list