BDD/TDD test cycle for beginners

I sent this message to a RailsMentor Protege of mine :

A couple notes on BDD testing :

1. Never test “the glue”. “Glue” means anything that Ruby or Rails should be doing “automatically”. That means, database querying, sending values from controller to view, etc. So, in a view test, you should be able to adequately test your views using the isolated view tests. This is where you could test that your table-building code is working right as you expect. Your controller tests should be able to be tested without database requests (mocking model instances), see #2.

2. Skinny Controllers, Skinny Views. Make your controller code, and your view usage as absolutely minimal as possible.
The ideal controller method looks like :
def show
respond_with @some_record
end

Yes, THAT SMALL. Rails framework provides a HEAP of assistive methods to accomplish that. #before_filter, #after_filter, #respond_to

Views should contain very little Ruby code. #render :partial and generous use of Helpers allows your view code to be very small (and subsequently, very testable). Repeatable elements like table-rows should be in partials, where they are easily testable.

3. Cucumber-level testing : Are you using Cucumber (http://cukes.info)? Cucumber scripts should really be reserved for “business owner specification”. A business owner would not usually be concerned with error handling or the exact placement (or even widget-type) of elements on the forms. The Business owner instead is interested in knowing that Page A => Page B => Page C works… or for instance, “If I buy product “Widget Sharpener”, then my shopping cart counter increases to 1 ”

There is a general BDD/TDD work cycle :

Create cucumber feature
Code supporting Cucumber step
Cucumber-RED : Cucumber execution fails because step causes failure in model/view/controller
Match expected functionality in model/controller/view RSpec
RSpec-RED : Rspec execution fails because functionality is not implemented
Modify model/view/controller with added functionality
RSpec-GREEN : Rspec now succeeds
Cucumber-GREEN : Cucumber now succeeds

You will often find steps 5-7 (Rspec Red/Green cycle) will repeat several times between Cucumber Red/Green cycles. This is our minute-to-minute Ruby-programmer’s work experience.

I’m looking forward to hearing more from you of your experience learning Ruby and Rails.

Brown Shoes Introduction

I will be writing about lessons-learned as I move through
the implementation of Shoes on Jruby.. known as Brown Shoes.

Repo – What’s what where

The Brown Shoes Repo is at : https://github.com/shoes/shoes/tree/brown_shoes – a branch on Shoooes Github project.

Right now there are two parallel implementations within
the brown_shoes branch.

At ./lib/shoes is the Eclipse SWT Library implementation.
This is using the expected event-loop main-display and
native SWT widgets.

At ./lib/brown_shoes is the Java/Swing implementation.
JFrame, JPanel, and a bit of AWT as necessary.

There are some issues found on the Pivotal Tracker for
Brown Shoes https://www.pivotaltracker.com/projects/444909

We need your help!

There are details about running SWT or Swing apps that
completely befuddle the newbie in this Jruby/Shoes
business. (namely.. ME!)

If you are a seasoned Jruby, Java/SWT, Java/Swing… or
maybe just JAVA developer, and have interest and a few
hours to spare, your expertise would be GREATLY
appreciated.

Who’s up for a fun challenge that will help Kids learn
Ruby – Hackety Hack runs on … Shoooes!

How to find what you’re looking for – a Google adventure.

So, I have been searching for a long time to re-discover the correct location of my children’s original orphanage in Carrefour, Haiti, “Heart of God Ministries, Haiti”.

We have repeatedly found the nearby “Auberge du Quebec” Hotel, which is where we stayed on several trips to Haiti to see our future adoptees and “check things out”.

What my wife and I had lost since those stressful times (adoption is almost always a nerve-wracking experience), was a memory of the exact location (and eventually, even the name!) of that orphanage.

So, here are the steps I took to re-discover this point in time and space.

A Viscinity

A map of the “general area” was my starting point.  This was easy at first, “Carrefour, Haiti” gains a direct hit, and immediate link to the “geographic center” on Google Maps.  Unfortunately, the default view is about 5 square miles of land, and I simply could not find the Auberge du Quebec on that space.  I knew it was “near”, though.

So I searched for several variations of “auberge du quebec map”, without successful links.  Then it hit me (early in the morning, after a fitful night), search “auberge du quebec carrefour lat long”.  Bingo.  A forum posting specifying the lat/long of our repeated resting quarters.  This happened to be a posting shortly after the Jan 20, 2011 earthquake.  If only I could figure out how to publicly post that location with a name…

Onward.

A Name

Now I needed a name to find the orphanage.  What was it now?  “Something du something”.  Bah.  I seem to recall the name had something to do with the owner’s name “Heart of God”.  Google Translate to the rescue, pick “Haitian Creole” as the target translation (I am personally amazed that Translate can do Haitian Creole)… and “ke bondye”.  Ahh… yes, starting to come back to me now.

So next I Google “kè bondye, carrefour, haiti”.  First hit : Orphanages recognized by the IBESR.  Bingo again!  Even though this is a pay-for-paper service, reference-looks are free, which is all I needed.  So now I have the “actual” address of “Krèch Kè BondyeHAITI”.

A Place

Now to find it?   Google Maps has painfully unmarked maps for Haiti in general.  So, Google Web again, and again this was a hunting expedition.  I eventually started reading the whole result list for “carrefour, haiti map”.  Last on the first page was a linke for MapQuest.  Oh, my “old’ favorite, circa 1998, until this newfangled web company named “Google” came around with a tightly integrated mapping system that actually seemed to “just know” what I was searching for.

Well, MapQuest has been doing their homework!  Carrefour, Haiti is a completely mapped region, ALL street names marked.  And lo, right next to Auberge du Quebec on the MapQuest streets are the first of several “Mahoutiere”.  A quick visual search revealed the block-corner that once contained our children’s orphanage.

A final destination

Although my wife and I cannot clearly identify “which” building on that grainy sattelite view was the actual orphanage, we know a location.

And thanks to the internet, the endless and thorough implementation of several public-service webistes, we now have a destination that we *could* return to one day, on a trip to Haiti.  Who knows, maybe someone on that block will excuse our poorly worded pidgin-creole, and tell us “Oh YES, Krèch Kè Bondye was *right there*.”

Observations

Being an information research practitioner has been made very easy by the likes of Google and MapQuest.  What has not been automated is the human intuition.  I cannot write in Google Search “The orphanage next to Auberge Quebec in Carrefour, Haiti” and achieve a useful result. (Nor ANY result).  This seems to be most a disconnect and deficiency in internet-intellect.  There are not enough computers (or interested parties) to have “right at hand” the information required to be indexed and presented as results to the english-language request.

As we can tell, the answer required human-language-translation, cartographic indexing (lat/long), several tangential searches, and several protected-document views.

So this may be a problem for information-processing specialists to tackle.  Until then, we need our intuition, and our information researchers to keep doing their jobs, and helping us find the revealing information about the world around us.

Heart of God Ministries (Krèch Kè Bondye-HAITI)
Mahotière 75 #5
Zone Simalo, Carrefour
Port-au-Prince, Haïti

Lego Mindstorms NXT-G moving from 1.0 to 2.0 – TriBot : Part 1

I discovered after installing Lego Mindstorms 2.0 NXT-G software that no one on the interwebs has captured this information before.

The Lego Mindstorms NXT 1.0 building instructions are found at Mindstorms Support 8527 -TriBot

So, without further ado, here is the Programming Guide for the Lego Mindstorms 1.0 TriBot : Part 1 – Driving Base