Commits

Fabrice Gabolde  committed eb4320b

Test attribute defaults, builders, coercions

  • Participants
  • Parent commits 64bd4d5

Comments (0)

Files changed (2)

     configure_requires => { 'Module::Build' => '0.36_14' },
     build_requires => {
         'File::Spec' => 0,
+        'Test::Builder' => 0,
         'Test::Exception' => 0,
         'Test::More' => 0,
         'Test::SetupTeardown' => 0,

File t/00-construction.t

 
 use_ok 'Lembas';
 
-new_ok 'Lembas', [ test_builder => Test::Builder->create,
-                   shell => 'examples/ush',
+new_ok 'Lembas', [ shell => 'examples/ush',
                    commands => [ { command => 'preamble' },
                                  { outputs => { match_type => 're',
                                                 output => '' } } ] ];
 
+my $lembas;
+
+lives_ok(sub { $lembas = Lembas->new(commands => [],
+                                     shell => 'examples/ush') },
+         q{... and the shell attribute can be passed as a string});
+is_deeply($lembas->shell, [ qw{examples/ush} ],
+          q{... and it is coerced to an arrayref});
+
+lives_ok(sub { $lembas = Lembas->new(commands => [],
+                                     shell => [ 'examples/ush',
+                                                '--horns' => 1 ]) },
+         q{... and the shell attribute can be passed as an arrayref});
+is_deeply($lembas->shell, [ qw{examples/ush --horns 1} ],
+          q{... and it stays that way});
+
+is($lembas->test_builder, Test::Builder->new,
+       q{... and we can grab the global Test::Builder instance});
+
 done_testing;