Overview

Mocking Library

Test::Stream comes with a very powerful mocking library.
Classes

Mocking Classes

You can mock a class directly: You can also mock a class as gathered from an instance of the class:
Objects

Mocking Objects

$mock

$mock Object Methods

The $mock object itself has several useful methods:
add
Add a symbol
override
override a symbol
restore
restore a symbol (pop)
reset
reset symbol to original
reset_all
undo all mocking
orig
get the original symbol
current
get the current symbol
before
new sub that calls custom code, then the original
after
new sub that calls original sub, then your custom code
around
new sub that calls your custom sub with the original as an arg
autoload
turn on autovivification of accessors
block_load
prevent the real class from being loaded
file
return the filename for the mocked class
stash
get a reference to the mocked package stash
parent
get the parent mock object if there is nested mocking
child
get the child mock object if there is nested mocking
Spec

Mock + Spec