Skip to content

Commit

Permalink
Added an unit test with Plack::Test
Browse files Browse the repository at this point in the history
  • Loading branch information
miyagawa committed Oct 1, 2009
1 parent ec0144c commit 61710b6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Makefile.PL
Expand Up @@ -2,7 +2,11 @@ use inc::Module::Install;
name 'HTML-Mason-PSGIHandler';
all_from 'lib/HTML/Mason/PSGIHandler.pm';
readme_from 'lib/HTML/Mason/PSGIHandler.pm';

requires 'HTML::Mason';

build_requires 'Test::More';
test_requires 'Test::Requires';
use_test_base;
auto_include_deps;
author_tests('xt');
Expand Down
4 changes: 4 additions & 0 deletions t/hello.mhtml
@@ -0,0 +1,4 @@
% my $var = "Foo";
Hello World <% $var %>
<% do { join ",", $r->params } %>

23 changes: 23 additions & 0 deletions t/hello.t
@@ -0,0 +1,23 @@
use strict;
use FindBin;
use Test::More;
use Test::Requires qw(Plack::Test);
use Plack::Test;

use HTML::Mason::PSGIHandler;

my $h = HTML::Mason::PSGIHandler->new(
comp_root => $FindBin::Bin,
);

my $handler = sub { $h->handle_psgi(@_) };

test_psgi app => $handler, client => sub {
my $cb = shift;
my $res = $cb->(HTTP::Request->new(GET => "http://localhost/hello.mhtml?foo=bar"));
like $res->content, qr/Hello World Foo/;
like $res->content, qr/foo,bar/;
};

done_testing;

0 comments on commit 61710b6

Please sign in to comment.