File: text_contains.t

package info (click to toggle)
libtest-www-mechanize-perl 1.60-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 380 kB
  • sloc: perl: 2,725; makefile: 4
file content (39 lines) | stat: -rw-r--r-- 1,158 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!perl -T

use strict;
use warnings;

use Test::More tests => 5;
use Test::Builder::Tester;
use URI::file;

use Test::WWW::Mechanize ();

my $mech = Test::WWW::Mechanize->new();
isa_ok( $mech,'Test::WWW::Mechanize' );

my $uri = URI::file->new_abs( 't/goodlinks.html' )->as_string;
$mech->get_ok( $uri );

# test regex
test_out( 'ok 1 - Does it say test page?' );
$mech->text_contains( 'Test Page', 'Does it say test page?' );
test_test( 'Finds the contains' );

# default desc
test_out( 'ok 1 - Text contains "Test Page"' );
$mech->text_contains( 'Test Page');
test_test( 'Finds the contains - default desc' );

# Handles not finding something. Also, what we are searching for IS
# found in content_contains() but NOT in text_contains().
test_out( 'not ok 1 - Trying to find goodlinks' );
test_fail(+5);
test_diag( q{    searched: "Test PageTest PageTest 1 Test 2 Test 3"} );
test_diag( q{  can't find: "goodlinks.html"} );
test_diag( q{        LCSS: "s"} );
test_diag( q{LCSS context: "Test PageTest PageTest 1 Test 2 Test 3"} );
$mech->text_contains( 'goodlinks.html', 'Trying to find goodlinks' );
test_test( 'Handles not finding it' );

done_testing();