Posts Tagged ‘kata’

Tic Tac Toe 2 – Initial code and story-driven class.

datePosted on 02:30, March 19th, 2009 by Peter Fitzgibbons

Episode 2: Using the story from the ground up.

I could go into great detail… but I’m beat.  Creating the dev environment from the ground up was a lot of work.  I also needed to get some project details under way.

Here is what I needed to get Features and Specs to load up the library properly

Cucumber

Create a cucumber.yml.  This is necessary to set the default profile, which I wanted to get a little more pretty printing during the cucumber command.

In a step definition (grid_steps.rb), I needed the $LOAD_PATH to point to the lib, so I added the following to the top of support/env.rb

$:.unshift File.expand_path(File.dirname(__FILE__) + "/../../lib")

Also support RSpec expectations/matchers within the steps, so

require 'spec/expectations'

RSpec

Update the $LOAD_PATH here from a different location in the tree than features, from ./spec

$:.unshift File.expand_path(File.dirname(__FILE__) + "/../lib")

Autotest integration

In order to get cucumber integrated with autotest, add this to cucumber.yml

autotest: --format pretty features
autotest-all: --format pretty features

Also autospec requires an environment switch, which I have added to ./bashrc for convenience

export AUTOFEATURE=true

Amber to Red to Green to Amber to Red to Green…

With all the prettyness set up with cucumber and RSpec, we now have a new color in the Red-Green cycle.

Cucumber Features’ Given/When/Then lines are displayed in Amber until each is properly trapped by a defined Given/When/Then in a steps definition file (./features/step_definitions/*.rb).

RSpec specs are displayed in amber if the spec is not defined (name only) like this

it "this spec is not defined yet"

Well, that’s about all I can handle for now.

I will make an attempt to trap the Amber-Red-Green cycle in git commits during my work tomorrow.

TicTacToe 1- Dev Environment

datePosted on 03:20, March 18th, 2009 by Peter Fitzgibbons

Here’s the entirement development environment for TicTacToe.  This was actually rebuilt for this project as I deleted my last dev environment (A VirtualBox instance) during a system-repair process (wipe-drive-reinstall of Vista ;)

  • Ubuntu 8.10 Desktop as VirtualBox Guest on Vista Home Premium on Compaq C771.  NAT, 1gb ram, 16gb vhd, shared folders
  • Ruby 1.8 + dependencies from Apt
  • Rubygems 1.3.1 installed from .tgz (Ubuntu 8.10 has trouble with Apt’s rubygems install)
  • Rails, RSpec, RSpec-Rails, Cucumber gems installed
  • NetBeans 6.5.1 / All Modules.  NBGit installed for Git integration.

Tic Tac Toe Kata

datePosted on 12:39, March 17th, 2009 by Peter Fitzgibbons

This week I am starting a Tic Tac Toe Kata in response to a programming exercise by a future employer.  (Wave to you!)

Here are my rules for performance of the kata:

  • Blog after every long session developing – discuss progress and response about the “kata” of the kata
  • Track time for every session.  Report will be posted at kata completion
  • Use Story-driven-development.  Using Cucumber.  And thusly Behavior-driven-development through RSpec.
  • Document api via RDoc

And here is the kata:

What we have in mind is a simple Tic-Tac-Toe program.
At the least this program should:

  1. Allow for a human player.
  2. Play against a human.
  3. Have some user interface, text is fine.
  4. Never lose. Furthermore, it should win whenever possible.

We would like you to use Ruby as the programming language.  (My Pleasure!)

So, in my next posting I’ll be into project setup, prerequisites, and the first story or two.

Update 3/17/09: Add RDoc to expected deliverables.