Froody
view release on metacpan or search on metacpan
#!perl
###########################################################################
# This does some fairly high level tests on Method and the associated XML
# parsing code. We create some XML, feed it to Froody::API::XML and then
# check to see if the Method contains the right stuff
###########################################################################
use strict;
use warnings;
use Test::More tests => 14;
use Test::Exception;
use Test::Differences;
use Froody::API::XML;
use Froody::Response::XML;
use Froody::Response::Terse;
use Data::Dumper;
use Term::ANSIColor qw(:constants);
$Term::ANSIColor::AUTORESET = 1;
sub _spec {
"<spec><methods>$_[0]</methods></spec>"
}
my $message = <<'END';
<method name="my.test.method" needslogin="1">
<description>This is a test method</description>
<arguments>
<argument name="foo" optional="1">The optional foo argument</argument>
<argument name="bar" optional="0" type="text">The non-optional bar argument</argument>
<argument name="baz" type="multipart">This is required, too</argument>
<argument name="shizzle" type="csv">Arguments are the shizniz</argument>
</arguments>
<response>
<book>
<spell name="rezrov">
<target>book</target>
<target>stove</target>
<description></description>
</spell>
<spell/>
</book>
</response>
<errors>
</errors>
</method>
END
my ($method) = Froody::API::XML->load_spec(_spec($message));
is($method->full_name, 'my.test.method', 'full name');
is($method->service, 'my', 'service');
is($method->object,'Test', 'object');
is($method->name, 'method', 'name');
is($method->module, 'My::Test', "full module");
is($method->description,
'This is a test method',
'description is correct');
is($method->source, 'unbound: my.test.method',
"Source looks right for an unbound method");
my $arguments;
my $actual_arguments = $method->arguments;
is_deeply($method->arguments, $arguments = {
'bar' => {
'doc' => 'The non-optional bar argument',
'optional' => '0',
'type' => ['text']
},
'baz' => {
'doc' => 'This is required, too',
( run in 3.342 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )