Dancer-Plugin-RPC
view release on metacpan or search on metacpan
t/010-dispatch-from-config.t view on Meta::CPAN
#! perl -I. -w
use t::Test::abeltje;
use Dancer::Test;
use Dancer::RPCPlugin::DispatchFromConfig;
use Dancer::RPCPlugin::DispatchItem;
{
my $dispatch = dispatch_table_from_config(
plugin => 'xmlrpc',
endpoint => '/xmlrpc',
config => {
'/xmlrpc' => {
'TestProject::SystemCalls' => {
'system.ping' => 'do_ping',
'system.version' => 'do_version',
}
}
}
);
is_deeply(
$dispatch,
{
'system.ping' => dispatch_item(
code => TestProject::SystemCalls->can('do_ping'),
package => 'TestProject::SystemCalls',
),
'system.version' => dispatch_item(
code => TestProject::SystemCalls->can('do_version'),
package => 'TestProject::SystemCalls',
),
},
"Dispatch from YAML-config"
);
like(
exception {
dispatch_table_from_config(
plugin => 'xmlrpc',
endpoint => '/xmlrpc',
config => {
'/xmlrpc' => {
'TestProject::SystemCalls' => {
'system.nonexistent' => 'nonexistent',
}
}
},
);
},
qr/Handler not found for system.nonexistent: TestProject::SystemCalls::nonexistent doesn't seem to exist/,
"Setting a non-existent dispatch target throws an exception"
);
}
done_testing();
( run in 0.710 second using v1.01-cache-2.11-cpan-e93a5daba3e )