[Dancer-users] Devel::Cover won't cover route handlers?

sawyer x xsawyerx at gmail.com
Thu Oct 27 21:30:37 CEST 2011


 On Thu, Oct 27, 2011 at 8:52 PM, Michael Alan Dorman <
mdorman at ironicdesign.com> wrote:

> sawyer x <xsawyerx at gmail.com> writes:
> > Try moving the route code into subroutines and calling those subs'
> > references in the route definition.
> >
> > Tell me how it goes.
>
> Hmmm.
>
> That does work, at the price of being something of an aesthetic
> disaster.
>

It was just to check whether my assumption was correct.

The problem isn't really with Dancer. Route dispatching is basically a form
of Inversion of Control (IOC), where you give Dancer the code to run and it
runs the code for you. When you give it strict coderefs, the code inside
those refs can't be tested. When you provide named subroutines, it can be
tracked.

This is perhaps something that can be fixed (or featured) in Devel::Cover
and perhaps not. When using Moose and providing any attribute configurations
in a subroutine reference (builder, default, even subtypes) you will not be
able to get coverage for that code. That is one reason to use a named
subroutine for a builder.

Perhaps with Dancer 2 we could provide a builder-like behavior for routes,
in which you'll be able to specify subroutine names in the class instead of
just subrefs. Feel free to suggest it once we finish up the spec.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.backup-manager.org/pipermail/dancer-users/attachments/20111027/23a23e1f/attachment.htm>


More information about the Dancer-users mailing list