Last active
September 27, 2015 06:39
-
-
Save kraih/1227900 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env perl | |
use Mojo::Base -strict; | |
use utf8; | |
use Test::More tests => 4; | |
use Mojolicious::Lite; | |
use Test::Mojo; | |
# Tiny echo web service | |
websocket '/echo' => sub { | |
my $self = shift; | |
$self->on(message => sub { | |
my ($self, $message) = @_; | |
$self->send("echo: $message"); | |
}); | |
}; | |
# Send message and receive echo | |
my $t = Test::Mojo->new; | |
$t->websocket_ok('/echo') | |
->send_ok('I ♥ Mojolicious') | |
->message_ok | |
->message_is('echo: I ♥ Mojolicious') | |
->finish_ok; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment