Test::Mock::Furl(3pm)
π 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 mockFurlobject, which is aTest::MockObjectobject π$Mock_furl_httpβ the mockFurl::HTTPobject, which is aTest::MockObjectobject π₯$Mock_furl_req,$Mock_furl_requestβ the mockFurl::Requestobject, which is aTest::MockObjectobject π«Ά$Mock_furl_res,$Mock_furl_responseβ the mockFurl::Responseobject, which is aTest::MockObjectobject π
π§ 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::MockObjectFurl- 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 isperl v5.42.2, dated2023-07-03, and it's theTest::Mock::Furl(3pm)manpage. mwah π
π¦ where this page comes from
- alpine 3.24: perl-test-mock-furl-doc 0.05-r1 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms