The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Test::JSON::Schema::Acceptance - Acceptance testing for JSON-Schema based validators like JSON::Schema

VERSION

Version 0.0.2

SYNOPSIS

This module allows the JSON Schema Test Suite tests to be used in perl to test a module that implements json-schema. These are the same tests that many modules (libraries, plugins, packages, etc.) use to confirm support of json-scheam. Using this module to confirm support gives assurance of interoperability with other modules that run the same tests in differnet languages.

In the JSON::Schema module, a test could look like the following:

  use Test::More;
  use JSON::Schema;
  use Test::JSON::Schema::Acceptance;

  my $accepter = Test::JSON::Schema::Acceptance->new(3);

  # Skip tests which are known not to be supported or which cause problems.
  my $skip_tests = ['multiple extends', 'dependencies', 'ref'];

  $accepter->acceptance( sub{
    my ( $schema, $input ) = @_;
    return JSON::Schema->new($schema)->validate($input);
  }, {
    skip_tests => $skip_tests
  } );

  done_testing();

This would determine if JSON::Schema's validate method returns the right result for all of the cases in the JSON Schema Test Suite, except for those listed in $skip_tests.

DESCRIPTION

JSON Schema is an IETF draft (at time of writing) which allows you to define the structure of JSON.

The abstract from draft 4 of the specification:

    JSON::Schema is a perl module created independantly of the specification, which aims to implement the json-schema specification.

    This module allows other perl modules (for example JSON::Schema) to test that they are json-schema compliant, by running the tests from the official test suite, without having to manually convert them to perl tests.

    You are unliekly to want this module, unless you are attempting to write a module which implements json-schema the specification, and want to test your compliance.

CONSTRUCTOR

Test::JSON::Schema::Acceptance->new($schema_version)

Create a new instance of Test::JSON::Schema::Acceptance.

Accepts optional argument of $schema_version. This determins the draft version of the schema to confirm compliance to. Default is draft 4 (current), but in the synopsis example, JSON::Schema is testing draft 3 compliance.

SUBROUTINES/METHODS

acceptance

Accepts a sub and optional options in the form of a hash. The sub should return truthy or falsey depending on if the schema was valid for the input or not.

options

The only option which is currently accepted is skip_tests, which should be an array ref of tests you want to skip. You can skip a whole section of tests or individual tests. Any test name that contains any of the array refs items will be skipped, using grep. You can also skip a test by its number.

AUTHOR

Ben Hutton (@relequestual), <relequest at cpan.org>

BUGS

Please report any bugs or feature requests to via github at https://github.com/Relequestual/Test-JSON-Schema-Acceptance/issues.

SUPPORT

Users' IRC: #json-schema on irc.perl.org

(click for instant chatroom login)

For questions about json-schema in general IRC: #json-schema on chat.freenode.net

(click for instant chatroom login)

You can also look for information at:

ACKNOWLEDGEMENTS

Daniel Perrett <perrettdl@cpan.org> for the concept and help in design.

Ricardo SIGNES <rjbs@cpan.org> for direction to and creation of Test::Fatal.

Various others in #perl-help.

LICENSE AND COPYRIGHT

Copyright 2015 Ben Hutton (@relequestual).

This program is distributed under the MIT (X11) License: http://www.opensource.org/licenses/mit-license.php

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

3 POD Errors

The following errors were encountered while parsing the POD:

Around line 58:

=over should be: '=over' or '=over positive_number'

Around line 74:

You forgot a '=back' before '=head1'

Around line 93:

You forgot a '=back' before '=head1'