So I want to learn Ruby using a TDD approach. So I started by installing The Ruby Development Tools Eclipse plugin.
Well it turns out to run Ruby you still need to install a Ruby Interpreter, which I did.
Here are some very early examples trying to use TDD:
DieTest
Die
PairOfDiceTest
PairOfDice
This works, however I want to be able to run all of my tests in one fell swoop. In Eclipse using Java, I simply right-click on a project and select Run->Junit Tests and it’s all good. This feature doesn’t seem to be available in Test::Unit (the Ruby equivalent) so after several attempts, I think I’ve got what I’m looking for:
Suite
This was adequate until I checked my code into subversion. When I did that, I had the original versions of the files in the .svn directory. I then updated this to prune the .svn directory:
Of course, on the Ruby Forum, Ryan Davis gave me a MUCH more concise (and frankly I think MUCH better) version of this:
All “require”d files are read in using a single array. To create the array we first create an array using words (in this case it saves nothing to use %w(test/unit) versus [‘test/unit’]. The + operation on an array adds the contents of one array to another and the Dir class’s [] method recursively finds files using a syntax I’m familiar with from ant.
This generates an array that looks like the following:
Then we require each of theses. By requiring test/unit, all other files read in using require that inherit from Test::Unit::TestCase are automatically added to a suite.
Having managed the first version, I continued with the first release of Monopoly.
Comments