فهرست منبع

Fixed the failing tests and added the other functions

Emmanuel Peroumalnaik 10 سال پیش
والد
کامیت
6271312ac1
2فایلهای تغییر یافته به همراه29 افزوده شده و 5 حذف شده
  1. 3 3
      lib/Test/Selenium/Remote/Driver.pm
  2. 26 2
      t/Test-Selenium-Remote-Driver.t

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

@@ -728,7 +728,7 @@ Tells if the text of the page (as returned by C<< get_body() >>)
 are provided, one 'test' is run for each regex against the content of the
 are provided, one 'test' is run for each regex against the content of the
 current page.
 current page.
 
 
-A default description of 'Text is lacks "$str"' will be provided if there
+A default description of 'Text lacks "$str"' will be provided if there
 is no description.
 is no description.
 
 
 To also match the HTML see, C<< content_lacks() >>.
 To also match the HTML see, C<< content_lacks() >>.
@@ -746,7 +746,7 @@ sub body_text_lacks {
     my $ret;
     my $ret;
 
 
     if ( not ref $str eq 'ARRAY' ) {
     if ( not ref $str eq 'ARRAY' ) {
-        $desc = qq{Text is lacks "$str"} if ( not defined $desc );
+        $desc = qq{Text lacks "$str"} if ( not defined $desc );
         $ret = lacks_string( $text, $str, $desc );
         $ret = lacks_string( $text, $str, $desc );
         if ( !$ret ) {
         if ( !$ret ) {
             $self->error_handler->($self,"Failed to find $str");
             $self->error_handler->($self,"Failed to find $str");
@@ -755,7 +755,7 @@ sub body_text_lacks {
     }
     }
     elsif ( ref $str eq 'ARRAY' ) {
     elsif ( ref $str eq 'ARRAY' ) {
         for my $s (@$str) {
         for my $s (@$str) {
-            $desc = qq{Text is lacks "$s"} if ( not defined $desc );
+            $desc = qq{Text lacks "$s"} if ( not defined $desc );
             $ret = lacks_string( $text, $s, $desc );
             $ret = lacks_string( $text, $s, $desc );
             if ( !$ret ) {
             if ( !$ret ) {
                 $self->error_handler->($self,"Failed to find $s");
                 $self->error_handler->($self,"Failed to find $s");

+ 26 - 2
t/Test-Selenium-Remote-Driver.t

@@ -137,13 +137,37 @@ $successful_driver->clear_element_ok('q','element is cleared ok');
 $successful_driver->is_element_enabled_ok('p','class','element is enabled');
 $successful_driver->is_element_enabled_ok('p','class','element is enabled');
 $successful_driver->is_element_displayed_ok('q','element is displayed');
 $successful_driver->is_element_displayed_ok('q','element is displayed');
 
 
-test_out('not ok 1 - Content is like "(?-xism:nomatch)"'."\n".'ok 2 - Error callback triggered');
-like(exception { $successful_driver->content_like( qr/nomatch/) },qr/^Got message/,'Error callback triggered');
+test_out('not ok 1 - Content is ok'."\n".'ok 2 - Error callback triggered');
+like(exception { $successful_driver->content_like( qr/nomatch/, 'Content is ok') },qr/^Got message/,'Error callback triggered');
 test_test(title => "Error handler works with 'content_like'",skip_err => 1);
 test_test(title => "Error handler works with 'content_like'",skip_err => 1);
 
 
+test_out('not ok 1 - Content is ok'."\n".'ok 2 - Error callback triggered');
+like(exception { $successful_driver->content_unlike(qr/matches/, 'Content is ok') },qr/^Got message/,'Error callback triggered');
+test_test(title => "Error handler works with 'content_unlike'",skip_err => 1);
+
+test_out('not ok 1 - Content is ok'."\n".'ok 2 - Error callback triggered');
+like(exception { $successful_driver->content_contains('blah', 'Content is ok') },qr/^Got message/,'Error callback triggered');
+test_test(title => "Error handler works with 'content_contains'",skip_err => 1);
+
+test_out('not ok 1 - Content is ok'."\n".'ok 2 - Error callback triggered');
+like(exception { $successful_driver->content_lacks('matches', 'Content is ok') },qr/^Got message/,'Error callback triggered');
+test_test(title => "Error handler works with 'content_lacks'",skip_err => 1);
+
+test_out('not ok 1 - Body is ok'."\n".'ok 2 - Error callback triggered');
+like(exception { $successful_driver->body_text_like( qr/nomatch/, 'Body is ok') },qr/^Got message/,'Error callback triggered');
+test_test(title => "Error handler works with 'body_text_like'",skip_err => 1);
+
+test_out('not ok 1 - Body is ok'."\n".'ok 2 - Error callback triggered');
+like(exception { $successful_driver->body_text_unlike(qr/matches/, 'Body is ok') },qr/^Got message/,'Error callback triggered');
+test_test(title => "Error handler works with 'body_text_unlike'",skip_err => 1);
+
 test_out('not ok 1 - Text contains "nomatch"'."\n".'ok 2 - Error callback triggered');
 test_out('not ok 1 - Text contains "nomatch"'."\n".'ok 2 - Error callback triggered');
 like(exception { $successful_driver->body_text_contains('nomatch') },qr/^Got message/,'Error callback triggered');
 like(exception { $successful_driver->body_text_contains('nomatch') },qr/^Got message/,'Error callback triggered');
 test_test(title => "Error handler works with 'body_text_contains'",skip_err => 1);
 test_test(title => "Error handler works with 'body_text_contains'",skip_err => 1);
 
 
+test_out('not ok 1 - Text lacks "match"'."\n".'ok 2 - Error callback triggered');
+like(exception { $successful_driver->body_text_lacks(['match','bar']) },qr/^Got message/,'Error callback triggered');
+test_test(title => "Error handler works with 'body_text_lacks'",skip_err => 1);
+
 
 
 done_testing();
 done_testing();