Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions t/082-exceptions.rakutest
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@ use HTTP::UserAgent;

plan 4;

my $ua = HTTP::UserAgent.new;
my $res;
if %*ENV<NETWORK_TESTING> {
my $ua = HTTP::UserAgent.new;
my $res;

lives-ok { $res = $ua.get('http://httpbin.org/status/404') }, "no exception - expect 404";
lives-ok { $res = $ua.get('http://httpbin.org/status/404') }, "no exception - expect 404";

ok !$res.is-success, "and it isn't successful";
is $res.code, 404, "and a 404";
ok !$res.is-success, "and it isn't successful";
is $res.code, 404, "and a 404";

$ua = HTTP::UserAgent.new(:throw-exceptions);
$ua = HTTP::UserAgent.new(:throw-exceptions);

throws-like { $ua.get('http://httpbin.org/status/404') }, X::HTTP::Response, message => "Response error: '404 Not Found'", response => HTTP::Response;
} else {
skip-rest "NETWORK_TESTING not set won't do network tests";
}

throws-like { $ua.get('http://httpbin.org/status/404') }, X::HTTP::Response, message => "Response error: '404 Not Found'", response => HTTP::Response;

# vim: expandtab shiftwidth=4
Loading