test for Filter::Babelfish
こんな感じで。キャッシュを無効にしているのは毎回確実にGoogleで翻訳してほしいから(万一おかしな結果になったときにキャッシュされるとうざいので)。
- t/plugins/Filter-Babelfish/babelfish.t
use strict; use FindBin; use t::TestPlagger; use utf8; test_requires_network plan tests => 6; run_eval_expected; __END__ === Test without Babelfish --- input config global: cache: class: Plagger::Cache::Null log: level: error plugins: - module: Subscription::Config config: feed: - file://$FindBin::Bin/../../samples/babelfish.xml --- expected is $context->update->feeds->[0]->entries->[0]->title, '猫'; is $context->update->feeds->[0]->entries->[0]->body, '犬'; === Test with Babelfish --- input config global: cache: class: Plagger::Cache::Null log: level: error plugins: - module: Subscription::Config config: feed: - file://$FindBin::Bin/../../samples/babelfish.xml - module: Filter::Babelfish config: source: Japanese destination: English service: Google prepend_original: 0 --- expected like $context->update->feeds->[0]->entries->[0]->title, qr/[cC]at/; like $context->update->feeds->[0]->entries->[0]->body, qr/[dD]og/; === Test with prepend_original --- input config global: cache: class: Plagger::Cache::Null log: level: error plugins: - module: Subscription::Config config: feed: - file://$FindBin::Bin/../../samples/babelfish.xml - module: Filter::Babelfish config: source: Japanese destination: English service: Google prepend_original: 1 --- expected like $context->update->feeds->[0]->entries->[0]->title, qr/猫.*[cC]at/s; like $context->update->feeds->[0]->entries->[0]->body, qr/犬.*[dD]og/s;
- t/samples/babelfish.xml
<?xml version="1.0" encoding="utf-8"?> <rss version="2.0"> <channel> <title>foo</title> <item> <title>猫</title> <description>犬</description> <link>http://plagger.org/</link> </item> </channel> </rss>