Skip to content

Commit

Permalink
Merge d6393fa into c8de4e8
Browse files Browse the repository at this point in the history
  • Loading branch information
oalders committed May 22, 2020
2 parents c8de4e8 + d6393fa commit 4af5f7a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
26 changes: 15 additions & 11 deletions t/history.t
Original file line number Diff line number Diff line change
@@ -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)}
Expand Down Expand Up @@ -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"
);

}

{
Expand All @@ -160,4 +164,4 @@ BEGIN {

}

done_testing();
done_testing();
2 changes: 1 addition & 1 deletion t/history_2.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<form action="history_3.html" method="get" name="get_form">
<input type="Submit" name="submit"/>
</form>
<form action="http://localhost/" method="post" name="post_form">
<form action="" method="post" name="post_form">
<input type="Submit" name="submit"/>
</form>
</body>
Expand Down
12 changes: 6 additions & 6 deletions t/local/LocalServer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ BEGIN {
HTTPS_PROXY https_proxy HTTP_PROXY_ALL http_proxy_all
)};
}
use LWP::Simple;
use FindBin;
use File::Spec;
use File::Temp;
use URI::URL qw();

use Carp qw(carp croak);
use File::Temp ();
use LWP::Simple qw( get );
use Path::Tiny qw( path );
use URI::URL qw();

=head1 SYNOPSIS
Expand Down Expand Up @@ -101,7 +101,7 @@ sub spawn {
$self->{logfile} = $logfile;
my $web_page = delete $args{file} || "";

my $server_file = File::Spec->catfile( $FindBin::Bin,'log-server' );
my $server_file = path('t/local/log-server')->absolute;
my @opts;
push @opts, "-e" => qq{"} . delete($args{ eval }) . qq{"}
if $args{ eval };
Expand Down

0 comments on commit 4af5f7a

Please sign in to comment.