ShowMeTheMoney-9 - What a Row...Fixture

Its time to take on RowFixture.. A few seconds to limber up. OK. LET’S DO THIS..

Lets look at the Fitnesse Tables.. a little modding and executable specs ready

So the first table (from the prev posts) adds 3 credit entries and deletes the last one. The next table then queries the credit entries, expecting the right description and amount. The FIT Server would use the cell values to match the records/rows. The first column is blank – I’m expecting it to be filled with actual creation dates as advertised (also this field would not be used to match expected and actual rows) So we need to write the fixture code now..

file: ShowMeTheMoney/AcceptanceTests/get_inflow_records.rb

require File.dirname(__FILE__) + '/../test/test_helper'

require 'fit/row_fixture'

module AcceptanceTests
class GetInflowRecords < Fit::RowFixture
def query
recordSet = []
Credit.find(:all, :order => 'id').each{|creditEntry|
recordSet << \, creditEntry.description, creditEntry.amount )


def get_target_class


class InflowRecord
attr_reader :received_on, :description, :amount

def initialize dtReceivedOn, sDescription, fAmount
@created_at = dtReceivedOn
@description = sDescription
@amount = fAmount
puts @amount
@@recordMetaData = {
'received_on' => Date,
'description' => String ,
'amount' => Float }
def InflowRecord.metadata

Now let me explain how I understand this thing works. RowFixture classes need to query a set of records and match it with an expected set of records, which are specified in the Fitnesse table. It uses the values in the table to perform the matching.
  • The query method of the fixture should be overridden to obtain a set of records. i.e. we use the Credit model class to retrieve the records, wrap them into InflowRecord objects and stuff them into the output array
  • The get_target_class method identifies the type of objects in the set. i.e. InflowRecord here.
  • The InflowRecord class ( more of a data-struct ) should have reader methods to query individual attributes and a metadata static/class method to help the fixture map the attributes to data types.
I have translated Credit’s created_at attribute into InflowRecord’s received_on because it makes more sense in the table. Also the received_on column is blank. The values cannot be predicted and hence should not be used to compare the records. I expect the blank cells to be filled with the current attribute values as advertised in the docs/examples
And here comes RubyFit storming out of the corner..

  • The next row in the test-output is more of the same. For some reason it is trying to call received_on on the Credit instance, even though I am giving it a hand-made InflowRecord object to play with.
  • The blank rows show up as “missing” and surplus records are added to the table.
After some cajoling, no luck.. won’t happen. I secede. I change the column name in the table to ‘created_at’. Find&Replace in the fixture code AND some thing that fits in one screenful this time.

So, none of the blank cell filling goodness for me. After some time trying to find out why; I decide to drop that column from the table..

The Green glow almost makes up for the fact that my arms feel like Dr. Reed from all the arm twisting by Fit. What a Row!! Good news is that I can mark my tasks as complete. THE STORY IS DONE.. YAY!!... Well except for the UI Design task. But that would be just a little of view html tweaking …. I hope (GULP!)

Lets update our chart, we got 3 ideal hours worth of work done. One more day to go in the iteration.. we are no where close to our initial estimates... However this is our first iteration - so some uncertainity is to be expected.

No comments:

Post a Comment