check postspec loading, factor out column order handling to avoid making further...
[engit/Iron-Munger.git] / t / plagger_loader.t
CommitLineData
04d3c854 1use strict;
2use warnings;
3use Test::More qw(no_plan);
7a42977e 4use IO::All;
dd5885d7 5
04d3c854 6BEGIN {
7 use_ok aliased => 'IronMunger::PlaggerLoader';
8}
9
dd5885d7 10my @names = ('Jess Robinson', 'Justin DeVuyst');
11
12my @files = ('my_Jess_Robinson.csv', 'my_Justin_DeVuyst.csv');
13
04d3c854 14ok(my $loader = PlaggerLoader->new(dir => 't/csv'), 'build loader');
15
dd5885d7 16my @target = $loader->_target_files;
17
18cmp_ok(@target, '==', 2, '2 files in CSV directory');
04d3c854 19
dd5885d7 20is_deeply(
21 [ sort map { ($_->splitpath)[-1] } @target ], \@files,
22 'filenames ok'
23);
bd245ba2 24
25{
26 my %args = (url => 'http://foo.com', at => '2008-04-06T12:00:00');
27
28 ok(my $post = $loader->_expand_post(\%args), 'Expand post constructs object');
29
30 foreach my $key (sort keys %args) {
31 is($post->$key, $args{$key}, "Attribute ${key} ok");
32 }
33}
7a42977e 34
35my @postspecs = map
36 +{
37 url => 'http://jdv79.blogspot.com/2009/05/testable-v007.html',
38 at => $_,
39 }, qw(2009-05-13T02:45:00 2009-05-14T16:00:00);
40
41my $specs = $loader->_expand_postspecs_from_file(
42 io('t/csv/my_Justin_DeVuyst.csv')
43 );
44
45is_deeply($specs, \@postspecs, 'Post specs from file ok');