make all warnings fatal in tests
[gitmo/MooseX-Getopt.git] / t / 112_configfile_constructor_arg.t
1 use strict;
2 use warnings FATAL => 'all';
3
4 # respect the configfile value passed into the constructor.
5
6 use Test::Requires 'MooseX::SimpleConfig';  # skip all if not installed
7 use Test::More tests => 3;
8 use Test::NoWarnings 1.04 ':early';
9 use Path::Tiny;
10
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
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
28 {
29     my $configfile = path(qw(t 112_configfile_constructor_arg.yml))->stringify;
30
31     my $obj = Foo->new_with_options(configfile => $configfile);
32
33     is(
34         path($obj->configfile),
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