The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Test::Dist::Zilla::BuiltFiles - TODO: Test your Dist::Zilla plugin in build action

VERSION

Version v0.4.2, released on 2015-10-31 08:49 UTC.

SYNOPSIS

    package ManifestTester2;

    use Test::Deep qw{ cmp_deeply re };
    use Test::More;
    use Test::Routine;
    use Test::Routine::Util;

    with 'Test::Dist::Zilla::Build';
    with 'Test::Dist::Zilla::BuiltFiles';

    run_me 'A test' => {
        plugins => [
            'GatherDir',
            'Manifest',
            'MetaJSON',
        ],
        files => {
            'lib/Dummy.pm' => 'package Dummy; 1;',
        },
        expected => {
            files => {
                'MANIFEST' => [
                    'lib/Dunny.pm',
                    'MANIFEST',
                    'META.json',
                ],
            },
        },
    };

    exit( 0 );

DESCRIPTION

This is a Test::Routine-based role for testing Dist::Zilla and its plugins. It is intended to be used in cooperation with Test::Dist::Zilla::Build role. Test::Dist::Zilla::Build builds the distribution and checks exception and build messages, while Test::Dist::Zilla::BuiltFiles checks built files.

OBJECT METHODS

BuiltFiles

It is a test routine. It checks built files. Names of files to check should be be enlisted in files key of expected hash. Value should be HashRef, keys are filenames, values are file content. File content may be specified as Str or ArrayRef[Str]:

    run_me {
        …
        expected => {
            files => {
                'filename1' => "line1\nline2\n",
                'filename2' => [
                    'line1',            # Should not include newline character.
                    'line2'
                ],
                'filename3' => undef,   # This file should not exist.
            },
        },
    };

For every file the test routine checks the file exists and its actual content matches the expected content. If expected content is undef, the file should not exists.

Note: BuiltFiles assumes successful build. If an exception occurred, BuiltFiles skips all the checks.

SEE ALSO

Test::Dist::Zilla
Test::Dist::Zilla::Build
"$ok = cmp_deeply($got, $expected, $name)" in Test::Deep
Test::Routine

AUTHOR

Van de Bugger <van.de.bugger@gmail.com>

COPYRIGHT AND LICENSE

Copyright (C) 2015 Van de Bugger

License GPLv3+: The GNU General Public License version 3 or later <http://www.gnu.org/licenses/gpl-3.0.txt>.

This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.