1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
use strict;
use warnings;
use Test::More;
use Test::Fatal;
use Dancer2::Core::App;
use Dancer2::Template::Tiny;
my $f = Dancer2::Template::Tiny->new();
isa_ok $f, 'Dancer2::Template::Tiny';
ok( $f->does('Dancer2::Core::Role::Engine') );
ok( $f->does('Dancer2::Core::Role::Template') );
is( $f->name, 'Tiny' );
# checks for validity of engine names
my $app = Dancer2::Core::App->new();
isa_ok( $app, 'Dancer2::Core::App' );
{
no warnings qw<redefine once>;
*Dancer2::Core::Factory::create = sub { $_[1] };
}
foreach my $engine_type ( qw<logger session template> ) {
my $engine;
my $build_method = "_build_${engine_type}_engine";
is(
exception {
$engine = $app->$build_method(
undef, { $engine_type => 'Fake43Thing' }
);
},
undef,
"Built $engine_type successfully",
);
like(
exception {
$engine = $app->$build_method(
undef, { $engine_type => '7&&afail' }
);
},
qr/^Cannot load $engine_type engine '7&&afail': illegal module name/,
"Built $engine_type successfully",
);
is( $engine, $engine_type, 'Correct response from override' );
}
done_testing;
|