Created
October 13, 2009 19:04
-
-
Save konobi/209457 to your computer and use it in GitHub Desktop.
An example of using named blocks in tests to help readability
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Failure_Scenarios: { | |
my $rpx = Net::API::RPX->new({ api_key => 'test' }); | |
{ | |
local $HTTP::Response::SUCCESS = 0; | |
local $HTTP::Response::STATUS = '500 the tubes were clogged'; | |
throws_ok { | |
$rpx->auth_info({ token => 'boo' }) | |
} qr{Could not contact RPX: 500 the tubes were clogged}, 'LWP failure handled'; | |
} | |
local $HTTP::Response::CONTENT = '{ "stat": "fail", "err": { "code": "2", "msg": "server went pop" } }'; | |
throws_ok{ | |
$rpx->auth_info({ token => 'yelp' }) | |
} qr{RPX returned error of type 'Data not found' with message: server went pop}, 'RPX failure handled'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment