Jakob Voß > Plack-App-DAIA-0.53 > Plack::App::DAIA::Test

Download:
Plack-App-DAIA-0.53.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.53   Source   Latest Release: Plack-App-DAIA-0.55

NAME ^

Plack::App::DAIA::Test - Test DAIA Servers

VERSION ^

version 0.53

SYNOPSIS ^

    use Test::More;
    use Plack::App::DAIA::Test;

    use Your::App; # your subclass of Plack::App::DAIA
    my $app = Your::App->new;

    # or wrap a DAIA server
    my $app = daia_app( 'http://your.host/pathtodaia' );

    test_daia $app,
        'some:id' => sub {
            my $daia = shift; # or = $_
            my @docs = $daia->document;
            is (scalar @docs, 1, 'returned one document');
            ...
        },
        'another:id' => sub {
            my $daia = shift;
            ...
        };

    # same usage, shown here with an inline server

    test_daia_psgi
        sub {
            my $id = shift;
            my $daia = DAIA::Response->new;
            ...
            return $daia;
        },
        'some:id' => sub {
            my $daia = $_; # or shift
            ...
        };

    done_testing;

DESCRIPTION ^

This model is experimental, so take care! The current version has different behaviour for test_daia and test_daia_psgi, that might get fixed.

This module exports two methods for testing DAIA servers. You must provide a DAIA server as code reference or as instance of Plack::App::DAIA and a list of request identifiers and testing code. The testing code is passed a valid DAIA::Response object on success ($_ is also set to this response).

METHODS ^

test_daia ( $app, $id1 => $expected, $id2 => ... )

Calls a DAIA server $app's retrieve method with one or more identifiers, each given a test function or an expected JSON structure to be tested with Test::JSON::Entails. This does not add warnings and the error option is ignored (use test_daia_psgi instead if needed).

test_daia_psgi ( $app, $id => $expected, $id => ... )

Calls a DAIA server $app as PSGI application with one or more identifiers, each given a test function or an expected JSON structure.

daia_app ( $plack_app_daia | $url | $code )

Returns an instance of Plack::App::DAIA or undef. Code references or URLs are wrapped. For wrapped URLs $@ is set on failure. This method may be removed to be used internally only!

SEE ALSO ^

Plack::App::DAIA::Test::Suite and provedaia.

AUTHOR ^

Jakob Voß

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2013 by Jakob Voß.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

syntax highlighting: