Your SlideShare is downloading. ×
0
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Test::WWW::Stub
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Test::WWW::Stub

46

Published on

2015/06/02 Shibuya.pm テクニカルトーク #7 LT

2015/06/02 Shibuya.pm テクニカルトーク #7 LT

Published in: Engineering
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
46
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Test::WWW::Stub Shibuya Perl Mongersテクニカルトーク#17 LT 2015/06/02 @ast_j (GitHub astj / hatena id:astj)
  • 2. HTTPリクエストする モジュールのテストを安全に LWPで
  • 3. Test::WWW::Stub
  • 4. 外部アクセスのモック
  • 5. 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';
  • 6. "http://b.hatena.ne.jp/hotentry.rss" qr<http://*[.]hatenablog[.]com/rss> URI [ 200, [], 'OK'] sub { [ 200, [], 'OK']; } res
  • 7. 外部アクセスのブロック
  • 8. LWP経由の全てのリクエストを塞ぐ モックされてないリクエストにはdiag
  • 9. 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
  • 10. 類似モジュール
  • 11. • Test::Mock::LWP • Mock::LWP::Request • Test::Mock::LWP::Conditional • Test::Mock::LWP::Dispatch • Test::LWP::MockSocket::http • and more...
  • 12. useするだけで外部アクセスを塞げる インターフェースがシンプル PSGI res/appが使える Why Test::WWW::Stub
  • 13. LWP::Protocol::PSGI?
  • 14. Your Code ! LWP HTTP

×