Test::Mock::Furl - Mocks Furl for testing
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;
Test::Mock::Furl is the mock module for teting Furl
Test::Mock::Furl
The following variables are exported by default:
The mock Furl object - a Test::MockObject object
The mock Furl::HTTP object - a Test::MockObject object
The mock Furl::Request object - a Test::MockObject object
The mock Furl::Response object - a Test::MockObject object
Test::Mock::Furl is hosted on github <http://github.com/bayashi/Test-Mock-Furl>
Welcome your patches and issues :D
Dai Okabayashi <bayashi@cpan.org>
Test::MockObject
Furl
The code of this module was almost copied from Test::Mock::LWP.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
To install Test::Mock::Furl, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Mock::Furl
CPAN shell
perl -MCPAN -e shell install Test::Mock::Furl
For more information on module installation, please visit the detailed CPAN module installation guide.