Permalink
Browse files

Added more tests. Added Dancer example

  • Loading branch information...
miyagawa committed Mar 16, 2010
1 parent ec769e0 commit 4fc84bf6b2b24410bf181a0d1c8c165cda361b80
Showing with 27 additions and 0 deletions.
  1. +25 −0 dancer.pl
  2. +2 −0 tester.pl
View
@@ -0,0 +1,25 @@
# PSGI application bootstraper for Dancer
use Dancer::Config 'setting';
setting apphandler => 'PSGI';
Dancer::Config->load;
use Dancer;
get '/' => sub {
content_type 'text/plain';
return "Hello World";
};
get '/blog/:year/:month' => sub {
return "Blog posts from " . params->{year} . "/" . params->{month};
};
post '/comment' => sub {
return "Comment posted with body=" . params->{body};
};
# return PSGI app
sub {
my $request = Dancer::Request->new(shift);
Dancer->dance($request);
};
View
@@ -9,9 +9,11 @@
my $cb = shift; my $cb = shift;
my $res = $cb->(GET "/"); my $res = $cb->(GET "/");
is $res->content_type, 'text/plain';
like $res->content, qr/Hello World/; like $res->content, qr/Hello World/;
$res = $cb->(GET "/blog/2010/02"); $res = $cb->(GET "/blog/2010/02");
is $res->content_type, 'text/html';
like $res->content, qr/Blog posts from 2010\/02/; like $res->content, qr/Blog posts from 2010\/02/;
$res = $cb->(POST "/comment", { name => "miyagawa", body => "Awesome blog!" }); $res = $cb->(POST "/comment", { name => "miyagawa", body => "Awesome blog!" });

0 comments on commit 4fc84bf

Please sign in to comment.