Test Automation with Ruby: Don't drink the kool-aid

I was stuck at home this weekend with house painters pondering how best to spend the day sitting at home, so I decided to actually play around with the Ruby scripting language a bit. I will admit my bias in my previous post about the Ruby scripting language was based on business justifications and personal preferences towards the C family of languages. But, because Ruby is still being pimped by some experts in the industry for test automation, I figured I should understand more about the mechanics of language other than it's lack luster appeal by many professionals in the software industry.

 

I didn't delve very deeply into Ruby. A few chapters of Hal Fulton's book The Ruby Way and some additional research on the web confirmed my suspicion that Ruby for all purpose software test automation is simply not a good investment in your time given the other alternatives.

 

International Support Sucks!

 

If you are stuck working on small projects in English only then this probably won't bother you too much. But, if you realize the majority of the world does not communicate in English then Ruby's lack of international support simply sucks. Unless there is some hidden secret in the Ruby society the fact is Ruby can't do Unicode. Yes, you can store UTF-8 encoded data in 8-bit encoded strings, but many Ruby String methods assume single byte encoding. I have to admit this completely blows my mind. UTF-8 is a popular encoding form of Unicode; however, it is only one of several Unicode transformation formats. So, forget about UTF-16, and definitely forget about testing Unicode surrogate pairs or conformance to the GB18030–2000 Chinese encoding standard. So, what does this mean for testers? String testing is basically limited to a very small subset of characters.

 

Multiple ways to initialize arrays (and just about anything else)

 

Hal Fulton lists the following 3 ways to initialize the array class method.

            a = Array.[](1,2,3,4)

            b = Array[1,2,3,4]

            c = [1,2,3,4]

I don't know why this would be a 'cool' thing to do, but I do know that it increases confusion, and potentially adds to the cost overhead of white box testing and code maintenance.

 

I guess it's pretty cool that arrays in Ruby contain objects rather than data types, and an array in Ruby can contain integers, strings, etc. I am not quite sure why this is a positive because I can't think of a situation where I would want to iterate through an array with disparate data types.

 

Cryptic codes

 

If Hungarian notation wasn't bad enough, just stir in some Ruby identifiers into the cryptic pool of sludge. Let's see the # sign is a comment if it is the first character in a new line or after a statement (which of course doesn't end with a semi-colon or other signifier), otherwise it is an embedded variable. And what is the deal with variable scope declarations? The @ sign is used to declare instance variables, using @@ signs declares a class variable, and of course the $ sign declares a variable that is global in scope. Hmmm...I am thinking the access modifiers 'public' and 'private' in C# make a lot more sense, but of course I have to type all those letters instead of just pressing the shift key followed by one or two characters.

 

Useless keywords

 

For all you Ruby experts, can someone please explain the purpose of the unless keyword? It seems to me to be another bit of useless confusion. Let's see if I have this right in Ruby:

 

            if x < 5 then

            statement

  end

and

            unless x < 5 then

            statement

            end

 

are identical! What's the point?

 

Syntax?

 

And what's the deal with 'downcase' and 'upcase' instead of 'lowercase' or 'uppercase?' Is downcase really intuitive to anyone other than Ruby zealots?

 

I could probably go on, but frankly I am convinced that Ruby is not the way.

 

So, that's a day in my life that I will never get back. But, all was not lost because in-between chapters of the Ruby book I got to watch the paint dry on my house.