Skip to content

Instantly share code, notes, and snippets.

@moritz
Created March 14, 2011 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moritz/869209 to your computer and use it in GitHub Desktop.
Save moritz/869209 to your computer and use it in GitHub Desktop.
myapp.pl
#!/usr/bin/env perl
use Mojolicious::Lite;
get '/' => sub {
my $self = shift;
$self->render('index');
};
app->start unless caller;
__DATA__
@@ index.html.ep
% title 'Welcome';
<ul>
<li><span>foo</span></li>
<li><span>bar</span></li>
</ul>
$ mojo version
CORE
Perl (5.012002, linux)
Mojolicious (1.14, Smiling Cat Face With Heart-Shaped Eyes)
OPTIONAL
IO::Epoll (not installed)
IO::KQueue (not installed)
IO::Socket::IP (not installed)
IO::Socket::SSL (not installed)
Net::Rendezvous::Publish (not installed)
Thanks for testing a development release, you are awesome!
$ ./myapp.pl get / li all text
Mon Mar 14 15:34:14 2011 info Mojo::Server::Daemon:316 [23574]: Server listening (http://*:19418)
Mon Mar 14 15:34:14 2011 debug Mojolicious:22 [23574]: Your secret passphrase needs to be changed!!!
Mon Mar 14 15:34:14 2011 debug Mojolicious::Plugin::RequestTimer:24 [23574]: GET / (Mojolicious (Perl)).
Mon Mar 14 15:34:14 2011 debug Mojolicious::Routes:418 [23574]: Dispatching callback.
Mon Mar 14 15:34:14 2011 debug Mojolicious::Plugin::RequestTimer:48 [23574]: 200 OK (0.003301s, 302.939/s).
foo
bar
$ perl test.pl
1..3
ok 1 - get /
ok 2 - 200 OK
Use of uninitialized value $this in pattern match (m//) at test.pl line 7.
not ok 3 - li all
# Failed test 'li all'
# at test.pl line 7.
# undef
# doesn't match '(?-xism:foo)'
# Looks like you failed 1 test of 3.
use Test::More tests => 3;
use Test::Mojo;
require "myapp.pl";
my $t = Test::Mojo->new;
$t->get_ok('/')
->status_is(200)
->text_like('li all' => qr/foo/);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment