#!/usr/bin/perl -w use strict; use lib 'inc'; use IO::Catch; use vars qw($_STDOUT_ ); tie *STDOUT, 'IO::Catch', '_STDOUT_' or die $!; # Disable all ReadLine functionality $ENV{PERL_RL} = 0; delete $ENV{PAGER} if $ENV{PAGER}; $ENV{PERL_HTML_DISPLAY_CLASS}="HTML::Display::Dump"; use Test::More tests => 6; use_ok('WWW::Mechanize::Shell'); my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef ); isa_ok $s, 'WWW::Mechanize::Shell'; SKIP: { $s->agent->{base} = 'http://example.com'; $s->agent->update_html(< An HTML page Some body HTML $s->cmd('title'); chomp $_STDOUT_; is($_STDOUT_,"An HTML page", "Title gets output correctly"); undef $_STDOUT_; $s->agent->update_html(< Some body HTML $s->cmd('title'); chomp $_STDOUT_; is($_STDOUT_,"", "Empty title gets output correctly"); undef $_STDOUT_; $s->agent->update_html(< 0 Some body HTML $s->cmd('title'); chomp $_STDOUT_; is($_STDOUT_,"0", "False title gets output correctly"); undef $_STDOUT_; $s->agent->update_html(< Some body HTML $s->cmd('title'); chomp $_STDOUT_; is($_STDOUT_,"", "A missing title gets output correctly"); };