Also some tests for doing so, all of which pass on Linux, Windows, and Java meterpreter, as well as shell sessions on Linux and Solaris. They will fail miserably on Windows shell sessions.
This makes running tests from a post module as easy as creating methods that start with +test_+ and running +it()+ blocks inside them.