Thanks both for the suggestions, but I prefer unit tests because they
serve as a great reference for the learner. For example I had some help
the other day with string formatting and now they're saved if I ever
need to check how they work (from string_test.rb):


  def test_percent_operator_with_leading_zeros
    str = "The number is %05d" % 123
    assert_equal("The number is 00123", str)
  end

  def test_percent_operator_with_range_and_leading_zeros
    var = (1..5).map do |n|
      "Num-%02d" % n
    end
    assert_equal(["Num-01", "Num-02", "Num-03", "Num-04", "Num-05"],
var)
  end

  def test_percent_operator_with_two_args
    str = "I'm %s and I'm %d years old." % ["simon", 100]
    assert_equal("I'm simon and I'm 100 years old.", str)
  end


From Mike Clarks blog post
==========================

"In the same way that a test is better than a specification, the
language is better than a description of the language. The test is
definitive¡½when we ask Ruby what the answer to 'Hello! ' * 3 is, we're
going to the horse's mouth. It doesn't matter what the documentation
says; what we're testing is what actually happens. And that's learning.
So the test is both a learning test and a regression test."