File Coverage

blib/lib/Poet/t/Environment.pm
Criterion Covered Total %
statement 3 3 100.0
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 4 4 100.0


line stmt bran cond sub pod time code
1             package Poet::t::Environment;
2             $Poet::t::Environment::VERSION = '0.16';
3 1     1   971 use Test::Class::Most parent => 'Poet::Test::Class';
  1         31356  
  1         6  
4             use Poet::Tools qw(mkpath tempdir_simple write_file);
5             use Poet::Environment::Generator;
6              
7             sub test_environment : Tests {
8             my $self = shift;
9              
10             my $app_name = 'TheTestApp';
11             my $poet = $self->temp_env( app_name => $app_name );
12             my $root_dir = $poet->root_dir;
13              
14             foreach my $subdir (qw(bin conf lib)) {
15             my $subdir_method = $subdir . "_dir";
16             is( $poet->$subdir_method, "$root_dir/$subdir", $subdir_method );
17             ok( -d $poet->$subdir_method, "$subdir exists" );
18             ok( -d $poet->path($subdir), "$subdir exists" );
19             }
20             is( $poet->conf->layer, 'development', "layer" );
21             foreach my $class (qw(Conf Log Mason)) {
22             my $file = $poet->lib_path("$app_name/$class.pm");
23             ok( -f $file, "$file exists" );
24             }
25             ok( -x $poet->bin_path("run.pl"), "run.pl executable" );
26             ok( -x $poet->bin_path("get.pl"), "get.pl executable" );
27             }
28              
29             sub test_dot_files_in_share_dir : Tests {
30             my $self = shift;
31             return 'author testing' if $ENV{AUTHOR_TESTING};
32             require File::Copy::Recursive;
33              
34             my $share_dir = $self->share_dir;
35             my $temp_dir = tempdir_simple();
36             File::Copy::Recursive::rcopy( $share_dir, $temp_dir ) or die $!;
37             my $gen_dir = "$temp_dir/generate.skel";
38             my @paths = ( "$gen_dir/extra", "$gen_dir/.git", "$gen_dir/bin/.svn" );
39             foreach my $path (@paths) {
40             mkpath( $path, 0, 0775 );
41             write_file( "$path/hi.txt", "hi" );
42             }
43             my $env_dir = $self->temp_env_dir( share_dir => $temp_dir );
44             ok( -d "$env_dir/extra", "extra exists" );
45             ok( !-d "$env_dir/.git", ".git does not exist" );
46             ok( !-d "$env_dir/bin/.svn", ".svn does not exist" );
47             }
48              
49             1;