[Dancer-users] Having an environments/test.yml

Simon Wistow simon at thegestalt.org
Tue Apr 12 22:44:29 CEST 2011


I want to have some test specific stuff in an environment/test.yml (db 
username and password, memcache prefixes etc etc). Sounds simple enough 
except that in order to get it to work I had to write something like 
this

package Dancer::TestEnviroment;
use strict;
use Cwd;

sub import {
  my $class = shift;

  $ENV{DANCER_ENVIRONMENT} = 'test';
  $ENV{DANCER_CONFDIR}     = getcwd;  
  unless ($INC{Dancer}) {
    require Dancer;
    Dancer->import(@_);
  }
  Dancer::setting(appdir  => getcwd);
  Dancer::Config->load;
}

1;


and the use that from the top of ever one of my test files. Which seems 
a little ... long winded. 

Am I doing something wrong? Is there an easier way to do this? 




More information about the Dancer-users mailing list