HiD
view release on metacpan or search on metacpan
t/cmd-publish.t view on Meta::CPAN
file_exists_ok( '_site/2012/05/06/post.html' , 'expected post file');
file_contains_like(
'_site/2012/05/06/post.html' ,
qr|POST: <p>this is a test post, and it's called this is a test post</p>| ,
'expected content'
);
}
{ # 'post' file with default layout gets default layout
write_fixture_file( '_posts/2012-05-06-default.mkdn' , << 'EOL' );
---
layout: default
title: this is a test post
---
this is a test post, and it's called {{page.title}}
EOL
_assert_good_run();
file_exists_ok( '_site/2012/05/06/default.html' , 'expected post file');
file_contains_like(
'_site/2012/05/06/default.html' ,
qr|this is a test post, and it's called this is a test post| ,
'expected content'
);
file_contains_like(
'_site/2012/05/06/default.html' ,
qr|<title>this is a test post</title>| ,
'expected content'
);
}
{ # 'post' file can override date in yaml
write_fixture_file( '_posts/2012-05-06-date-override.mkdn' , << 'EOL' );
---
date: 1999-01-01
title: this is a test post
---
this is a test post, and it's called {{page.title}}
and it was made on {{page.date}}
EOL
_assert_good_run();
file_exists_ok( '_site/1999/01/01/date-override.html' , 'expected post file');
file_contains_like(
'_site/1999/01/01/date-override.html' ,
qr|and it was made on 1999-01-01| ,
'expected content'
);
}
TODO: { # embedded layouts
local $TODO = 'embedded layouts all fucked up';
write_fixture_file( '_layouts/embedded_post.html' , << 'EOL' );
---
layout: default
----
EMBEDDED POST: {{content}}
EOL
write_fixture_file( '_posts/2012-05-06-embedded_layout.mkdn' , << 'EOL' );
---
layout: embedded_post
title: this is a test post
---
this is a test embedded post, and it's called {{page.title}}
EOL
_assert_good_run();
file_exists_ok( '_site/2012/05/06/embedded_layout.html' , 'expected post file');
file_contains_like(
'_site/2012/05/06/embedded_layout.html' ,
qr|EMBEDDED POST: this is a embedded test post, and it's called this is a test post| ,
'expected content'
);
}
## tests to write
# setting 'processor' in config (use '+$MODULE' to bypass wrapper, etc.)
# setting 'destination' in config
# setting 'permalink' in config (and then still overriding in specific post)
# setting fully custom permalink format
# permalink with categories
chdir('/');
done_testing();
sub _assert_good_run {
my $result = test_app( 'HiD::App' => [ 'publish' ]);
is $result->stdout , '' , 'expected STDOUT';
is $result->stderr , '' , 'empty STDERR';
is $result->exit_code , 0 , 'exit=success';
}
sub _setup_fixtures {
mkdir "_$_" foreach qw/ includes layouts posts site /;
my %fixtures = (
'_layouts/default.html' => q|<html><head><title>{{page.title}}</title></head><body>{{{content}}}</body></html>| ,
'_layouts/post.html' => q|POST: {{{content}}}| ,
);
foreach ( keys %fixtures ) {
write_fixture_file( $_ , $fixtures{$_} );
}
}
( run in 0.538 second using v1.01-cache-2.11-cpan-71847e10f99 )