Commit | Line | Data |
1c9973b6 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::Requires |
5 | 'MooseX::SimpleConfig'; # skip all if not installed |
6 | |
7 | # respect the configfile value passed into the constructor. |
8 | |
9fbb5be9 |
9 | use Test::More tests => 3; |
10 | use Test::NoWarnings 1.04 ':early'; |
395546ae |
11 | use Path::Class; # exports file, dir |
1c9973b6 |
12 | |
ba2137c6 |
13 | # avoid warning if all we have installed is YAML or YAML::Syck - the user will |
14 | # see this eventually when he actually uses MooseX::SimpleConfig in his own |
15 | # code |
16 | use Config::Any::YAML; |
17 | $Config::Any::YAML::NO_YAML_XS_WARNING = 1; |
18 | |
1c9973b6 |
19 | { |
20 | package Foo; |
21 | use Moose; |
22 | with 'MooseX::Getopt', 'MooseX::SimpleConfig'; |
23 | |
24 | has foo => ( |
25 | is => 'ro', isa => 'Str', |
26 | default => 'foo default', |
27 | ); |
28 | } |
29 | |
1c9973b6 |
30 | { |
395546ae |
31 | my $configfile = file(qw(t 112_configfile_constructor_arg.yml))->stringify; |
1c9973b6 |
32 | |
33 | my $obj = Foo->new_with_options(configfile => $configfile); |
34 | |
35 | is( |
36 | $obj->configfile, |
37 | $configfile, |
38 | 'configfile value is used from the constructor', |
39 | ); |
40 | is( |
41 | $obj->foo, |
42 | 'foo value', |
43 | 'value is read in from the config file', |
44 | ); |
45 | } |
46 | |