Test::Mock::Furl(3pm)

πŸ“¦ version 0.05, in alpine 3.24

πŸ’– Test::Mock::Furl πŸ’–

okay bestie, so this is Test::Mock::Furl β€” the Perl module that mocks Furl for testing. That's the whole vibe. You want to test your Furl code without actually hitting the network? This is your girl. πŸŽ€


✨ SYNOPSIS ✨

So here's what a test of mocked Furl looks like, fr fr:

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 a mock test of Furl::HTTP? It's giving the same energy, lowkey. Look:

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 testing Furl. That's it, that's the tweet. πŸ’…

🌸 EXPORTS 🌸

The following variables are exported by default β€” like, you don't even have to ask, they just show up:

  • $Mock_furl β€” the mock Furl object, which is a Test::MockObject object πŸ‘‘
  • $Mock_furl_http β€” the mock Furl::HTTP object, which is a Test::MockObject object πŸ”₯
  • $Mock_furl_req, $Mock_furl_request β€” the mock Furl::Request object, which is a Test::MockObject object 🫢
  • $Mock_furl_res, $Mock_furl_response β€” the mock Furl::Response object, which is a Test::MockObject object πŸ’œ

🧚 REPOSITORY 🧚

Test::Mock::Furl is hosted on github at http://github.com/bayashi/Test-Mock-Furl β€” go say hi!

Patches and issues are welcome, fr fr :D πŸ™ˆ


⭐ AUTHOR ⭐

Dai Okabayashi <bayashi@cpan.org>


🌈 SEE ALSO 🌈

  • Test::MockObject
  • Furl
  • The code of this module was almost copied from Test::Mock::LWP. (iykyk πŸ’€)

πŸ’€ LICENSE πŸ’€

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


πŸ“ cute little sign-off: this page is perl v5.42.2, dated 2023-07-03, and it's the Test::Mock::Furl(3pm) manpage. mwah πŸ’‹
πŸ“¦ where this page comes from