Module-New
view release on metacpan or search on metacpan
t/10_config.t view on Meta::CPAN
454647484950515253545556575859606162636465
my
$file
= path(
't/sample.yaml'
);
ok !
$file
->
exists
,
'sample file does not exist'
;
my
$config
= Module::New::Config->new(
file
=>
$file
,
no_prompt
=> 1,
);
ok
$config
->file eq
$file
,
'config file is the sample'
;
local
@ARGV
=
qw( --author=me --email=me@localhost )
;
$config
->get_options(
qw( author=s email=s )
);
ok
$config
->get(
'author'
) eq
'me'
,
'author is correct'
;
ok
$config
->get(
'email'
) eq
'me@localhost'
,
'email is correct'
;
$file
->remove;
};
subtest
from_mixed_source
=>
sub
{
my
$file
= path(
't/sample.yaml'
);
t/10_config.t view on Meta::CPAN
707172737475767778798081828384858687888990
ok
$file
->
exists
,
'sample file exists'
;
my
$config
= Module::New::Config->new(
file
=>
$file
,
no_prompt
=> 1,
);
ok
$config
->file eq
$file
,
'config file is the sample'
;
local
@ARGV
=
qw( --email=foo@localhost )
;
$config
->get_options(
qw( author=s email=s )
);
ok
$config
->get(
'author'
) eq
'me'
,
'author is correct'
;
ok
$config
->get(
'email'
) eq
'foo@localhost'
,
'email is correct'
;
$file
->remove;
};
subtest
set_and_save
=>
sub
{
my
$file
= path(
't/sample.yaml'
);
t/10_config.t view on Meta::CPAN
116117118119120121122123124125126127128129130131132133134135
$config
->load(
force
=> 1 );
ok
$config
->get(
'email'
) eq
'foo@localhost'
,
'new email is kept with reload'
;
$file
->remove;
};
subtest
merge
=>
sub
{
my
$config
= Module::New::Config->new(
no_prompt
=> 1 );
local
@ARGV
=
qw(--first=first --second=second)
;
$config
->get_options(
'first=s'
);
$config
->get_options(
'second=s'
);
ok
$config
->get(
'first'
) eq
'first'
,
'first option'
;
ok
$config
->get(
'second'
) eq
'second'
,
'second option'
;
};
done_testing;
( run in 0.245 second using v1.01-cache-2.11-cpan-87723dcf8b7 )