The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Test::Mock::Furl - Mocks Furl for testing

SYNOPSIS

The test of mocked Furl.

    use Test::More;
    use Test::Mock::Furl;
    use Furl;
    use Furl::Request;

    $Mock_furl->mock(request => sub { Furl::Response->new } );
    $Mock_furl_res->mock(message => sub { 'ok ok ok' } );

    my $req  = Furl::Request->new('GET' => 'http://example.com/');
    my $furl = Furl->new;
    my $res  = $furl->request($req);

    ok $res->is_success;
    is $res->code, 200;
    is $res->content, '';
    is $res->message, 'ok ok ok';

    done_testing;

And mock test of Furl::HTTP is like below.

    use Test::More;
    use Test::Mock::Furl;

    use Furl::HTTP;

    $Mock_furl_http->mock(
        request => sub {
            ( 1, 200, 'OK', ['content-type' => 'text/plain'], 'mock me baby!' );
        },
    );

    my $furl = Furl::HTTP->new;
    my @res  = $furl->request(
        method => 'GET', host => 'example.com', port => 80, path => '/',
    );

    is $res[4], 'mock me baby!';

    done_testing;

DESCRIPTION

Test::Mock::Furl is the mock module for teting Furl

EXPORTS

The following variables are exported by default:

$Mock_furl

The mock Furl object - a Test::MockObject object

$Mock_furl_http

The mock Furl::HTTP object - a Test::MockObject object

$Mock_furl_req, $Mock_furl_request

The mock Furl::Request object - a Test::MockObject object

$Mock_furl_res, $Mock_furl_response

The mock Furl::Response object - a Test::MockObject object

REPOSITORY

Test::Mock::Furl is hosted on github <http://github.com/bayashi/Test-Mock-Furl>

Welcome your patches and issues :D

AUTHOR

Dai Okabayashi <bayashi@cpan.org>

SEE ALSO

Test::MockObject

Furl

The code of this module was almost copied from Test::Mock::LWP.

LICENSE

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