If you’re a bad boy and sometimes write tests after the code you’re testing, here’s a quick tip:
It’s nice to be able to glance at the code being tested while writing the tests. When working e.g. with Rails, the tests and the code are typically in different files.
Copy the code being tested. Paste it at the bottom of the test file, under an
END line, and it will in effect be commented out (it actually goes into the DATA global constant).
So while writing a test, your buffer may now look like so:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
I remove the
END and everything after it once the test has been written.