move use_ext before the extra args
[gitmo/MooseX-SimpleConfig.git] / t / 11default.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 YAML::Syck ()";
13     if($@) {
14         eval "use YAML ()";
15         if($@) {
16             plan skip_all => "YAML or YAML::Syck required for this test";
17         }
18     }
19     
20     plan tests => 5;
21
22     use_ok('MXDefaultConfigTest');
23 }
24
25 # Can it load a simple YAML file with the options
26 #  based on a default in the configfile attr
27 {
28     open(my $test_yaml, '>', 'test.yaml')
29       or die "Cannot create test.yaml: $!";
30     print $test_yaml "direct_attr: 123\ninherited_ro_attr: asdf\nreq_attr: foo\n";
31     close($test_yaml);
32
33     my $foo = eval {
34         MXDefaultConfigTest->new_with_config();
35     };
36     ok(!$@, 'Did not die with good YAML configfile')
37         or diag $@;
38
39     is($foo->req_attr, 'foo', 'req_attr works');
40     is($foo->direct_attr, 123, 'direct_attr works');
41     is($foo->inherited_ro_attr, 'asdf', 'inherited_ro_attr works');
42 }
43
44 END { unlink('test.yaml') }