[Dancer-users] Writing tests for restricted parts of Dancer application

Anatoly Bashmakov anatoly.bashmakov at gmail.com
Sun May 27 16:38:35 CEST 2012


Hello.

What are the proper way to write tests for parts of Dancer application which
are acceptable after user logged in?

I.e., for example:

----
hook 'before' => sub {
    if ( !session('username') and request->path !~ qr{^/login} ) {
        redirect '/login';
    }
};

get '/login' => sub {
    # appropriate template
};

post '/login' => sub {
    # set up session('username')
};

get '/auth_only' => sub { ... }
----

How can I write tests for '/auth_only'?

-- 
Anatoly


More information about the Dancer-users mailing list