ruby-koans: Test driven ruby learning

Recently I found ruby-koans on github. If I should discribe it in a few words I would say it’s a test driven ruby tutorial.

After downloading ruby-koans you call rake and you see the first failing test.

Thinking AboutAsserts
test_assert_truth has damaged your karma.You have not yet reached enlightenment …
<false> is not true.

Please meditate on the following code:
./about_asserts.rb:10:in `test_assert_truth‘

Then you take a look at the test-file

# We shall contemplate truth by testing reality, via asserts.
def test_assert_truth
assert false                # This should be true
end# Enlightenment may be more easily achieved with appropriate
# messages.
def test_assert_with_message
assert false, „This should be true — Please fix this“

# To understand reality, we must compare our expectations against
# reality.
def test_assert_equality
expected_value = __
actual_value = 1 + 1

assert expected_value == actual_value

By correcting the tests you learn much about ruby and tests – step by step.

Like meta programming in ruby this is a meta-way in learning ruby.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *