Skip to content

Instantly share code, notes, and snippets.

@neilhwatson
Last active January 12, 2016 01:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neilhwatson/40669414b404e0054a97 to your computer and use it in GitHub Desktop.
Save neilhwatson/40669414b404e0054a97 to your computer and use it in GitHub Desktop.
URL test script
#!/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