Hi, I wrote this test: use strict; use warnings; use Test::More; use Test::TCP; use LWP::UserAgent; use FindBin; use t::testapp::lib::Site; BEGIN { $ENV{DANCER_VIEWS} = "views"; } Test::TCP::test_tcp( client => sub { my $port = shift; my $ua = LWP::UserAgent->new; my $res = $ua->get("http://127.0.0.1:$port/admin"); ok($res->is_success); }, server => sub { my $port = shift; use Dancer2; set(show_errors => 1, startup_info => 0, port => $port, logger => 'capture', log => 'debug', ); Site->runner->server->port($port); start; }, ); done_testing; t::testapp::lib::Site is just a dummy app I created as environment to test libraries. Problem is that it search for views in t/testapp/views, but I want it to find them under t/../views. I know that running the test as DANCER_VIEWS=views t/001_app.t it works but how can i force DANCER_VIEWS=views inside the code? I tried $ENV{DANCER_VIEWS} = $other_path but it's not working... Thank you! -- Cymon http://perlishscrewdriver.blogspot.com
On 3/3/2014 17:45, Warren Young wrote:
On 3/3/2014 17:39, Cymon wrote:
$ENV{DANCER_VIEWS} = "views";
You can set that in the config.yml file, which you should already have if you used the "dancer" helper app to create your application shell:
views: "../views"
or whatever.
Also: https://metacpan.org/pod/Dancer::Config#views-directory
Il giorno Mon, 03 Mar 2014 17:45:55 -0700 Warren Young <warren@etr-usa.com> ha scritto:
On 3/3/2014 17:39, Cymon wrote:
$ENV{DANCER_VIEWS} = "views";
You can set that in the config.yml file, which you should already have if you used the "dancer" helper app to create your application shell:
views: "../views"
or whatever.
Hi, thank you for the advice! It worked! Problem is that first time I tried to put this configuration directly in the Test::TCP server configuration server => sub { my $port = shift; use Dancer2; set(show_errors => 1, startup_info => 1, port => $port, logger => 'capture', log => 'debug', views => '../../views' ); Dancer2->runner->server->port($port); start; }, but it didn't work so I had to put it directly in the config.yml. It seems that no configuration written as a set in the server of Test::TCP is correctly used. Does someone know why? Where should I put configurations good only for tests that I don't want in config.yml? -- Cymon http://perlishscrewdriver.blogspot.it/
participants (2)
-
Cymon -
Warren Young