From: Matt S Trout Date: Sat, 16 May 2009 14:57:06 +0000 (+0100) Subject: test post expansion from hashref X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bd245ba2fea735266005bd9df2fed4812bf573e0;p=engit%2FIron-Munger.git test post expansion from hashref --- diff --git a/lib/IronMunger/Post.pm b/lib/IronMunger/Post.pm index 0a0057e..aca135f 100644 --- a/lib/IronMunger/Post.pm +++ b/lib/IronMunger/Post.pm @@ -5,7 +5,7 @@ class IronMunger::Post { use MooseX::Types::Moose qw(Str); use MooseX::Types::DateTimeX qw(DateTime); - has at => (isa => DateTime, is => 'ro', required => 1); + has at => (isa => DateTime, is => 'ro', required => 1, coerce => 1); has url => (isa => Str, is => 'ro', required => 1); } diff --git a/t/plagger_loader.t b/t/plagger_loader.t index 2b7539a..f4b3002 100644 --- a/t/plagger_loader.t +++ b/t/plagger_loader.t @@ -21,3 +21,13 @@ is_deeply( [ sort map { ($_->splitpath)[-1] } @target ], \@files, 'filenames ok' ); + +{ + my %args = (url => 'http://foo.com', at => '2008-04-06T12:00:00'); + + ok(my $post = $loader->_expand_post(\%args), 'Expand post constructs object'); + + foreach my $key (sort keys %args) { + is($post->$key, $args{$key}, "Attribute ${key} ok"); + } +}