Skip to content

Instantly share code, notes, and snippets.

@motemen
Created February 27, 2011 15:13
Show Gist options
  • Save motemen/846251 to your computer and use it in GitHub Desktop.
Save motemen/846251 to your computer and use it in GitHub Desktop.
mech's $res->base does not see <base href="">
use strict;
use warnings;
use Test::More;
use LWP::UserAgent;
use WWW::Mechanize;
my $ua = LWP::UserAgent->new;
my $mech = WWW::Mechanize->new;
subtest ua => sub {
my $res = $ua->get('http://www.nicovideo.jp/tag/VOCALOID');
is $res->base, 'http://www.nicovideo.jp/';
};
subtest mech => sub {
my $res = $mech->get('http://www.nicovideo.jp/tag/VOCALOID');
is $res->base, 'http://www.nicovideo.jp/'; # fail
};
done_testing;
__END__
ok 1
1..1
ok 1 - ua
not ok 1
# Failed test at /Users/motemen/sketch.pl line 17.
# got: 'http://www.nicovideo.jp/tag/VOCALOID'
# expected: 'http://www.nicovideo.jp/'
1..1
# Looks like you failed 1 test of 1.
not ok 2 - mech
# Failed test 'mech'
# at /Users/motemen/sketch.pl line 18.
1..2
# Looks like you failed 1 test of 2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment