Test::Stub - Stub! Stub! Stub!
use Test::Stub; # DSL style my $agent = LWP::UserAgent->new(); stub($agent)->get(HTTP::Response->new(200, "OK")); is($agent->get('http://www.aiseikai.or.jp/')->code, 200); # simple style my $agent = LWP::UserAgent->new(); make_stub($agent, 'get', HTTP::Response->new(200, "OK")); is($agent->get('http://www.aiseikai.or.jp/')->code, 200);
Test::Stub is a simple stubbing library for Perl5.
Create a new instance of Test::Stub::Driver.
Make monadic class from blessed($object) and add a $method with $stub.
This class only provides a AUTOLOAD method.
AUTOLOAD method rebless the $stuff to anonymous class.
$stuff
For example. After calling following code:
stub($stuff)->foo('bar');
$stuff->foo() returns 'bar'.
$stuff->foo()
Tokuhiro Matsuno <tokuhirom AAJKLFJEF@ GMAIL COM>
The interface was taken from Test::Double.
Copyright (C) Tokuhiro Matsuno
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Test::Stub, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Stub
CPAN shell
perl -MCPAN -e shell install Test::Stub
For more information on module installation, please visit the detailed CPAN module installation guide.