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
perl -Ilib t/002_index_route.t 1..2 ok 1 - a route handler is defined for / ok 2 - response status is 200 for / So turns out having "use Dancer ':moose';" seems to be the trigger. Remove that and the problem goes away. From what I understand this simply stops the export "after" and "before". Guess we need em? Obviously I've overlooked something here.. Complete file: package MyApp; use Dancer ':moose'; our $VERSION = '0.1'; get '/' => sub { template 'index', { page => 'index' }; }; true; 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. Change "Dancer ':moose';" to "use Dancer ':syntax';" and you'll get: perl -Ilib t/002_index_route.t 1..2 ok 1 - a route handler is defined for / ok 2 - response status is 200 for / In fact changing the code in "Dancer::Test" from "use Dancer ':syntax', ':tests';" to "use Dancer ':moose', ':tests';" and then run the tests on a freshly generated dancer app and I get the same error. So I've started looking into the internals of dancer to try and work out what's going on, at the very least I might learn something. However by all means, don't hold back telling me what on earth am I doing wrong. :) On Sun, Aug 5, 2012 at 2:51 AM, Sarah Fuller <sarah@averna.id.au> wrote:
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
Ummm If I replace... use Dancer ':moose'; With... use Dancer qw(:syntax !before !after); Then problem solved. Weird... Would love like to know why but for the moment I have to move on. Sorry for the spam and hope someone out there saves some time from my mistakes. On Mon, Aug 6, 2012 at 12:00 AM, Sarah Fuller <sarah@averna.id.au> wrote:
perl -Ilib t/002_index_route.t 1..2 ok 1 - a route handler is defined for / ok 2 - response status is 200 for /
So turns out having "use Dancer ':moose';" seems to be the trigger. Remove that and the problem goes away. From what I understand this simply stops the export "after" and "before". Guess we need em? Obviously I've overlooked something here..
Complete file:
package MyApp;
use Dancer ':moose'; our $VERSION = '0.1';
get '/' => sub { template 'index', { page => 'index' }; };
true;
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.
Change "Dancer ':moose';" to "use Dancer ':syntax';" and you'll get:
perl -Ilib t/002_index_route.t 1..2 ok 1 - a route handler is defined for / ok 2 - response status is 200 for /
In fact changing the code in "Dancer::Test" from "use Dancer ':syntax', ':tests';" to "use Dancer ':moose', ':tests';" and then run the tests on a freshly generated dancer app and I get the same error.
So I've started looking into the internals of dancer to try and work out what's going on, at the very least I might learn something. However by all means, don't hold back telling me what on earth am I doing wrong. :)
On Sun, Aug 5, 2012 at 2:51 AM, Sarah Fuller <sarah@averna.id.au> wrote:
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
participants (1)
-
Sarah Fuller