Koans Complete!

According to Wikipedia, a Koan is a story, dialogue, question or statement used in Zen practice to provoke the “great doubt” and test a student’s progress.  When referring to learning Ruby, the Koans Project is a valuable introduction and learning tool.

The Neo Ruby  Koans project gives you hands-on experience with the main aspects of Ruby, covering blocks, classes, constants, hashes, arrays and much more.  It takes you through a series of subject-specific project test scripts where you provide the answers as in the following example.

array =  [1, 2, 3]
new_array = array.collect { |item| item + 10 }
asset_equal __ , new_array

Your task is to fill in the “__” test assertion value.

Taking the Test

When you launch the project with

$ rake

the test will be evaluated displaying the success or failure of the test.  Here’s what that looks like in Sublime Text and a terminal session in Linux Mint.

Koans also requires you to write a few simple classes to support completed Test Assert definitions, like this one for determining triangle types.

Here’s a sample Koans Test Assertion statement which the above Ruby definition needs to satisfy.

assert_equal   :scalene , triangle(3, 4, 5)

How long it takes to complete the Neo Ruby Koans test obviously depends on your familiarity with Ruby.  If you’re starting out with Ruby the Koans Test Project is worth the investment, whether it takes you days or even weeks to find, um, enlightenment.