-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conflicts: Mechanize.pm
- Loading branch information
Showing
8 changed files
with
225 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
language: perl | ||
perl: | ||
- "dev" | ||
- "5.24" | ||
- "5.22" | ||
- "5.20" | ||
- "5.18" | ||
- "5.16" | ||
- "5.14" | ||
- "5.12" | ||
- "5.10" | ||
sudo: false | ||
before_install: | ||
- git clone git://github.com/travis-perl/helpers ~/travis-perl-helpers | ||
- source ~/travis-perl-helpers/init | ||
- build-perl | ||
- perl -V | ||
- cpanm HTML::Lint || true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#!perl -T | ||
|
||
use strict; | ||
use warnings; | ||
use Test::More tests => 19; | ||
use Test::Builder::Tester; | ||
|
||
use lib 't'; | ||
use TestServer; | ||
|
||
my $server = TestServer->new; | ||
my $pid = $server->background; | ||
my $server_root = $server->root; | ||
|
||
use Test::WWW::Mechanize (); | ||
|
||
my $mech = Test::WWW::Mechanize->new( autocheck => 0 ); | ||
isa_ok($mech,'Test::WWW::Mechanize'); | ||
$mech->get_ok( "$server_root/form.html" ); | ||
|
||
GOOD_EXISTS: { | ||
test_out( 'ok 1 - Has Content-Type' ); | ||
my $ok = $mech->header_exists('Content-Type', 'Has Content-Type'); | ||
test_test( 'Gets existing header and reports success' ); | ||
is( ref($ok), '', 'get_ok() should only return a scalar' ); | ||
ok( $ok, 'And the result should be true' ); | ||
|
||
# default desc | ||
test_out( 'ok 1 - Response has Content-Type header' ); | ||
$mech->header_exists('Content-Type'); | ||
test_test( 'Gets existing header and reports success - default desc' ); | ||
} | ||
|
||
BAD_EXISTS: { | ||
test_out( 'not ok 1 - Try to get a bad header' ); | ||
test_fail( +1 ); | ||
my $ok = $mech->header_exists('Server', 'Try to get a bad header'); | ||
test_diag( 'Content-Length: ' ); | ||
test_diag( 'Content-Type: ' ); | ||
test_diag( 'client-date: ' ); | ||
test_diag( 'client-peer: ' ); | ||
test_diag( 'client-response-num: ' ); | ||
test_diag( 'title: ' ); | ||
test_test( 'Fails to get nonexistent header and reports failure' ); | ||
|
||
is( ref($ok), '', 'get_ok() should only return a scalar' ); | ||
ok( !$ok, 'And the result should be false' ); | ||
} | ||
|
||
GOOD_MATCHES: { | ||
test_out( 'ok 1 - Content-Type is "text/html"' ); | ||
my $ok = $mech->header_matches('Content-Type', 'text/html', 'Content-Type is "text/html"'); | ||
test_test( 'Matches existing header and reports success' ); | ||
is( ref($ok), '', 'get_ok() should only return a scalar' ); | ||
ok( $ok, 'And the result should be true' ); | ||
|
||
# regex | ||
test_out( 'ok 1 - Content-Type matches /^text\\/html$/' ); | ||
$mech->header_matches('Content-Type', qr/^text\/html$/, 'Content-Type matches /^text\\/html$/'); | ||
test_test( 'Matches existing header and reports success - regex' ); | ||
|
||
# default desc | ||
test_out( 'ok 1 - Response has Content-Type header with value \'text/html\'' ); | ||
$mech->header_matches('Content-Type', 'text/html'); | ||
test_test( 'Matches existing header and reports success - default desc' ); | ||
} | ||
|
||
BAD_MATCHES: { | ||
test_out( 'not ok 1 - Try to match a bad header' ); | ||
test_fail( +1 ); | ||
my $ok = $mech->header_matches('Server', 'GitHub.com', 'Try to match a bad header'); | ||
test_test( 'Fails to match nonexistent header and reports failure' ); | ||
|
||
is( ref($ok), '', 'get_ok() should only return a scalar' ); | ||
ok( !$ok, 'And the result should be false' ); | ||
|
||
test_out( 'not ok 1 - Content-Type is "text/plain"' ); | ||
test_fail( +1 ); | ||
$mech->header_matches('Content-Type', 'text/plain', 'Content-Type is "text/plain"'); | ||
test_diag( 'text/html' ); | ||
test_test( 'Fails to match header and reports failure' ); | ||
|
||
test_out( 'not ok 1 - Content-Type matches /^text\\/plain$/' ); | ||
test_fail( +1 ); | ||
$mech->header_matches('Content-Type', qr/^text\/plain$/, 'Content-Type matches /^text\\/plain$/'); | ||
test_diag( 'text/html' ); | ||
test_test( 'Fails to match header and reports failure - regex' ); | ||
} | ||
|
||
$server->stop; | ||
|
||
done_testing(); |
Oops, something went wrong.