NAME

Test::Mojo::Server - Server Tests

SYNOPSIS

use Curse::Transaction;
use Mojo::Test::Server;

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

DESCRIPTION

Mojo::Test::Server is a test harness for server tests.

ATTRIBUTES

command

my $command = $server->command;
$server     = $server->command("lighttpd -D -f $config");

debug

my $debug = $server->debug;
$server   = $server->debug(1);

pid

my $pid = $server->pid;

port

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

script

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

timeout

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

tmpdir

my $tmpdir = $server->tmpdir;
$server    = $server->tmpdir('/tmp/foo');

METHODS

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

new

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

detect_lib_ok

my $lib = $server->detect_lib_ok;
my $lib = $server->detect_lib_ok('lib test');

detect_script_ok

my $script = $server->detect_script_ok;
my $script = $server->detect_script_ok('script test');

generate_port_ok

my $port = $server->generate_port_ok;
my $port = $server->generate_port_ok('port test');

mk_tmpdir_ok

my $tmpdir = $server->mk_tmpdir_ok;
my $tmpdir = $server->mk_tmpdir_ok('tmpdir test');

render_to_file_ok

my $file = $server->render_to_file_ok($template, '/tmp/file.txt');
my $file = $server->render_to_file_ok(
    $template,
    '/tmp/file.txt',
    [qw/foo bar/],
    'file test'
);

render_to_tmpfile_ok

my $tmpfile = $server->render_to_tmpfile_ok($template);
my $tmpfile = $server->render_to_tmpfile_ok(
    $template,
    [qw/foo bar/],
    'file test'
);

rm_tmpdir_ok

$server->rm_tmpdir_ok('cleanup test');

server_ok

$server->server_ok('server running');

start_daemon_ok

my $port = $server->start_daemon_ok('daemon test');

start_daemon_prefork_ok

my $port = $server->start_daemon_prefork_ok('prefork daemon test');

start_server_ok

my $port = $server->start_server_ok('server test');

start_server_untested_ok

my $port = $server->start_server_untested_ok('server test');

stop_server_ok

$server->stop_server_ok('server stopped');