NAME

Test::Mojo::Server - Server Tests

SYNOPSIS

    use Test::Mojo::Server;

    my $server = Test::Mojo::Server->new;
    $server->start_daemon_ok;
    $server->stop_server_ok;

DESCRIPTION

Test::Mojo::Server is a collection of testing helpers specifically for developers of Mojo server bindings.

ATTRIBUTES

Test::Mojo::Server implements the following attributes.

command

    my $command = $server->command;
    $server     = $server->command("/usr/sbin/httpd -X -f 'x.cfg'");
    $server     = $server->command(['/usr/sbin/httpd', '-X', '-f', 'x.cfg']);

Command for external server start.

delay

    my $delay = $server->delay;
    $server   = $server->delay(2);

Time to wait between server checks in seconds, defaults to 1.

executable

    my $script = $server->executable;
    $server    = $server->executable('mojo');

Mojo executable name.

home

    my $home = $server->home;
    $server  = $server->home(Mojo::Home->new);

Home for application.

pid

    my $pid = $server->pid;

Process id for external server.

port

    my $port = $server->port;
    $server  = $server->port(3000);

Server port.

timeout

    my $timeout = $server->timeout;
    $server     = $server->timeout(5);

Timeout for external server startup.

METHODS

Test::Mojo::Server inherits all methods from Mojo::Base and implements the following new ones.

new

    my $server = Test::Mojo::Server->new;

Construct a new Test::Mojo::Server object.

find_executable_ok

    my $path = $server->find_executable_ok;

Try to find Mojo executable.

generate_port_ok

    my $port = $server->generate_port_ok;

server_ok

    $server->server_ok;

Check if server is still running.

start_daemon_ok

    my $port = $server->start_daemon_ok;

Start external Mojo::Server::Daemon server.

start_daemon_prefork_ok

    my $port = $server->start_daemon_prefork_ok;

Start external Mojo::Server::Daemon::Prefork server.

start_server_ok

    my $port = $server->start_server_ok;

Start external server.

start_server_untested_ok

    my $port = $server->start_server_untested_ok;

Start external server without testing the port.

stop_server_ok

    $server->stop_server_ok;

Stop external server.

SEE ALSO

Mojolicious, Mojolicious::Guides, http://mojolicious.org.