What can I do to Makefile.PL so that when I run make test it runs the test suite with dancer environment set to 'test'?
Question
I would like to be able to just type "make test" in a dancer app toplevel source directory (the one that was generated by "dancer -a appname") and have it run the tests with the environment set to 'test'.
Or if anyone can point me to repository that I can refer to as a sort of "best practice for developing dancer app" for this that would be great!
Solution
I did some checking and found the following thread on the dancer-users mailing list:
http://lists.perldancer.org/pipermail/dancer-users/2011-March/001277.html
In a nutshell; In your test files include:
use Dancer::Test;
Dancer::set environment => 'testing';
Dancer::Config->load;
Don't do:
use Dancer;
I've not tested this though; but the user from the post states that it worked for them....
OTHER TIPS
You could modify the makefile to set the DANCER_ENVIRONMENT variable appropriately.
If I had my druthers, just using Dancer::Test would automatically set the environment though.