File: 112_configfile_constructor_arg.t

package info (click to toggle)
libmoosex-getopt-perl 0.45-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 356 kB
  • sloc: perl: 1,964; makefile: 8
file content (39 lines) | stat: -rw-r--r-- 787 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use strict;
use warnings;

use Test::Requires
    'MooseX::SimpleConfig'; # skip all if not installed

# respect the configfile value passed into the constructor.

use Test::More tests => 2;
use Path::Class;    # exports file, dir

{
    package Foo;
    use Moose;
    with 'MooseX::Getopt', 'MooseX::SimpleConfig';

    has foo => (
        is => 'ro', isa => 'Str',
        default => 'foo default',
    );
}

{
    my $configfile = file(qw(t 112_configfile_constructor_arg.yml))->stringify;

    my $obj = Foo->new_with_options(configfile => $configfile);

    is(
        $obj->configfile,
        $configfile,
        'configfile value is used from the constructor',
    );
    is(
        $obj->foo,
        'foo value',
        'value is read in from the config file',
    );
}