| 1 |
#!/usr/bin/perl -w |
| 2 |
use strict; |
| 3 |
use lib './inc'; |
| 4 |
use IO::Catch; |
| 5 |
use Test::HTTP::LocalServer; |
| 6 |
|
| 7 |
our ($_STDOUT_, $_STDERR_); |
| 8 |
tie *STDOUT, 'IO::Catch', '_STDOUT_' or die $!; |
| 9 |
tie *STDERR, 'IO::Catch', '_STDERR_' or die $!; |
| 10 |
|
| 11 |
use Test::More tests => 5; |
| 12 |
|
| 13 |
# Disable all ReadLine functionality |
| 14 |
$ENV{PERL_RL} = 0; |
| 15 |
delete @ENV{qw(HTTP_PROXY http_proxy CGI_HTTP_PROXY)}; |
| 16 |
|
| 17 |
use_ok('WWW::Mechanize::Shell'); |
| 18 |
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef ); |
| 19 |
|
| 20 |
# Now test |
| 21 |
my $server = Test::HTTP::LocalServer->spawn(); |
| 22 |
|
| 23 |
{ no warnings 'redefine','once'; |
| 24 |
local *WWW::Mechanize::Shell::status = sub {}; |
| 25 |
|
| 26 |
#$s->cmd("set dumprequests 1"); |
| 27 |
$s->cmd("set dumpresponses 1"); |
| 28 |
eval { $s->cmd( sprintf 'get "%s"', $server->url); }; |
| 29 |
is($@, "", "Get url worked"); |
| 30 |
isnt($_STDOUT_,undef,"Response was not undef"); |
| 31 |
isnt($_STDOUT_,"","Response was output"); |
| 32 |
isnt($s->agent->content,"","Retrieved content"); |
| 33 |
}; |
| 34 |
|
| 35 |
|