3 use Test::More qw(no_plan);
6 use_ok 'IronMunger::Post';
7 use_ok 'IronMunger::Calculate';
11 use autobox::DateTime::Duration;
14 sub named_eq ($test_name, $sub_name, $expected, @posts) {
15 my $sub_ref = IronMunger::Calculate->can($sub_name);
16 die "Couldn't find $sub_name in IronMunger::Calculate" unless $sub_ref;
17 my $sub_description = join(' ', split '_', $sub_name);
19 $sub_ref->(@posts), '==', $expected,
20 "${test_name}: ${expected} ${sub_description}",
24 sub case ($name_spec, $case, $expect) {
25 my $name = join(' ', map ucfirst, split '_', $name_spec);
26 my @posts = map { IronMunger::Post->new(at => $_->days->ago) } @$case;
27 foreach my $test (sort keys %$expect) {
28 named_eq($name, $test, $expect->{$test}, @posts);
32 sub expect (%expect) {
34 successful_sequential_posts => $expect{sequential},
35 days_remaining_to_post => $expect{remaining},
45 case two_posts_too_far_apart =>