aboutsummaryrefslogtreecommitdiff
path: root/t/tests/sietima/cmdline.t
blob: bd24c84b33c9c92af2f3236573705b1da1ab11e4 (plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!perl 
use lib 't/lib';
use Test::Sietima;
use Path::Tiny;
use Sietima;
use Sietima::CmdLine;
 
subtest 'given instance' => sub {
    my $s = Sietima->new({
        return_path => 'list@example.com',
    });
    my $c = Sietima::CmdLine->new({
        sietima => $s,
    });
    is(
        $c,
        object {
            call app_spec => object {
                call name => 'sietima';
                call subcommands => hash {
                    field send => object {
                        call name => 'send';
                    };
                    etc;
                };
            };
            call runner => object {
                call cmd => $s;
            };
        },
        'spec & runner should be built',
    );
};
 
subtest 'built via args' => sub {
    my $c = Sietima::CmdLine->new({
        args => {
            return_path => 'list@example.com',
        },
    });
    is(
        $c,
        object {
            call sietima => object {
                call return_path => 'list@example.com';
            };
        },
        'sietima should be built',
    );
};
 
subtest 'built via args & traits' => sub {
    my $c = Sietima::CmdLine->new({
        traits => [ qw(ReplyTo) ],
        args => {
            return_path => 'list@example.com',
        },
    });
    DOES_ok(
        $c->sietima,
        ['Sietima::Role::ReplyTo'],
        'sietima should be built with the given trait',
    );
};
 
subtest 'extra spec' => sub {
    my $c = Sietima::CmdLine->new({
        extra_spec => { name => 'different' },
        args => {
            return_path => 'list@example.com',
        },
    });
    is(
        $c->app_spec,
        object {
            call name => 'different';
        },
        'spec fields should be overridden',
    );
};
 
done_testing;