Code-TidyAll
view release on metacpan or search on metacpan
t/lib/TestFor/Code/TidyAll/Conf.pm view on Meta::CPAN
package TestFor::Code::TidyAll::Conf;
use Code::TidyAll;
use Code::TidyAll::Util qw(tempdir_simple);
use Test::Class::Most parent => 'TestHelper::Test::Class';
my @tests = (
{
name => 'valid config',
config => <<'EOF',
backup_ttl = 5m
no_cache = 1
inc = /foo
inc = /bar
[+TestHelper::Plugin::UpperText]
select = **/*.txt
[+TestHelper::Plugin::RepeatFoo]
select = **/foo*
select = **/bar*
times = 3
EOF
methods => {
backup_ttl => '5m',
_backup_ttl_secs => '300',
inc => [ '/foo', '/bar' ],
no_backups => undef,
no_cache => 1,
plugins => {
'+TestHelper::Plugin::UpperText' => {
select => ['**/*.txt'],
},
'+TestHelper::Plugin::RepeatFoo' => {
select => [ '**/foo*', '**/bar*' ],
times => 3,
},
},
},
},
{
name => 'space-separate select & ignore',
config => <<'EOF',
[+TestHelper::Plugin::RepeatFoo]
select = **/foo* **/bar*
ignore = buz baz
EOF
methods => {
plugins => {
'+TestHelper::Plugin::RepeatFoo' => {
select => [ '**/foo*', '**/bar*' ],
ignore => [ 'buz', 'baz' ],
},
},
},
},
);
sub test_config_file_handling : Tests {
my $self = shift;
my $root_dir = tempdir_simple();
for my $test (@tests) {
subtest(
$test->{name},
sub {
my $conf_file = $root_dir->child('tidyall.ini');
$conf_file->spew( $test->{config} );
my $ct = Code::TidyAll->new_from_conf_file($conf_file);
for my $method ( sort keys %{ $test->{methods} } ) {
cmp_deeply(
$ct->$method,
$test->{methods}{$method},
$method
);
}
is(
$ct->root_dir,
$root_dir,
'root_dir comes from config file path'
);
is(
$ct->data_dir,
"$root_dir/.tidyall.d",
'data dir is below root dir'
( run in 1.536 second using v1.01-cache-2.11-cpan-39bf76dae61 )