Skip to content

seminull/Test-Mock-LWP-Conditional

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NAME

Test::Mock::LWP::Conditional - stubbing on LWP request

SYNOPSIS

use LWP::UserAgent;
use HTTP::Response;

use Test::More
use Test::Mock::LWP::Conditional;

my $uri = 'http://example.com/';

# global
Test::Mock::LWP::Conditional->stub_request($uri => HTTP::Response->new(503));
is LWP::UserAgent->new->get($uri)->code => 503;

# lexical
my $ua = LWP::UserAgent->new;
$ua->stub_request($uri => sub { HTTP::Response->new(500) });
is $ua->get($uri)->code => 500;
is LWP::UserAgent->new->get($uri)->code => 503;

# reset
Test::Mock::LWP::Conditional->reset_all;
is $ua->get($uri)->code => 200;
is LWP::UserAgent->new->get($uri)->code => 200;

DESCRIPTION

This module stubs out LWP::UserAgent's request.

METHODS

  • stub_request($uri, $res)

    Sets stub response for requesed URI.

  • reset_all

    Clear all stub requests.

AUTHOR

NAKAGAWA Masaki <[email protected]>

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

Test::Mock::LWP, Test::Mock::LWP::Dispatch, Test::MockHTTP, Test::LWP::MockSocket::http

LWP::UserAgent

https://github.com/bblimke/webmock, https://github.com/chrisk/fakeweb

About

LWP mocking module like WebMock

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Perl 99.6%
  • Other 0.4%