[dancer-users] How do you test the internal methods of a plugin?

Steve Dondley sdondley at gmail.com
Fri Nov 9 15:29:19 GMT 2018

I'm trying to test the internal methods of a plugin in the context of a
running test app. The following doesn't work but should give you an idea of
what I want to accomplish:

use Plack::Test;
use HTTP::Request::Common;
{ package TestApp;
  use Dancer2;
  use Dancer2::Plugin::Menu;

  get '/'     => sub { return template 'index' };
  get '/test' => sub {
    template 'index.tt', {
      html => 'hi',

my $test = Plack::Test->create( TestApp->to_app );
my $res;

my $menu = Dancer2::Plugin::Menu->new(app => $test);

# test the return value of plugin method
my $result = $menu->_convert_routes_to_array;

cmp_deeply($result, [ '/', '/test' ], 'returns array of menu paths');

Is there a way to do this?

Prometheus Labor Communications, Inc.

UnionConnect Phone App for Labor Unions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20181109/97218626/attachment.html>

More information about the dancer-users mailing list