Skip to content

Instantly share code, notes, and snippets.

@memowe
Created February 12, 2012 18:45
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 memowe/1810171 to your computer and use it in GitHub Desktop.
Save memowe/1810171 to your computer and use it in GitHub Desktop.
use Mojo::Base -strict;
use Test::More tests => 8;
use Test::Mojo;
use Mojolicious::Lite;
use FindBin;
get '/first' => {template => '23'};
get '/second' => {template => '42'};
# Create tester
my $t = Test::Mojo->new;
# Found 23 in default template directory
$t->get_ok('/first')->status_is(200)->content_like(qr/^23$/);
# template2/42 not found
$t->get_ok('/second')->status_is(404);
# Add second template root and refresh templates cache
push @{$t->app->renderer->roots}, "$FindBin::Bin/templates2";
delete $t->app->renderer->{templates};
# Found 42 in template2 directory
$t->get_ok('/second')->status_is(200)->content_like(qr/^42$/);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment