Specs for where $_ is defined and when it is defined?

So I should have an external file (I've seen examples of those) and I should probably pipe stdin and use that to use #gets without actually requiring user input.

I know the problem of depending on it StringIO - I have had to shim it for Truffle to get the rest of the predefined specs passing.