domain support for feeds, factor out sc-specific bits
[scpubgit/SCS.git] / t / pages.t
CommitLineData
95148a72 1use strictures 1;
2use Test::More;
3use SCSite::PageSet;
fc436d2e 4use IO::All;
95148a72 5
6sub check_structure {
7 my ($s) = @_;
8 $s = { %$s };
9 my $body = delete $s->{body};
10 like($body, qr/^\s+<p>Some markdown here.<\/p>\s+$/sm, 'Body correct');
ebd4c292 11 delete @{$s}{grep /^_/, keys %$s};
fc436d2e 12 delete $s->{path};
95148a72 13 is_deeply($s,
14 {
ebd4c292 15 created => '',
95148a72 16 title => '--TITLE--',
17 description => '--DESCRIPTION--',
18 keywords => '--KW1-- --KW2--'
19 },
20 'Metadata ok'
21 );
22}
23
fc436d2e 24my $ps = SCSite::PageSet->new(base_dir => io->dir('t/pages'));
95148a72 25
26my $test_html = q{<html>
27 <head>
28 <title>--TITLE--</title>
29 <meta name="description" content="--DESCRIPTION--" />
30 <meta name="keywords" content="--KW1-- --KW2--" />
31 </head>
32 <body>
33 <p>Some markdown here.</p>
34 </body>
35</html>};
36
37check_structure($ps->_extract_from_html($test_html));
38
39my $test_md = q{Title: --TITLE--
40description: --DESCRIPTION--
41keywords: --KW1-- --KW2--
42
43Some markdown here.
44};
45
46check_structure($ps->_extract_from_md($test_md));
47
48check_structure($ps->get({ path => 'index' }));
49
50check_structure($ps->get({ path => 'one/two' }));
51
52done_testing;