Browse Source

content_like should not throw away description

amacleay 11 years ago
parent
commit
f3f7b15fa9
2 changed files with 24 additions and 2 deletions
  1. 2 2
      lib/Test/Selenium/Remote/Driver.pm
  2. 22 0
      t/Test-Selenium-Remote-Driver.t

+ 2 - 2
lib/Test/Selenium/Remote/Driver.pm

@@ -318,12 +318,12 @@ sub content_like {
     my $content = $self->get_page_source();
 
     if ( not ref $regex eq 'ARRAY' ) {
-        my $desc = qq{Content is like "$regex"} if ( not defined $desc );
+        $desc = qq{Content is like "$regex"} if ( not defined $desc );
         return like_string( $content, $regex, $desc );
     }
     elsif ( ref $regex eq 'ARRAY' ) {
         for my $re (@$regex) {
-            my $desc = qq{Content is like "$re"} if ( not defined $desc );
+            $desc = qq{Content is like "$re"} if ( not defined $desc );
             like_string( $content, $re, $desc );
         }
     }

+ 22 - 0
t/Test-Selenium-Remote-Driver.t

@@ -99,5 +99,27 @@ my $element = Test::Selenium::Remote::WebElement->new(
 
 }
 
+# content_like
+{
+    $successful_driver->mock( 'get_page_source', sub { 'this output matches regex' } );
+    check_tests(
+        sub {
+            my $rc = $successful_driver->content_like( qr/matches/,
+                'content_like works' );
+            is( $rc, 1, 'returns true' );
+        },
+        [   {   ok   => 1,
+                name => "content_like works",
+                diag => "",
+            },
+            {   ok   => 1,
+                name => "returns true",
+                diag => "",
+            },
+        ]
+    );
+
+}
+
 
 done_testing();