Skip to content

Instantly share code, notes, and snippets.

@jashank
Created March 12, 2013 07:10
Show Gist options
  • Save jashank/5140883 to your computer and use it in GitHub Desktop.
Save jashank/5140883 to your computer and use it in GitHub Desktop.
Dancer2::Test misbehaviour
#!/usr/bin/perl -w
use warnings;
use strict;
=head1 NAME
dancer2test.pl -- test code for Dancer2::Test
=head1 SYNOPSIS
dancer2test.pl
=head1 DESCRIPTION
This is a minimal complete demonstration for a bug in Dancer2::Test
which I have no idea how to fix.
First, we set up a simple Dancer 2 application, in the C<TestApp>
package. It pulls in Dancer 2 and configures one route, which returns
a known string.
=cut
package TestApp;
use Dancer2;
get '/' => sub {
"test reference 1";
};
=pod
Next, we switch back to the main package, and set up Dancer2::Test to
see our test application.
=cut
package main;
use Test::More import => ['!pass'], tests => 1;
use Dancer2 ':syntax';
use Dancer2::Test apps => 'TestApp';
=pod
Finally, we query the C<response_content_is> function of Dancer2::Test.
=cut
response_content_is ([GET => '/'], "test reference 1", 'reference passing');
=pod
=head1 DISCUSSION
This test I<always> fails, for reasons I don't quite grasp.
If I turn on C<DANCER_DEBUG_CORE> in the environment, it's obvious
that the app is being configured correctly, and in fact, if we were to
simply tell the application to dance, it would.
This suggests, to me, that the bug is in Dancer2::Core. But I have no
idea what the flow of routes and requests is, so I cannot (yet)
suggest a solution.
In the meantime, it looks suspiciously like Dancer2::Test is broken.
I ran the Dancer2 test suite, which includes testing Dancer2::Test,
and, while it doesn't find any errors, I'm not convinced that it
works. I'll be doing more debugging in the near future.
=cut
done_testing;
1;
__END__
=head1 AUTHOR
Jashank Jeremy, E<lt>jashank@rulingia.comE<gt>
=cut
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment