trailing whitespace
[catagits/Catalyst-Plugin-ConfigLoader.git] / t / 21-mock_load_env.t
1 package MockApp;
2
3 use Test::More tests => 10;
4 use Cwd;
5
6 # Remove all relevant env variables to avoid accidental fail
7 foreach my $name ( grep { m{^(CATALYST|MOCKAPP)} } keys %ENV ) {
8     delete $ENV{ $name };
9 }
10
11 $ENV{ CATALYST_HOME }  = cwd . '/t/mockapp';
12 $ENV{ MOCKAPP_CONFIG } = $ENV{ CATALYST_HOME } . '/mockapp.pl';
13
14 use_ok( 'Catalyst', qw( ConfigLoader ) );
15
16 __PACKAGE__->config->{ 'Plugin::ConfigLoader' }->{ substitutions } = {
17     foo => sub { shift; join( '-', @_ ); }
18 };
19
20 __PACKAGE__->setup;
21
22 ok( __PACKAGE__->config );
23 is( __PACKAGE__->config->{ 'Controller::Foo' }->{ foo }, 'bar' );
24 is( __PACKAGE__->config->{ 'Controller::Foo' }->{ new }, 'key' );
25 is( __PACKAGE__->config->{ 'Model::Baz' }->{ qux },      'xyzzy' );
26 is( __PACKAGE__->config->{ 'Model::Baz' }->{ another },  'new key' );
27 is( __PACKAGE__->config->{ 'view' },                     'View::TT::New' );
28 is( __PACKAGE__->config->{ 'foo_sub' },                  'x-y' );
29 is( __PACKAGE__->config->{ 'literal_macro' },            '__DATA__' );
30 is( __PACKAGE__->config->{ 'environment_macro' },        $ENV{ CATALYST_HOME }.'/mockapp.pl' );