App-Slaughter

 view release on metacpan or  search on metacpan

t/test-lib-slaughter-transport.t  view on Meta::CPAN

$dir = "../lib/Slaughter/Transport" if ( -d "../lib/Slaughter/Transport" );

ok( -d $dir, "We found the transport directory." );


#
#  Look for each module
#
foreach my $name ( sort( glob( $dir . "/*.pm" ) ) )
{
    if ( $name =~ /(.*)\/(.*)\.pm/ )
    {

        #
        #  Name of the module implementation file.
        #
        my $name = $2;

        #
        # Load the module
        #
        use_ok("Slaughter::Transport::$name");
        require_ok("Slaughter::Transport::$name");

        #
        # Create a new instance of the module.
        #
        my $module = "Slaughter::Transport::$name";
        my $handle = $module->new();

        #
        #  Is the module the type we wish to be?
        #
        ok( $handle, "Calling the constructor succeeded." );
        isa_ok( $handle, $module );

        #
        # Test that our required methods are present
        #
        foreach my $method (qw! error fetchContents isAvailable name new !)
        {
            ok( UNIVERSAL::can( $handle, $method ),
                "required method available - $method" );
        }

        #
        # Call the "name" method, which is always safe, and ensure it returns
        # something sane.
        #
        my $reported = $handle->name();
        ok( $reported, "We received output from name()." );
        is( $reported, $name, "The name matches what we expect." );

        #
        #
        # Sanity check by ensuring that a made-up method name is
        # invalid.
        #
        # This ensures we're not misusing UNIVERSAL:can
        #
        ok( !UNIVERSAL::can( $handle, "not_present" ),
            "Random methods aren't present." );
    }
}



( run in 2.469 seconds using v1.01-cache-2.11-cpan-5a3173703d6 )