App-Spec

 view release on metacpan or  search on metacpan

t/11.appspecrun.t  view on Meta::CPAN

    my $spec = App::Spec->read("$Bin/../examples/$app-spec.yaml");
    my $runner = $spec->runner;
    $runner->response->buffered(1);
    my $exit = $test->{exit} || 0;
    my $env = $test->{env};
    my $name = "$app args: (@$args)";
    $name .= ", $_=$env->{$_}" for sort keys %$env;

    subtest $name => sub {
        {
            local @ARGV = @$args;
            local %ENV = %ENV;
            if ($env) {
                @ENV{ keys %$env } = values %$env;
            }
            $runner->process;
        };
        my $res = $runner->response;
        my $outputs = $res->outputs;
        my @stdout_output = map { $_->content } grep { not $_->error } @$outputs;
        my @stderr_output = map { $_->content } grep { $_->error } @$outputs;

t/13.argv.t  view on Meta::CPAN

use App::Spec;
$ENV{PERL5_APPSPECRUN_COLOR} = 'never';
$ENV{PERL5_APPSPECRUN_TEST} = 1;

{
    my $spec = App::Spec->read("$Bin/../examples/myapp-spec.yaml");
    my @args = qw/ help convert /;

    my $runner1 = $spec->runner;
    {
        local @ARGV = @args;
        $runner1->process;
    };

    my $runner2 = $spec->runner(
        argv => [@args],
    );
    $runner2->process;

    my $res1 = $runner1->response;
    my $res2 = $runner2->response;

t/14.disable-plugins.t  view on Meta::CPAN

use App::Spec::Example::Nometa;
use Data::Dumper;

my $specfile = "$Bin/../examples/nometa-spec.yaml";

subtest nometa_valid => sub {
    my $spec = App::Spec->read($specfile);
    my $runner = $spec->runner;
    $runner->response->buffered(1);
    {
        local @ARGV = qw/ foo a /;
        $runner->process;
    };
    my $res = $runner->response;
    my $outputs = $res->outputs;
    cmp_ok(scalar @$outputs, '==', 1, "Output number ok");
    my $output = $outputs->[0];
    cmp_ok($output->content, 'eq', "foo\n", "Output ok");
};

subtest nometa_invalid => sub {
    my $spec = App::Spec->read($specfile);
    my $runner = $spec->runner;
    $runner->response->buffered(1);
    {
        local @ARGV = qw/ _meta /;
        $runner->process;
    };
    my $res = $runner->response;
    my $outputs = $res->outputs;
    my $output = $outputs->[1];
    cmp_ok($output->content, '=~', qr{Unknown subcommand}, "Output error as expected");
};

done_testing;

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.478 second using v1.00-cache-2.02-grep-82fe00e-cpan-da92000dfeb )