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