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 | |
13 | { |
14 | package Foo; |
15 | use Moose; |
16 | with 'MooseX::Getopt', 'MooseX::SimpleConfig'; |
17 | |
18 | has foo => ( |
19 | is => 'ro', isa => 'Str', |
20 | default => 'foo default', |
21 | ); |
22 | } |
23 | |
1c9973b6 |
24 | { |
395546ae |
25 | my $configfile = file(qw(t 112_configfile_constructor_arg.yml))->stringify; |
1c9973b6 |
26 | |
27 | my $obj = Foo->new_with_options(configfile => $configfile); |
28 | |
29 | is( |
30 | $obj->configfile, |
31 | $configfile, |
32 | 'configfile value is used from the constructor', |
33 | ); |
34 | is( |
35 | $obj->foo, |
36 | 'foo value', |
37 | 'value is read in from the config file', |
38 | ); |
39 | } |
40 | |