3 use Test::More qw(no_plan);
6 use aliased 'LolCatalyst::Lite::Snippet';
8 { package MockTranslator;
10 sub can_translate_to { $_[1] eq 'uc' };
12 sub translate { return uc $_[1] };
17 has_attribute_ok(Snippet, "id", "Snippets know about thier own id");
18 has_attribute_ok(Snippet, "text", "Snippets have text attr");
22 $snippet = Snippet->new(
24 translator => MockTranslator->new
26 } qr/\(text\) is required/;
29 $snippet = Snippet->new(
31 translator => MockTranslator->new
33 } qr/\(id\) is required/;
36 $snippet = Snippet->new(
40 } qr/\(translator\) is required/;
43 $snippet = Snippet->new(
44 id => ($id = rand 9_999),
46 translator => MockTranslator->new
48 } "Can create a snippet";
50 is($snippet->id, $id, "this snippet has the right id");
51 is($snippet->text, "hi there");
53 is($snippet->translated(), "HI THERE", "and the snippet can be translated");