1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
use strict;
use warnings;
use Test::More;
use Moose;
BEGIN {
eval 'require MooseX::ConfigFromFile; require YAML;';
if ($@) {
plan skip_all =>
'These tests require MooseX::ConfigFromFile and YAML';
}
else {
plan tests => 3;
}
}
use lib 't/lib';
use Test::ConfigFromFile;
my $cmd = Test::ConfigFromFile->new;
{
local @ARGV = qw(moo);
eval { $cmd->run };
like(
$@,
qr/Mandatory parameter 'moo' missing in call to ["(]eval[)"]/,
'command died with the correct string',
);
}
{
local @ARGV = qw(moo --configfile=t/lib/Test/ConfigFromFile/config.yaml);
eval { $cmd->run };
like(
$@,
qr/cows go moo1 moo2 moo3/,
'command died with the correct string',
);
}
{
local @ARGV = qw(boo);
eval { $cmd->run };
like( $@, qr/ghosts go moo1 moo2 moo3/, 'default configfile read', );
}
|