NAME
Test::Snippets - Helper functions to test POD formatters with snippets
SYNOPSIS
use Test::Snippets qw(list_snippets test_snippet);
for my $snippet (list_snippets()) {
test_snippet('Pod::Thread', $snippet);
}
DESCRIPTION
This module collects various utility functions that are useful for writing test cases for a POD formatter. It is not intended to be, and probably isn't, useful outside of the test suite for a module.
FUNCTIONS
None of these functions are imported by default. The ones used by a script should be explicitly imported.
- list_snippets([PATH])
-
Return a list of all snippet files in the given PATH, which should be relative to t/data/snippets. PATH may be omitted to use the t/data/snippets directory. A file named README.md in that directory will be ignored, as are files starting with a period (
.). - read_snippet(PATH)
-
Read one test snippet from the provided relative file name and return it. The path should be relative to t/data/snippets. For the format, see t/data/snippets/README.
The result will be a hash with the following keys:
- name
-
The name of the test, for reporting purposes.
- options
-
A hash of any options to values, if any options were specified.
- input
-
Input POD to try formatting.
- output
-
The expected output.
- errors
-
Expected errors from the POD formatter.
- exception
-
An expected exception from the POD formatter, with the file and line information stripped from the end of the exception.
- test_snippet(CLASS, SNIPPET[, OPTIONS])
-
Test a formatter on a particular POD snippet. This does all the work of loading the snippet, creating the formatter by instantiating CLASS, running it, and checking the results. Results are reported with Test::More.
OPTIONS, if present, is a reference to a hash of options. Currently, only one key is supported:
encoding, which, if set, specifies the encoding of the output portion of the snippet.
AUTHOR
Russ Allbery <rra@cpan.org>
COPYRIGHT AND LICENSE
Copyright 2015-2016, 2018-2021 Russ Allbery <rra@cpan.org>
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.