Skip to content

Instantly share code, notes, and snippets.

@konobi
Created October 13, 2009 19:04
Show Gist options
  • Save konobi/209457 to your computer and use it in GitHub Desktop.
Save konobi/209457 to your computer and use it in GitHub Desktop.
An example of using named blocks in tests to help readability
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