[dancer-users] Changing paths for testing purpose

Cymon cymon.ML at gmail.com
Tue Mar 4 00:39:34 GMT 2014


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


More information about the dancer-users mailing list