File: basic_inherit_attr.t

package info (click to toggle)
libdist-zilla-util-configdumper-perl 0.003009-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 296 kB
  • sloc: perl: 278; makefile: 2
file content (64 lines) | stat: -rw-r--r-- 2,060 bytes parent folder | download | duplicates (3)
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
use strict;
use warnings;

use Test::More tests => 1;
use Test::DZil qw( simple_ini Builder );

# ABSTRACT: Make sure plugins do what they say they'll do

require Moose;
require Dist::Zilla::Role::Plugin;
require Dist::Zilla::Plugin::Bootstrap::lib;
require Dist::Zilla::Plugin::GatherDir;
require Dist::Zilla::Plugin::MetaConfig;

my $pn    = 'TestPlugin';
my $fpn   = 'Dist::Zilla::Plugin::' . $pn;
my $files = {};
$files->{'source/dist.ini'} = simple_ini( ['Bootstrap::lib'], ['GatherDir'], ['MetaConfig'], [$pn], );
$files->{'source/lib/Dist/Zilla/Plugin/BasePlugin.pm'} = <<"EOREOR";
package #
  Dist::Zilla::Plugin::BasePlugin;

use Moose qw( has around with );
use Dist::Zilla::Util::ConfigDumper qw( config_dumper );
with 'Dist::Zilla::Role::Plugin';

has 'lattr' => ( is => 'ro', 'lazy' => 1, default => sub { 'I have value, my life has meaning' } );
has 'attr' => ( is => 'ro', default => sub { 'I have value, my life has meaning' } );

around dump_config => config_dumper(__PACKAGE__, { attrs => [qw( attr )] });

no Moose;
1;
EOREOR
$files->{ 'source/lib/Dist/Zilla/Plugin/' . $pn . '.pm' } = <<"EOF";
package $fpn;

use Moose qw( has around extends );
use Dist::Zilla::Util::ConfigDumper qw( config_dumper );
extends 'Dist::Zilla::Plugin::BasePlugin';

has 'childattr' => ( is => 'ro', default => sub { 'Rainbows and lollypops, etc' } );

around dump_config => config_dumper(__PACKAGE__, { attrs => [qw( childattr )] });

__PACKAGE__->meta->make_immutable;
no Moose;

1;
EOF
my $t = Builder->from_config( { dist_root => 'invalid' }, { add_files => $files } );
$t->chrome->logger->set_debug(1);
$t->build;
is_deeply(
  [ map { $_->{config} } grep { $_->{class} eq $fpn } @{ $t->distmeta->{x_Dist_Zilla}->{plugins} } ],
  [
    {
      'Dist::Zilla::Plugin::TestPlugin' => { 'childattr' => 'Rainbows and lollypops, etc' },
      'Dist::Zilla::Plugin::BasePlugin' => { 'attr'      => 'I have value, my life has meaning' },
    }
  ],
  "Plugin list expected"
);
note explain grep { $_->{class} eq $fpn } @{ $t->distmeta->{x_Dist_Zilla}->{plugins} };