App-DocKnot

 view release on metacpan or  search on metacpan

t/spin/tree.t  view on Meta::CPAN

# The extra file shouldn't be deleted.
ok($bogus->is_dir(), 'Stray file and directory not deleted');

# Reconfigure spin to enable deletion, and run it again.  The only action
# taken should be to delete the stray file.
$spin
  = App::DocKnot::Spin->new({ delete => 1, 'style-url' => '/~eagle/styles/' });
$stdout = capture_stdout { $spin->spin($tmpdir, $output) };
is(
    $stdout,
    "Deleting .../bogus/some-file\nDeleting .../bogus\n",
    'Spinning with delete option cleans up',
);
ok(!$bogus->exists(), 'Stray file and directory was deleted');

# Override the title of the POD document and request a contents section.  Set
# the modification timestamp in the future to force a repsin.
my $pod_source = path('lib', 'App', 'DocKnot.pm')->realpath();
my $pointer_path = $tmpdir->child(
    'software', 'docknot', 'api', 'app-docknot.spin',
);
$pointer_path->spew_utf8(
    "format: pod\n",
    "path: $pod_source\n",
    "options:\n",
    "  contents: true\n",
    "  navbar: false\n",
    "title: 'New Title'\n",
);
utime(time() + 5, time() + 5, $pointer_path)
  or die "Cannot reset timestamps of $pointer_path: $!\n";
$stdout = capture_stdout { $spin->spin($tmpdir, $output) };
is(
    $stdout,
    "Converting .../software/docknot/api/app-docknot.html\n",
    'Spinning again regenerates the App::DocKnot page',
);
my $output_path = $output->child(
    'software', 'docknot', 'api', 'app-docknot.html',
);
my $page = $output_path->slurp_utf8();
like(
    $page,
    qr{ <title> New [ ] Title </title> }xms,
    'POD title override worked',
);
like($page, qr{ <h1> New [ ] Title </h1> }xms, 'POD h1 override worked');
like($page, qr{ Table [ ] of [ ] Contents }xms, 'POD table of contents');

# Set the time back so that it won't be generated again.
utime(time() - 5, time() - 5, $pointer_path)
  or die "Cannot reset timestamps of $pointer_path: $!\n";

# Now, update the .versions file at the top of the input tree to change the
# timestamp to ten seconds into the future.  This should force regeneration of
# only the software/docknot/index.html file.
my $versions_path = $tmpdir->child('.versions');
my $versions = $versions_path->slurp_utf8();
my $new_date = strftime('%Y-%m-%d %T', localtime(time() + 10));
$versions =~ s{ \d{4}-\d\d-\d\d [ ] [\d:]+ }{$new_date}xms;
$versions_path->chmod(0644);
$versions_path->spew_utf8($versions);
$stdout = capture_stdout { $spin->spin($tmpdir, $output) };
is(
    $stdout,
    "Spinning .../software/docknot/index.html\n",
    'Spinning again regenerates the DocKnot page',
);

# Report the end of testing.
done_testing($count + 12);



( run in 0.978 second using v1.01-cache-2.11-cpan-39bf76dae61 )