Upload
astj
View
1.486
Download
0
Tags:
Embed Size (px)
Citation preview
use Test::WWW::Stub; !my $stubbed_res = [ 200, [], ['okay'] ]; my $guard = Test::WWW::Stub->register( q<http://example.com/TEST>, $stubbed_res ); !my $ua = LWP::UserAgent->new; !is $ua->get('http://example.com/TEST')->content, 'okay';
"http://b.hatena.ne.jp/hotentry.rss"
qr<http://*[.]hatenablog[.]com/rss>
URI
[ 200, [], 'OK']
sub { [ 200, [], 'OK']; }
res
use Test::WWW::Stub; my $ua = LWP::UserAgent->new; !$ua->get('http://example.com/HOGE'); # Unexpected external access: GET http://example.com/HOGE at t/hogehoge.t line XX
• Test::Mock::LWP
• Mock::LWP::Request
• Test::Mock::LWP::Conditional
• Test::Mock::LWP::Dispatch
• Test::LWP::MockSocket::http
• and more...
LWP::Protocol::PSGI !!!!!
Your Code !
LWP
HTTP����������� ������������������ world
LWP::Protocol::httppsgi app example.com
psgi app *.hatena.ne.jp/*
For "example.com" For "*.hatena.ne.jp/*" OTHERWISE
LWP::Protocol::PSGI !!!!!
Your Code !
LWP
Test::WWW::Stub : PSGI app !
!Handler example.com
Handler *.hatena.ne.jp/*
Handler ...
ALL
No Fallback