Skip to content

Commit

Permalink
Add the test for xslate
Browse files Browse the repository at this point in the history
  • Loading branch information
dann committed Mar 24, 2013
1 parent c341655 commit b78392e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
10 changes: 3 additions & 7 deletions t/03_options.t
@@ -1,22 +1,18 @@
use strict;
use Test::More;
use Test::Requires qw(Text::Xslate);

use Plack::Middleware::Profiler::KYTProf;
use Plack::Test;
use Plack::Builder;
use HTTP::Request::Common;
use t::TestProfile;
use t::TestPerson;

# FIXME use logger to test
subtest 'threshold option' => sub {
my $app = sub {
my $env = shift;
my $tx = Text::Xslate->new;
my $template = q{
<h1>hello world</h1>
};
print $tx->render_string( $template, {} );

t::TestPerson->name();

return [ '200', [ 'Content-Type' => 'text/plain' ], ["Hello World"] ];
};
Expand Down
32 changes: 32 additions & 0 deletions t/04_xslate.t
@@ -0,0 +1,32 @@
use strict;

use Test::More;
use Test::Requires qw(Text::Xslate);
use Plack::Middleware::Profiler::KYTProf;
use Plack::Test;
use Plack::Builder;
use HTTP::Request::Common;
use File::Spec ();

# TODO use logger to test profiling
subtest 'Can profile a test module with the custom profile' => sub {
my $app = sub {
my $env = shift;
return [ '200', [ 'Content-Type' => 'text/plain' ], ["Hello World"] ];
};

$app = Plack::Middleware::Profiler::KYTProf->wrap($app);

test_psgi $app, sub {
my $cb = shift;
my $res = $cb->( GET "/" );
warn "Error Occured. Response body:" . $res->content if $res->code eq 500;

my $tx = Text::Xslate->new;
$tx->render(File::Spec->catfile("t", "hello.tx"), {});

is $res->code, 200, "Response is returned successfully";
};
};

done_testing;
1 change: 1 addition & 0 deletions t/hello.tx
@@ -0,0 +1 @@
aaa

0 comments on commit b78392e

Please sign in to comment.