Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Commit

Permalink
Fortune: Switching to text template (#3063)
Browse files Browse the repository at this point in the history
* Fortune: Switching to text template

* Fortune: Adding subtitle and using Test::Deep
  • Loading branch information
mintsoft authored and GuiltyDolphin committed May 15, 2016
1 parent 3349534 commit 58ce9b0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
15 changes: 9 additions & 6 deletions lib/DDG/Goodie/Fortune.pm 100644 → 100755
Expand Up @@ -18,12 +18,15 @@ handle remainder => sub {
my $output = $fortune_file->get_random_fortune();
$output =~ s/\n/ /g;

return $output,
structured_answer => {
input => [],
operation => 'Random fortune',
result => $output
};
return $output, structured_answer => {
data => {
title => $output,
subtitle => "Random Fortune"
},
templates => {
group => 'text'
}
};
};

1;
30 changes: 18 additions & 12 deletions t/Fortune.t 100644 → 100755
Expand Up @@ -3,26 +3,32 @@
use strict;
use warnings;
use Test::More;
use Test::Deep;
use DDG::Test::Goodie;

zci answer_type => 'fortune';
zci is_cached => 0;

my @fortune = (
'-ANY-',
structured_answer => {
input => [],
operation => 'Random fortune',
result => '-ANY-'
});
sub build_test
{
return test_zci(re(qr/.+/), structured_answer => {
data => {
title => re(qr/.+/),
subtitle => 'Random Fortune'
},
templates => {
group => 'text'
}
})
}

ddg_goodie_test(
[qw( DDG::Goodie::Fortune )],
'gimmie a fortune cookie' => test_zci(@fortune),
'gimmie a unix fortune' => test_zci(@fortune),
'give me a fortune cookie' => test_zci(@fortune),
'give me a unix fortune' => test_zci(@fortune),
'unix fortune cookie' => test_zci(@fortune),
'gimmie a fortune cookie' => build_test(),
'gimmie a unix fortune' => build_test(),
'give me a fortune cookie' => build_test(),
'give me a unix fortune' => build_test(),
'unix fortune cookie' => build_test(),
'how do I make a fortune overnight' => undef,
"bill gates' fortune" => undef,
);
Expand Down

0 comments on commit 58ce9b0

Please sign in to comment.