Module-New

 view release on metacpan or  search on metacpan

t/10_config.t  view on Meta::CPAN

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
  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

70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
  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

116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
  $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 )