Last active
January 12, 2016 01:00
-
-
Save neilhwatson/40669414b404e0054a97 to your computer and use it in GitHub Desktop.
URL test script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
=pod | |
=head1 SYNOPSIS | |
Test the contents of a URL using Mojo::UserAgent. | |
=cut | |
use strict; | |
use warnings; | |
use Mojo::UserAgent; | |
use Test::More tests => 2; | |
# URL from command line arg | |
my $url = $ARGV[0]; | |
# Make user agent object and get URL | |
my $ua = Mojo::UserAgent->new; | |
my $contents = $ua->get( $url ); | |
# Test get and returned contents | |
ok( $contents->success, "Test for successful Get" ); | |
like( $contents->res->body, qr/infomart demo by Neil Watson/ism, "Test contents" ); | |
done_testing; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment