App-FuguWeb
view release on metacpan or search on metacpan
t/fuguweb/index.t view on Meta::CPAN
my $body = App::FuguWeb::Index->new( config => $config )->body;
unlike( $body, qr/Empty/, 'no heading and no list' );
like( $body, qr/<h1>Manuals<\/h1>/,
'the opening still has the title' );
};
subtest 'two manuals may not become the same page' => sub {
# Two sources that render to one name overwrite each other in
# the staging directory and in the output, and the index then
# shows two entries that lead to one page.
my $root = build_root( <<'RC' );
site = Example
manuals "One" {
dir = man/tool
anchor = one
}
manuals "Two" {
dir = man/copy
anchor = two
}
RC
make_path("$root/man/copy");
open my $fh, '>', "$root/man/copy/tool.1"
or die "Cannot write the second source: $!";
print {$fh} ".Sh NAME\n.Nd the other tool\n";
close $fh;
my $config =
App::FuguWeb::Config->load( root => $root, error => \my $reason );
is( $config, undef, 'the load fails' );
like( $reason, qr/both become tool\.1\.html/,
'and names both sources and the page' );
};
subtest 'a group whose directory is absent fails the load' => sub {
my ( $config, $reason ) = load( <<'RC' );
site = Example
manuals "Gone" {
dir = man/gone
anchor = gone
}
RC
is( $config, undef, 'the load fails' );
like( $reason, qr{manuals "Gone" names man/gone},
'the message names the block and the directory' );
( $config, $reason ) = load( <<'RC' );
site = Example
modules "No anchor" {
dir = lib/Thing
}
RC
is( $config, undef, 'a group with no anchor fails the load' );
like( $reason, qr{has no anchor}, 'the message says which' );
};
subtest 'a project fragment replaces the opening' => sub {
my $root = build_root($RC);
open my $fh, '>', "$root/web/manuals.body.html"
or die "Cannot write the fragment: $!";
print {$fh} "<h1>The manuals</h1>\n\n<p>Read them.</p>\n\n";
close $fh;
my $config =
App::FuguWeb::Config->load( root => $root, error => \my $reason );
ok( $config, 'the description loads' ) or diag $reason;
my $body = App::FuguWeb::Index->new( config => $config )->body;
like( $body, qr{^<h1>The manuals</h1>\n}, 'the fragment opens' );
unlike( $body, qr/These pages come from/, 'and replaces the prose' );
like( $body, qr{<h2 id="tool">Tool</h2>}, 'the groups still follow' );
};
done_testing();
( run in 1.662 second using v1.01-cache-2.11-cpan-364913b4093 )