Write code to generate spec tests

Allows more meaningful failure messages.