Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
let Test::Mojo fail a little more gracefully in general
  • Loading branch information
kraih committed Nov 25, 2014
1 parent 49790e4 commit baf1429
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/Test/Mojo.pm
Expand Up @@ -97,7 +97,7 @@ sub element_exists_not {

sub finish_ok {
my $self = shift;
$self->tx->finish(@_);
$self->tx->finish(@_) if $self->tx->is_websocket;
Mojo::IOLoop->one_tick while !$self->{finished};
return $self->_test('ok', 1, 'closed WebSocket');
}
Expand Down Expand Up @@ -332,7 +332,7 @@ sub _message {
}

# Decode text frame if there is no type check
else { $msg = decode 'UTF-8', $msg if $type eq 'text' }
else { $msg = decode 'UTF-8', $msg if ($type // '') eq 'text' }

return $self->_test($name, $msg // '', $value, $desc);
}
Expand All @@ -348,7 +348,7 @@ sub _request_ok {
$self->ua->start(
$tx => sub {
my ($ua, $tx) = @_;
$self->tx($tx);
$self->{finished} = [] unless $self->tx($tx)->tx->is_websocket;
$tx->on(finish => sub { shift; $self->{finished} = [@_] });
$tx->on(binary => sub { push @{$self->{messages}}, [binary => pop] });
$tx->on(text => sub { push @{$self->{messages}}, [text => pop] });
Expand Down

0 comments on commit baf1429

Please sign in to comment.