Install this theme
Don’t Write Tests

Writing code without tests usually looks like this for me.  Let me know if it sounds familiar.

  1. Open the console
  2. Create some base objects (usually Active Record Models)
  3. Write some code reopening classes along the way
  4. See if it works the way I expect it to
  5. Copy the code to a scratch space
  6. Repeat 3 - 5 until I think I’ve got what I’m looking for (occasionally jumping back to 1 to clear the environment)
  7. Put the code in the files where it belongs
  8. Checkin

The process gets a little longer when I get to working with the full stack and am looking at the browser.

  1. Create some basic models with known values
  2. Go to the URL in the browser needed to see what I’m working on
  3. See if it works
  4. Go back to the editor and try something different
  5. Repeat steps 3 & 4 until satisfied
  6. Checkin

Hey I’ve watched (some of) the Abelson and Sussman lectures and know that programming by wishful thinking is useful so sometimes I create functions/methods that use a not complete implementation.  That looks like:

  1. Realize that I’m going to need a function/method that I haven’t created yet
  2. Figure out a name for it
  3. Give it a minimal implementation
  4. Go back to what I’m working on
  5. Finish what I’m focused on
  6. Checkin
  7. Go back and finish off the helper
  8. Checkin

This should sound familiar to some if not many of you. 

What if I told you there was a framework for automating many of those steps?  Wouldn’t that be awesome? 

Steps like:

  • Creating basic objects to play with
  • Seeing if the code you’re writing does what you expect
  • Pretending that functions/methods that don’t exist yet exist with a basic implementation

It’s call rSpec people (optionally with Guard).  You can create those basic objects and wishfully-thought-of functions with rSpec stubs and mocks.  You can check if your code works the way you think it should with should.  You can even have those steps happen automatically with guard.

I invite you to not write tests (that’s boring), automate your process.  Machines should work and people should think.  The fact that you have a suite of tests and documentation at the end of the day is a bonus not the point.

—R