package Dist::Zilla::Plugin::Test::CPAN::Changes;
use strict;
use warnings;
# ABSTRACT: release tests for your changelog
our $VERSION = '0.012'; # VERSION

use Moose;
use Data::Section -setup;

has changelog => (
    is      => 'ro',
    isa     => 'Str',
    default => 'Changes',

around dump_config => sub
    my ($orig, $self) = @_;
    my $config = $self->$orig;

    $config->{+__PACKAGE__} = {
        changelog => $self->changelog,
        blessed($self) ne __PACKAGE__
            ? ( version => (defined __PACKAGE__->VERSION ? __PACKAGE__->VERSION : 'dev') )
            : (),
    return $config;

sub gather_files {
    my $self = shift;

    require Dist::Zilla::File::InMemory;

    for my $file (qw( xt/release/cpan-changes.t )){
        my $content = ${$self->section_data($file)};

        my $changes_filename = $self->changelog;

        $content =~ s/CHANGESFILENAME/$changes_filename/;
        $content =~ s/PLUGIN/ref($self)/e;
        $content =~ s/VERSION/$self->VERSION || '<self>'/e;

        $self->add_file( Dist::Zilla::File::InMemory->new(
            name => $file,
            content => $content,

# Register the release test prereq as a "develop requires"
# so it will be listed in "dzil listdeps --author"
sub register_prereqs {
  my ($self) = @_;

      type  => 'requires',
      phase => 'develop',
    # Latest known release of Test::CPAN::Changes
    # because CPAN authors must use the latest if we want
    # this check to be relevant
    'Test::CPAN::Changes'     => '0.19',

no Moose;


=encoding UTF-8

=head1 NAME

Dist::Zilla::Plugin::Test::CPAN::Changes - release tests for your changelog

=head1 VERSION

version 0.012

=for test_synopsis BEGIN { die "SKIP: synopsis isn't perl code" }


In C<dist.ini>:



This is an extension of L<Dist::Zilla::Plugin::InlineFiles>, providing the
following file:

    xt/release/cpan-changes.t - a standard Test::CPAN::Changes test

See L<Test::CPAN::Changes> for what this test does.

=head2 Alternate changelog filenames

L<CPAN::Changes::Spec> specifies that the changelog will be called 'Changes' -
if you want to use a different filename for whatever reason, do:

    changelog = CHANGES

and that file will be tested instead.

=for Pod::Coverage gather_files register_prereqs


The project homepage is L<>.

The latest version of this module is available from the Comprehensive Perl
Archive Network (CPAN). Visit L<> to find a CPAN
site near you, or see L<>.

=head1 SOURCE

The development version is on github at L<>
and may be cloned from L<git://>


You can make new bug reports, and view existing ones, through the
web interface at L<>.

=head1 AUTHOR

Mike Doherty <>


This software is copyright (c) 2011 by Mike Doherty.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.


__[ xt/release/cpan-changes.t ]__
use strict;
use warnings;

# this test was generated with PLUGIN VERSION

use Test::More 0.96 tests => 1;
use Test::CPAN::Changes;
subtest 'changes_ok' => sub {