An example of refactoring with tests, from Martin Fowler's Refactoring, chapter 4, Building Tests.
Run the tests with:
ruby test/producer_test.rb
ruby test/province_test.rb
A Rubified version of Fowler's test walkthrough in Chapter 4 of Refactoring.
Ruby