• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

inc/Module/H19-Oct-2013-2,1241,597

lib/Test/Mock/H19-Oct-2013-43099

t/H19-Oct-2013-4029

ChangesH A D19-Oct-2013780 2618

MANIFESTH A D16-Jul-2011536 2423

META.ymlH A D19-Oct-2013486 2524

Makefile.PLH A D16-Jul-2011413 1811

READMEH A D16-Jul-2011848 2919

README

1NAME
2    Test::Mock::LWP - Easy mocking of LWP packages
3
4SYNOPSIS
5
6Make LWP packages to make testing easier.
7
8    use Test::Mock::LWP;
9
10    # Setup fake response content and code
11    $Mock_response->mock( content => sub { 'foo' } );
12    $Mock_resp->mock( code => sub { 201 } );
13
14    # Validate args passed to request constructor
15    is_deeply $Mock_request->new_args, \@expected_args;
16
17    # Validate request headers
18    is_deeply [ $Mock_req->next_call ],
19              [ 'header', [ 'Accept', 'text/plain' ] ];
20
21    # Special User Agent Behaviour
22    $Mock_ua->mock( request => sub { die 'foo' } );
23
24DESCRIPTION
25
26This package arises from duplicating the same code to mock LWP et al in
27several different modules I've written.  This version is very minimalist, but
28works for my needs so far.  I'm very open to new suggestions and improvements.
29