diff --git a/lib/DDG/Goodie/Rot13.pm b/lib/DDG/Goodie/Rot13.pm old mode 100644 new mode 100755 index cb0aacc55..d2d1e7660 --- a/lib/DDG/Goodie/Rot13.pm +++ b/lib/DDG/Goodie/Rot13.pm @@ -17,12 +17,15 @@ handle remainder => sub { $out =~ tr[a-zA-Z][n-za-mN-ZA-M]; - return "ROT13: $out", - structured_answer => { - input => [html_enc($in)], - operation => 'ROT13', - result => html_enc($out), - }; + return "ROT13: $out", structured_answer => { + data => { + title => html_enc($out), + subtitle => "ROT13: ".html_enc($in) + }, + templates => { + group => 'text' + } + }; }; 1; diff --git a/t/Rot13.t b/t/Rot13.t old mode 100644 new mode 100755 index 69b4c2c6c..ac9bbae4a --- a/t/Rot13.t +++ b/t/Rot13.t @@ -9,32 +9,24 @@ use DDG::Test::Goodie; zci answer_type => 'rot13'; zci is_cached => 1; +sub build_answer { + my ($text, $input, $answer) = @_; + return test_zci($text, structured_answer => { + data => { + title => $answer, + subtitle => "ROT13: $input" + }, + templates => { + group => 'text' + } + }); +} + ddg_goodie_test( [qw( DDG::Goodie::Rot13 )], - 'rot13 This is a test' => test_zci( - 'ROT13: Guvf vf n grfg', - structured_answer => { - input => ['This is a test'], - operation => 'ROT13', - result => 'Guvf vf n grfg' - } - ), - 'rot13 thirteen' => test_zci( - 'ROT13: guvegrra', - structured_answer => { - input => ['thirteen'], - operation => 'ROT13', - result => 'guvegrra' - } - ), - 'rot13 guvegrra' => test_zci( - 'ROT13: thirteen', - structured_answer => { - input => ['guvegrra'], - operation => 'ROT13', - result => 'thirteen' - } - ), + 'rot13 This is a test' => build_answer('ROT13: Guvf vf n grfg', 'This is a test', 'Guvf vf n grfg'), + 'rot13 thirteen' => build_answer('ROT13: guvegrra', 'thirteen', 'guvegrra'), + 'rot13 guvegrra' => build_answer('ROT13: thirteen', 'guvegrra', 'thirteen'), ); done_testing;