NAME

Test::HTTP - utility to test LWP usage without actual HTTP requests

SYNOPSIS

use Test::HTTP;

my $ua;
http_test_setup { $ua = $_[0] };

http_cmp( sub { $ua->do_some_http_request() },
    [
        as_string => re('image1_link=\S+mail\.rambler\.ru'),
        # these are pairs of method => test againt its return
        # value
    ]
);
...

FUNCTIONS

http_test_setup

This function takes one coderef argument which gets called with a specially crafted (with mocked methods) LWP::UserAgent instance before each test. All actions should use this UA to be tested.

http_cmp This is a wrapper around Test::Deep::cmp_deeply which does the actual tests.

It takes 4 arguments.

$code

This is the code to test. It gets called.

$methods

This is an arrayref of pairs 'method' => 'test against its return value'. It gets passed into Test::Deep::methods to construct a test against HTTP::Request which is provided by LWP.

$msg

TAP message, is directly passed to Test::Deep::cmp_deeply.

$resp

HTTP::Response instance which is returned as a fake response to HTTP::Request from simple_request() method. Defaults to simple '200 Ok' empty response.