<div dir="ltr">Can you help me with the Plugin Adaptor?<br><br><div><div><div class="gmail_extra"> Looking at<br>  <a href="https://metacpan.org/source/YANICK/Dancer2-Plugin-Adapter-0.006/t/file-temp.t" target="_blank">https://metacpan.org/source/YANICK/Dancer2-Plugin-Adapter-0.006/t/file-temp.t</a><br></div><div class="gmail_extra">it seems as if a Plugin Adaptor test should go like this:<br></div><div class="gmail_extra"><br>use strict;<br>use warnings;<br>use Test::More 0.96 import => ['!pass'];<br><br>use Plack::Test;<br>use HTTP::Request::Common;<br>    use Data::Printer;<br><br>{ # Test app<br>    package Test::Adapter::fuu::Barr;<br>    use Dancer2;<br>    use Dancer2::Plugin::Adapter;<br><br>    set show_errors => 0;<br>    set serializer => "JSON";<br>    set plugins => {<br>                    "Adapter" => {<br>                                capdir => {<br>                                           class => 'fuu::CAP::Directory',<br>                                           constructor => 'new'<br>                                          },<br>                               },<br>                   };<br>    get '/' => sub {<br>        if ( -d service("capdir") ) {<br>            return {message => 'Hello World'};<br>        }<br>        else {<br>            return ({message => service});<br>        }<br>    };<br>}<br>my $test = Plack::Test->create( Test::Adapter::fuu::Barr->to_app );<br>my $res  = $test->request( GET '/' );<br>p( $res);<br><br>ok( $res->is_success, 'Successful request' );<br>#like $res->content->{message}, qr/Hello World/i, "Request content correct";<br>like $res->content, qr/Hello World/i, "Request content correct";<br><br>done_testing;<br>===========================================<br>exception below:<br>==================<br>$ perl -T -Ilib t/004_plugin_adapter_dir.t 2>&1 <br>[Test::Adapter::fuu::Barr:9518] error @2015-09-18 14:38:41> Route exception: Dancer2::Plugin::Adapter::service() requires a name argument at lib/Dancer2/Plugin/Adapter.pm line 42. in /usr/local/share/perl/5.20.1/Dancer2/Core/App.pm l. 1276<br>HTTP::Response  {<br>    Parents       HTTP::Message<br>    public methods (23) : as_string, base, clone, code, current_age, dump, error_as_HTML, filename, freshness_lifetime, fresh_until, from_psgi, is_error, is_fresh, is_info, is_redirect, is_success, message, new, parse, previous, redirects, request, status_line<br>    private methods (0)<br>    internals: {<br>        _content   "{"status":500,"exception":"Dancer2::Plugin::Adapter::service() requires a name argument at lib/Dancer2/Plugin/Adapter.pm line 42.\n","message":"","title":"Error 500 - Internal Server Error"}",<br>        _headers   HTTP::Headers,<br>        _msg       "Internal Server Error",<br>        _rc        500,<br>        _request   HTTP::Request<br>    }<br>}<br>not ok 1 - Successful request<br>#   Failed test 'Successful request'<br>#   at t/004_plugin_adapter_dir.t line 45.<br>not ok 2 - Request content correct<br>#   Failed test 'Request content correct'<br>#   at t/004_plugin_adapter_dir.t line 47.<br>#                   '{"status":500,"exception":"Dancer2::Plugin::Adapter::service() requires a name argument at lib/Dancer2/Plugin/Adapter.pm line 42.\n","message":"","title":"Error 500 - Internal Server Error"}'<br>#     doesn't match '(?^i:Hello World)'<br>1..2<br># Looks like you failed 2 tests of 2.<br>====================<br></div><div class="gmail_extra">The exception above is coming from line 47 below<br></div><div class="gmail_extra">========================<br clear="all">Dancer2/Plugin/Adapter.pm<br>========================<br>register service => sub {<br>  my ( $dsl, $name ) = plugin_args(@_);<br><br>  unless ($name) {<br>     die "Dancer2::Plugin::Adapter::service() requires a name argument";   # line 47<br>  }<br><br>  $conf ||= plugin_setting();<br><br>  # ensure service is defined<br>  my $object_conf = $conf->{$name}<br>    or die "No configuration for Adapter '$name'";<br><br>==============<br>Dancer2/Plugin.pm  around line 136<br>===============<br>sub plugin_setting {<br>    my $plugin = caller;<br>    my $dsl    = _get_dsl()<br>        or croak 'No DSL object found';<br><br>    ( my $plugin_name = $plugin ) =~ s/Dancer2::Plugin:://;<br><br>    return $dsl->app->config->{'plugins'}->{$plugin_name} ||= {};<br>}<br>=================<br><br></div><div class="gmail_extra">(ref<br>  <a href="https://metacpan.org/pod/Dancer2::Manual::Testing" target="_blank">https://metacpan.org/pod/Dancer2::Manual::Testing</a> and <br>  <a href="https://metacpan.org/pod/Plack::Test" target="_blank">https://metacpan.org/pod/Plack::Test</a><br>  <a href="http://search.cpan.org/~xsawyerx/Dancer2-0.162000/lib/Dancer2/Manual/Testing.pod" target="_blank">http://search.cpan.org/~xsawyerx/Dancer2-0.162000/lib/Dancer2/Manual/Testing.pod</a><br>)<br></div><div class="gmail_extra">-- <br><div><div dir="ltr">Thanks -- Rick<br></div></div>
</div></div></div></div>