Simplify string handling in spec/main.rb.

The code paths are nearly the same, so make them share the same code,
both to reduce duplication, and as documentation.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>