The McDev Blog

Kevin McKelvin's perspective of the Ruby world.

Ruby Koans – Learn Ruby by TDD!

Ruby caught my attention quite some time ago. The expressiveness, stability, widespread adoption (and awesome community!) and the fact that the whole language is open source were just a couple of the bits that got me interested.

I’m also a great fan of test driven development (TDD). But I’d never have thought I’d learn a language by using unit tests.

That said, Jim Weirich of Edgecase has produced a really awesome suite of tests that guide one through the “path to enlightenment” of Ruby. Each step of the journey is guided by the rake (Ruby make) build environment, and follows the Red-Green-Refactor workflow we’ve grown accustomed to in TDD.

While being simple enough to show the language features one small assertion at a time, they still show the more nitty-gritty parts of Ruby that you usually won’t find documented in a tutorial or book. It forces you to actively think about the code as you progress, rather than just read over it or parrot it out.

Check it out yourself at http://github.com/edgecase/ruby_koans. Clone the repository and get started!