App-SimpleScan-Plugin-LinkCheck
view release on metacpan or search on metacpan
t/03has_link.t view on Meta::CPAN
use Test::More;
use Test::Differences;
use File::Temp qw(tempfile);
$ENV{HARNESS_PERL_SWITCHES} = '' unless defined $ENV{HARNESS_PERL_SWITCHES};
sub build_input {
my($fh, $filename) = tempfile();
print $fh @_;
close $fh;
return $filename;
}
$simple_scan = `which simple_scan`;
if (!$simple_scan){
plan skip_all => 'simple_scan unavailable';
}
else {
plan tests =>12;
chomp $simple_scan;
}
$delete_me = build_input(<<EOS);
%%has_link
http://cpan.org/ /CPAN/ Y CPAN is there
EOS
@output = `$^X $ENV{HARNESS_PERL_SWITCHES} -Iblib/lib $simple_scan --gen < $delete_me`;
ok((scalar @output), "got output");
$expected = <<EOS;
use Test::More tests=>2;
use Test::WWW::Simple;
use strict;
mech->agent_alias('Windows IE 6');
fail "No arguments for %%has_link";
page_like "http://cpan.org/",
qr/CPAN/,
qq(CPAN is there [http://cpan.org/] [/CPAN/ should match]);
EOS
eq_or_diff(join("",@output), $expected, "output matches");
unlink $delete_me;
#########################################
$delete_me = build_input(<<EOS);
%%has_link "CPAN sites"
http://cpan.org/ /CPAN/ Y CPAN is there
EOS
@output = `$^X $ENV{HARNESS_PERL_SWITCHES} -Iblib/lib $simple_scan --gen < $delete_me`;
ok((scalar @output), "got output");
$expected = <<EOS;
use Test::More tests=>2;
use Test::WWW::Simple;
use strict;
mech->agent_alias('Windows IE 6');
( run in 0.945 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )