[Dancer-users] Question regarding Dancer::Test

Sarah Fuller sarah at averna.id.au
Sat Aug 4 18:51:17 CEST 2012


Hello Dancers! :)

Firstly please forgive me for bothering all of you with my silly little
issues. However I've been using dancer for a number of projects for awhile
now (loving it!) and haven't come across this before. Perhaps its just the
lack of sleep but I've not been able to work out what's going on. I don't
expect a magic bullet but if someone out there has some suggestions that
might point me in the right direction I'd be most grateful.

The problem: I've been using Dancer::Test and testing the app as I go.
Somehow have managed to get it into a state whereby testing any route that
returns a template with say "response_status_is" returns 500. Thing is, the
routes are working and returning 200. They work in the browser and they
work when I check them with curl. All routes returning a serializer or
indeed just doing a "return;" work fine too. I've included some example
information below, happy to share any other details that may help me sort
this out.

I'm sure I've just overlooked something....

Thank you.

Sarah Fuller


ROUTE:

get '/' => sub
{
=pod
    main page
=cut

    template 'index';
};

---

TEST FILE:

use Test::More tests => 2;

use warnings;
use strict;

# the order is important
use MyApp;
use Dancer::Test;

route_exists [GET => '/'], 'a route handler is defined for /';
response_status_is ['GET' => '/'], 200, 'response status is 200 for /';

---

TEST RESULT:

perl -Ilib t/002_index_route.t
1..2
ok 1 - a route handler is defined for /
not ok 2 - response status is 200 for /
#   Failed test 'response status is 200 for /'
#   at t/002_index_route.t line 11.
#          got: '500'
#     expected: '200'
# Looks like you failed 1 test of 2.

---

MANUAL TEST:

curl -I http://localhost:3000/
HTTP/1.0 200 OK
Server: Perl Dancer 1.3098
Content-Length: 9093
Content-Type: text/html; charset=utf-8
Set-Cookie: dancer.session=768955642575256601817434832617820228; path=/;
expires=Sun, 05-Aug-2012 00:33:47 GMT; HttpOnly
X-Powered-By: Perl Dancer 1.3098

---

CONFIG FILE:

appname: "app"
layout: "main"
charset: "UTF-8"
serializer: "JSON"

session: Storable
session_dir: /tmp/dancer_app
session_expires: 28800

template: "template_toolkit"

engines:
  template_toolkit:
    encoding:  'utf8'
    start_tag: '[%'
    end_tag:   '%]'

plugins:
  ValidateTiny:
    rules_dir: validation
    error_prefix: err_
    is_full: 0

  Passphrase:
    default: bcrypt
    bcrypt:
      cost: 12

  DBIC:
   default:
     schema_class: MyApp::Schema
     dsn:  dbi:mysql:MyApp
     user: user
     pass: pass
     options:
       RaiseError: 1
       PrintError: 1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.backup-manager.org/pipermail/dancer-users/attachments/20120805/69a85bfe/attachment.htm>


More information about the Dancer-users mailing list