Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

Screencast: Coding Conway’s Game of Life in Ruby the TDD Way with RSpec

By Peter Cooper / November 2, 2011

Recently, there have been many screencasts of people coding things in real time. Yesterday, Ryan Bigg released a video of him implementing Conway's Game of Life from scratch by reading through the 'rules' and then using RSpec to take a test driven approach to fleshing out the functionality.

Ryan is a Ruby Hero and technical writer best known for being co-author of the recently released Rails 3 in Action (along with Yehuda Katz) which I'll be reviewing soon for Ruby Inside. But Ryan's also been getting into doing a little screencasting:

If you can't see the video above, view it directly on Vimeo here.

Ryan's technique is just one of many legitimate approaches but many of you will find something to pick up from this, especially if you're not familiar with test driven development or, perhaps, RSpec. If you're already working on koans non-stop and consider yourself well versed in the ways of TDD, you might want to skip it.

The only downside is that Ryan focuses entirely on the logic without doing a live render of the game board to see his work in action, though this was the right rational choice given the time limit. That would make a good separate project to follow on with, though, if you fancy a little challenge, but be careful to not couple the game logic tightly to any interface you choose to try.


  1. Adam Leonard says:

    Awesome screencast ! It will be very beneficial for those wanting to better understand TDD, as you can have someone explain it to you a million times, but you learn so much more by watching them do it.

  2. Justin Forder says:

    "If you're already working on koans non-stop..." had me thinking for a while (as koans do). Perhaps you meant "katas" :-)

  3. Will says:

    "The challenge was to implement Conway's Game of Life in under 45 minutes -- that's actually impossible to do."

    Impossible, eh?

    Took 30 minutes, and I wasn't even trying to be fast.

  4. Gimi says:

    @Will I think 45 minutes mean in a TDD way, include 100% test.

  5. Justin Forder says:

    Ignore my comment about koans - I didn't know about

    I found out about that when reading a sample of the forthcoming book "Build Awesome Command-Line Applications in Ruby", which is available as a beta book and now has all the chapters (but not the appendices).

    I bought a copy, and at first sight it looks great - very thorough but still pretty readable.

  6. Petr says:

    This is wrong. How can you immediately modify the world (cell.die! for example)? It could interact with other cells that are next in the each loop. There should be current_world and next_world and you should copy them on world.tick!

    Is it TDD fail? Or there will be some test later which shows this problem and we will have to fix it. Is thinking about this problem some type of "premature optimization" banned in TDD method?

  7. Pingback: Further reading 2011 | the fancy part of the web -

Other Posts to Enjoy

Twitter Mentions