test for warnings everywhere
[gitmo/MooseX-Getopt.git] / t / 112_configfile_constructor_arg.t
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
9 use Test::More tests => 3;
10 use Test::NoWarnings 1.04 ':early';
11 use Path::Class;    # exports file, dir
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
24 {
25     my $configfile = file(qw(t 112_configfile_constructor_arg.yml))->stringify;
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