#!perl

use Template::Test;
$Template::Test::DEBUG = 1;

my $template_cfg = {
    GRAVATAR => {
        default => "/avatar.jpg",
        rating => "R",
        border => "BA9",
        size => 50,
    }
};

my $template_obj = Template->new($template_cfg);

test_expect( \*DATA, $template_obj );

__DATA__
-- test --
[% USE Gravatar -%]
loaded

-- expect --
loaded

-- test --
[% USE Gravatar -%]
[% Gravatar( email => 'whatever@wherever.whichever' ) %]

-- expect --
http://www.gravatar.com/avatar.php?gravatar_id=a60fc0828e808b9a6a9d50f1792240c8&rating=R&size=50&default=%2Favatar.jpg&border=BA9

-- test --
[% USE Gravatar(default => "/local.png") -%]
[% Gravatar( email => 'whatever@wherever.whichever' ) | html %]

-- expect --
http://www.gravatar.com/avatar.php?gravatar_id=a60fc0828e808b9a6a9d50f1792240c8&amp;rating=R&amp;size=50&amp;default=%2Flocal.png&amp;border=BA9

-- test --
[% USE Gravatar(default => "/local.png", rating => 'X') -%]
[% Gravatar( email => 'whatever@wherever.whichever' ) %]

-- expect --
http://www.gravatar.com/avatar.php?gravatar_id=a60fc0828e808b9a6a9d50f1792240c8&rating=X&size=50&default=%2Flocal.png&border=BA9

-- test --
[% USE Gravatar(default => "/local.png") -%]
[% Gravatar( email  => 'whatever@wherever.whichever',
             rating => 'R',
             size   => 80 ) | html %]

-- expect --
http://www.gravatar.com/avatar.php?gravatar_id=a60fc0828e808b9a6a9d50f1792240c8&amp;rating=R&amp;size=80&amp;default=%2Flocal.png&amp;border=BA9

-- test --
[% USE Gravatar(default => "/local.png",
                border => 'AAB',
                rating => 'PG',
                size => 45 ) -%]
[% Gravatar( email => 'whatever@wherever.whichever' ) | html %]

-- expect --
http://www.gravatar.com/avatar.php?gravatar_id=a60fc0828e808b9a6a9d50f1792240c8&amp;rating=PG&amp;size=45&amp;default=%2Flocal.png&amp;border=AAB
