Perl6-Pugs

 view release on metacpan or  search on metacpan

misc/sixpan/JIB/t/020_JIB-Package.t  view on Meta::CPAN

 
    for my $method ( keys %map ) {
        can_ok( $Obj,           $method );
        
        my $rv = $Obj->$method;
        ok( $rv,                "   Returns '$rv'" );
        is( $rv, $map{$method}, "       As expected" );
    }
}
 
### installl the package
{   my $inst_pkg = $Obj->install( installation => $Inst );
    ok( $inst_pkg,              "Package installed" );
    isa_ok( $inst_pkg,          "JIB::Package::Installed" );
    ok( $Inst->is_installed( package => $Obj ),
                                "   Package installation registered" );
    
    
    ### XXX add more file tests
    for my $file ( @{ $inst_pkg->files } ) {
        ok( -e $file,           "   File '$file' exists" );
    }
    
    ### check for module
    ### XXX get this from config/object
    {   my $pm = file( 
                    $Inst->dir,
                    $Obj->package,
                    qw[lib Foo Bar.pm]
                );
                
        ok( -e $pm,             "   Module '$pm' exists" );
    
    }
    
    ### check for scripts
    ### XXX get this from config/object
    {   my $script = 'script.pl';
        my $conf   = $Obj->config;
        for my $dir ( $Inst->alternatives_dir, $conf->bin_dir,
                      $Inst->dir->subdir( $Obj->package )->subdir( 'bin' )
        ) {
            my $path = $dir->file( $script );
            ok( -d $dir,        "   Bin dir '$dir' exists" );
            ok( -e $path,       "       Script '$script' installed there" );
        }
    
    }
    
    ### XXX check for manpages
    {
        1;
    
    }


    ### install again
    {
        my $log = file('error_log');
        my $fh  = $log->openw;
        local $Log::Message::Simple::ERROR_FH = $fh;
        
        ok( $Obj->install( installation => $Inst ),           
                                "Second install returns true" );

        close $fh;
        like( scalar $log->slurp, qr/is already installed/,
                                '   Prior installation detected' );

        $log->remove;
    }
}    

### Uninstall tests
{   my $inst_pkg = $Inst->is_installed( package => $Obj );
    ok( $inst_pkg,              "Retrieved installed package" );
    isa_ok( $inst_pkg,          "JIB::Package::Installed" );
    ok( $inst_pkg->uninstall,   "   Package uninstalled" );

    ### XXX more file tests
    for my $file ( @{ $inst_pkg->files } ) {
        ok( !-e $file,          "       File '$file' no longer exists" );
    }    
}


# Local variables:
# c-indentation-style: bsd
# c-basic-offset: 4
# indent-tabs-mode: nil
# End:
# vim: expandtab shiftwidth=4:



( run in 1.101 second using v1.01-cache-2.11-cpan-5c0b1e786e0 )