Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Getting Started with Ruby Koans

Getting Started with Ruby Koans

A short presentation about getting started with the Ruby Koans

Corinna Brock

October 16, 2012
Tweet

Other Decks in Programming

Transcript

  1. WHAT IS A KOAN? a paradox to be meditated upon

    that is used to train Zen Buddhist monks to abandon ultimate dependence on reason and to force them into gaining sudden intuitive enlightenment -- merriamwebster.com
  2. ABOUT THE KOANS “The Koans walk you along the path

    to enlightenment in order to learn Ruby. The goal is to learn the Ruby language, syntax, structure, and some common functions and libraries. We also teach you culture. Testing is not just something we pay lip service to, but something we live. It is essential in your quest to learn and do great things in the language. --rubykoans.com
  3. WHAT IS TESTING? •  Ruby is a test driven development

    language •  In test-driven development the mantra has always been: •  red : write a failing test and run it, •  green : write just enough code to make the test pass, and •  refactor : look at the code to see if you can make it any better. •  Some common testing gems: •  Cucumber •  Turnip •  Steak
  4. STARTING DETAILS •  Download, don’t web-base •  RubyKoans does offer

    you the option to web-base, which is a good option if you want to practice but are not on your local machine •  Push repository to Github
  5. ABOUT ASSERTS •  The first testing set instructs you in

    what to replace to help get you used to testing syntax. •  It clearly tells us to do this:
  6. TRY IN IRB: ABOUT NIL •  Our next class, about

    nil, gives us the first chance to test things in IRB. Here is the first test in about nil: •  Let’s test this in IRB:
  7. TRY IN IRB: ABOUT NIL •  We change the __

    to true, and run ruby path_to_enlightenment.rb again, and our test passes.
  8. DEALING WITH EXCEPTION TESTING •  The next assert asks us

    to provide the error raised when nil doesn’t know about a method. This is another great one to try in IRB.
  9. DEALING WITH EXCEPTION TESTING •  Again, copy and paste the

    method call into IRB: •  So the solution to this assert is as follows:
  10. INHERITANCE •  Ruby Koans gives a clear and concise view

    of Inheritance. It defines a class, sets up two methods, illustrates how traits are both inherited and not passed up. The class is established as follows: