Logo Elisabeth Hendrickson’s Thoughts on Testing, Agile, and Agile Testing

RubyFIT and Fitnesse

October 9th, 2007
Filed under Lessons Learned, Ruminations, Test Automation

At the moment, I’m creating a little Acceptance Test Driven Development (ATDD) demo. I’m keen on Ruby these days, so I wanted to do it all in Ruby. And I wanted to use Fitnesse. And as it happens, Fitnesse supports RubyFIT. Or RubyFIT supports Fitnesse. Something like that. So I figured this would be a slam dunk.

I was wrong. It’s taken me the better part of a day. Now it could be because I can’t read directions terribly well. And that may also explain the odd assortment of leftover hardware I have from various Ikea purchases. But I did discover at least one gotcha I didn’t find documented anywhere else, so I thought I’d share.

First, major thanks to Cory Foy for his fabulous little tutorial. And thanks to maosd, whoever you are, for blogging some update notes. They helped a lot. And finally thanks to Ron and Chet for blogging about their RubyFIT/Fitnesse adventures.

Now, for the gotchas I ran into that made a 1 hour project into something more like 6 hours.

  1. Beware hiding the right side of your browser off-screen. The “Errors Occurred” icon in Fitnesse appears on the right hand side of the browser. And if it’s off screen, all you’ll see is a friendly “Assertions: 0 right, 0 wrong, 0 ignored, 0 exceptions” when something goes drastically wrong. Time wasted: 1 hour. Yes, I am an idiot.
  2. By default, mac host names are like host.local. So my iMac, “eshmac”, has a host name of “eshmac.local”. The first problem I ran into was that Fitnesse wanted to refer to the machine as “eshmac,” and my machine maintained “there’s nobody here by that name.” I tried to figure out how to get Fitnesse to let me customize the host name, but to no avail. So I decided to make “eshmac” a legitimate name instead. Now, I’m sure there are better ways to do this, but since I didn’t want to change the host name on the network, I just added a record for “eshmac” and pointed it to “127.0.0.1″ in the /etc/hosts file. Time wasted: 0.5 hours.
  3. As maosd indicates, you need to call the FitServer.rb file from the gem location. Conveniently enough, the path is documented in the README.txt file that comes with the RubyFIT gem. Inconveniently, that file is placed in the very folder I was looking for. The answer is that on Macs, gems get installed to /usr/lib/ruby/gems, and you can find the RubyFIT gem at /usr/lib/ruby/gems/1.8/gems/fit-1.1/. Time wasted: 1 hour.
  4. In Cory Foy’s tutorial, where it says, “You want to go one directory below the directory your class is in,” it really means one directory below. I had my !path variable set incorrectly, and could not figure out for the life of me why RubyFIT couldn’t find the fixture. Silly me. Time wasted: 2 hours - and waaayyy too many “puts” statements.

So, as a service to those who happen to be as documentationally challenged as I am, allow me to be excruciatingly precise about the naming thing with RubyFIT and Fitnesse. It’s enough of a gotcha that lots of people have already written about it. But here’s my attempt at explaining things.

Let’s say you want to call your test page FooTest. And you want to create a Division fixture. And you want to create a directory hierarchy under “/mine” to hold your fixture files.

Your Fitnesse page will contain:

...other stuff...

!path /mine/
|Footest.Division|

...other stuff...

Your fixture code will look like:

...
module Footest
	class Division < Fit::ColumnFixture
		# code goes here
	end
end
...

And that code will live in the file /mine/footest/division.rb

Once again, note that the !path setting in Fitnesse is “/mine/”. For the record, the mistake I made was setting “!path /mine/footest/”. As I said, I’m documentationally challenged.

Matching capitalization does not seem to be important, but the names of the directories, files, modules, and classes sure are. And they all have to match up. So, your test page name must match your module name and that must match the directory name in which the file lives, and does not match the !path variable.

I’m sure I’ll run into more gotchas, but I figured I should document these while I’m thinking about them.

Leave a Comment

Because of the rise in blog-spam, I've turned on comment moderation. If it takes a while before your comment appears, I hope you understand.

Moderation Policy: I approve substantive comments. I reject ads. And if I don't know whether it's substantive or advertising, it sits in my moderation queue until I get sick of looking at it, at which point I reject it, kind of like the questionable meatloaf in the fridge. But please be assured that I think long and hard before clicking that reject link. I really am grateful for every comment any human takes the time to make. (Spambots, not so much. But if you're reading this, you're probably human.) So please contribute to the conversation...