From d6393fa580c7e7a49b26aac91449647f293fbfa5 Mon Sep 17 00:00:00 2001 From: Olaf Alders Date: Fri, 22 May 2020 17:46:21 -0400 Subject: [PATCH] Don't make assumptions in tests about what's happening on port 80 Fixes #276 --- Changes | 1 + t/history.t | 26 +++++++++++++++----------- t/history_2.html | 2 +- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Changes b/Changes index ba619410..e69c3c0b 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Revision history for WWW::Mechanize {{$NEXT}} + - Don't make assumptions about port 80 in test (GH#299) (Olaf Alders) 1.97 2020-05-14 00:46:53Z - Respect CDATA[[ sections when parsing HTML (GH#298) (Max Maischein) diff --git a/t/history.t b/t/history.t index ee877bea..26c6a606 100644 --- a/t/history.t +++ b/t/history.t @@ -1,11 +1,17 @@ -#!perl -T +#!perl use warnings; use strict; -use Test::More; + +use lib qw( t/local ); + +use LocalServer (); +use Path::Tiny qw( path ); use Test::Deep; use Test::Fatal; -use URI::file; +use Test::More; +use URI::file (); +use WWW::Mechanize (); BEGIN { delete @ENV{qw(PATH IFS CDPATH ENV BASH_ENV)} @@ -118,22 +124,20 @@ BEGIN { } { + my $html = path('t/history_2.html')->slurp; + my $server = LocalServer->spawn( html => $html ); my $mech = WWW::Mechanize->new( cookie_jar => undef, autocheck => 0 ); - isa_ok( $mech, 'WWW::Mechanize' ); + $mech->get( $server->url ); - my $uri = URI::file->new_abs('t/history_2.html')->as_string; - - $mech->get($uri); ok( $mech->submit_form( form_name => "post_form" ), "Submit form using 'post' method" ); is( $mech->history_count, 2, "... and it was recorded in the history" ); - like( - $mech->history(0)->{req}->uri, qr/localhost/, + is( + $mech->history(0)->{req}->uri, $server->url, "... and the correct request was saved" ); - } { @@ -160,4 +164,4 @@ BEGIN { } -done_testing(); \ No newline at end of file +done_testing(); diff --git a/t/history_2.html b/t/history_2.html index 279d2e06..06e86bcd 100644 --- a/t/history_2.html +++ b/t/history_2.html @@ -6,7 +6,7 @@
-
+