Permalink
Browse files

Merge pull request #1 from marciof/master

Differentiate real HTTP errors from LWP-generated ones.
  • Loading branch information...
2 parents 1a631a0 + 2e6dbd6 commit e307152bcc4575e53e28b76572600f4a0c200405 @cosimo committed Dec 16, 2013
Showing with 8 additions and 0 deletions.
  1. +8 −0 lib/Test/Cukes/HTTP.pm
View
@@ -118,6 +118,7 @@ sub check_status_code_isnt {
if (! $res) {
return fail("No response object. Maybe you need a 'Given I go to \"<url>\"' first?");
}
+ return fail($res->message) if _is_internal_error_response($res);
my $status = $res->status_line;
if (ref $expected eq "Regexp") {
unlike($status => $expected,
@@ -138,6 +139,7 @@ sub check_status_code {
if (! $res) {
return fail("No response object. Maybe you need a 'Given I go to \"<url>\"' first?");
}
+ return fail($res->message) if _is_internal_error_response($res);
my $status = $res->status_line;
if (ref $expected eq "Regexp") {
like($status => $expected,
@@ -195,6 +197,12 @@ sub check_redirects_chain_for {
return $found_redir;
}
+sub _is_internal_error_response {
+ my ($res) = @_;
+ return !$res->is_success
+ && ($res->header('Client-Warning') eq 'Internal response');
+}
+
Given qr{(?:i will follow) a max of (\d+) redirects}, sub {
my $ua = get_useragent();
$ua->max_redirect($1);

0 comments on commit e307152

Please sign in to comment.