Skip to content

Instantly share code, notes, and snippets.

@andrewsolomon
Created October 25, 2014 21:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewsolomon/8c05fa06f6df3d6938d9 to your computer and use it in GitHub Desktop.
Save andrewsolomon/8c05fa06f6df3d6938d9 to your computer and use it in GitHub Desktop.
Dancer2 0.153 Unit testing example
#!/usr/bin/perl
use Test::More tests => 2;
use strict;
use warnings;
use Plack::Test;
use HTTP::Request::Common;
use GuArt::Controller;
my $app = GuArt::Controller->psgi_app;
my $test = Plack::Test->create($app);
my $res = $test->request( GET "/");
is $res->code, 302, 'response status is 302 for / without logging in';
$res = $test->request( POST "/",[
login_user => 'Andrew'
]);
is($res->code, 200, 'successful 200 response on login');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment