Regenerate README
[gitmo/MooseX-SimpleConfig.git] / t / 12config_any_args.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use lib 't/lib';
7 use lib '../t/lib';
8
9 BEGIN {
10     use Test::More;
11
12     eval "use Config::General ()";
13     if($@) {
14         plan skip_all => "Config::General required for this test";
15     }
16     
17     plan tests => 6;
18
19     use_ok('MXDriverArgsConfigTest');
20 }
21
22 # Does it work with no configfile and not barf?
23 {
24     eval { MXDriverArgsConfigTest->new(req_attr => 'foo') };
25     ok(!$@, 'Did not die with no configfile specified')
26         or diag $@;
27 }
28
29 # Can it load a simple YAML file with the options
30 {
31     open(my $test_conf, '>', 'test.conf')
32       or die "Cannot create test.conf: $!";
33     print $test_conf <<EOM;
34 Direct_Attr 123
35 Inherited_Ro_Attr asdf
36 Req_Attr foo
37 EOM
38     close($test_conf);
39
40     my $foo = eval {
41         MXDriverArgsConfigTest->new_with_config(configfile => 'test.conf');
42     };
43     ok(!$@, 'Did not die with good General configfile')
44         or diag $@;
45
46     is($foo->req_attr, 'foo', 'req_attr works');
47     is($foo->direct_attr, 123, 'direct_attr works');
48     is($foo->inherited_ro_attr, 'asdf', 'inherited_ro_attr works');
49 }
50
51 END { unlink('test.conf') }