Browse files

test post expansion from hashref

  • Loading branch information...
1 parent dd5885d commit bd245ba2fea735266005bd9df2fed4812bf573e0 Matt S Trout committed May 16, 2009
Showing with 11 additions and 1 deletion.
  1. +1 −1 lib/IronMunger/Post.pm
  2. +10 −0 t/plagger_loader.t
View
2 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);
}
View
10 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");
+ }
+}

0 comments on commit bd245ba

Please sign in to comment.