Data-Section-Writer

 view release on metacpan or  search on metacpan

t/data_section_writer.t  view on Meta::CPAN

use Test2::V0 -no_srand => 1;
use Data::Section::Writer;
use Test::Builder ();  # required for Test::Differences + Test2 le sigh
use Test::Differences;

is(
  Data::Section::Writer->new,
  object {
    prop isa => 'Data::Section::Writer';
    call perl_filename => object {
      prop isa => 'Path::Tiny';
      call stringify => __FILE__;
    };
    call render_section => "__DATA__\n";
  },
  'defaults',
);

is(
  Data::Section::Writer->new( perl_filename => 'Foo/Bar.pm' ),
  object {
    prop isa => 'Data::Section::Writer';
    call perl_filename => object {
      prop isa => 'Path::Tiny';
      call stringify => 'Foo/Bar.pm';
    };
    call render_section => "__DATA__\n";
  },
  'upgrade perl_filename',
);

my $perl_filename = Path::Tiny->tempfile;

my $writer = Data::Section::Writer->new(
  perl_filename => $perl_filename,
);

my $section = "__DATA__\n" .
              "\@\@ bar.bin (base64)\n" .
              "Rm9vIEJhciBCYXo=\n" .
              "\@\@ foo.txt\n" .
              "Foo Bar Baz\n";
is(
  $writer,
  object {
    prop isa => 'Data::Section::Writer';
    call [add_file => 'foo.txt', "Foo Bar Baz"] => object {
      prop isa => 'Data::Section::Writer';
    };
    call [add_file => 'bar.bin', "Foo Bar Baz", 'base64'] => object {
      prop isa => 'Data::Section::Writer';
    };
    call render_section => $section;

    call unchanged => U();

    call update_file => object {
      prop isa => 'Data::Section::Writer';
    };

    call unchanged => F();

    call update_file => object {
      prop isa => 'Data::Section::Writer';



( run in 2.104 seconds using v1.01-cache-2.11-cpan-e1769b4cff6 )