watir 1.5.6 and ruby 1.8.6-26

On one of my Vista machines I just reinstalled ruby using 1.8.6-26 (one click installer) and watir 1.5.6
Of course I will need to reinstall all other gems because they perished when I uninstalled ruby 1.8.4-25 (yes, sometimes it’s nice to clean up and start again.)

So Ruby 1.8.9-26 bundles gem 0.9.4. I did not update the gem system (I am not sure if I should or not) and then I did ‘gem install watir’. Here is what we get at the prompt.

C:\Users\marekj>gem -v
0.9.4

C:\Users\marekj>gem install watir
Bulk updating Gem source index for: http://gems.rubyforge.org
Install required dependency win32-process? [Yn]  Y
Install required dependency windows-pr? [Yn]  Y
Install required dependency windows-api? [Yn]  Y
Install required dependency win32-api? [Yn]  Y
Select which gem to install for your platform (i386-mswin32)
 1. win32-api 1.1.0 (ruby)
 2. win32-api 1.1.0 (x86-mswin32-60)
 3. win32-api 1.0.6 (ruby)
 4. win32-api 1.0.6 (x86-mswin32-60)
 5. Skip this gem
 6. Cancel installation
> 2
Install required dependency activesupport? [Yn]  Y
Successfully installed watir-1.5.6
Successfully installed win32-process-0.5.9
Successfully installed windows-pr-0.8.6
Successfully installed windows-api-0.2.3
Successfully installed win32-api-1.1.0-x86-mswin32-60
Successfully installed activesupport-2.1.0
Installing ri documentation for watir-1.5.6…
Installing ri documentation for win32-process-0.5.9…
Installing ri documentation for windows-pr-0.8.6…
Installing ri documentation for windows-api-0.2.3…
Installing ri documentation for win32-api-1.1.0-x86-mswin32-60…
Installing ri documentation for activesupport-2.1.0…
Installing RDoc documentation for watir-1.5.6…
Installing RDoc documentation for win32-process-0.5.9…
Installing RDoc documentation for windows-pr-0.8.6…
Installing RDoc documentation for windows-api-0.2.3…
Installing RDoc documentation for win32-api-1.1.0-x86-mswin32-60…
Installing RDoc documentation for activesupport-2.1.0…

C:\Users\marekj>

I am just not sure what activesupport is needed for here. which gem needs it? (I will look at gemspecs)

So to summarize - to install watir 1.5.6 I also needed to install 4 more gems: windows-pr-0.8.6, windows-api-0.2.3, win32-api-1.1.0 (x86-mswin32-60) and activesupport-2.1.0

we’ll dig deeper to make sure installation went great.
next unit tests.

i can has time tracking! with punch rubygem

Just installed rubygem punch (depends on rubygems: main, chronic, attributes, arrayfields, systemu, orderhash) on windows.

and the first try ‘puch help I got the error: couldn’t find HOME environment — expanding `~’ (ArgumentError). Looks like windows problem… so on my machine I changed to:

Home = File.expand_path(ENV['USERPROFILE'])

# C:\ruby\lib\ruby\gems\1.8\gems\punch-0.0.2\bin\punch:313

all is well.

assignment to variables from ARGV array on one line

I have just discovered that you can do this

# lets say ARGV has 3 items [1, 2, 3]
# the following:
a, b, c = ARGV
# will make this
#=> a=1, b=2, c=3

I didn’t know you can do this. I just ready it in one of the examples somewhere and I can’t find it.
Nice way of procesing not only ARGV but other arrays.

#So, this is how I can ship my data in Watir scripts.
# Write out:
ARGV.clear
ARGV << 'a1' << 'b2' << 'c3' # 

# read from:
a, b, c = ARGV
# of course I could use main gem or other option parsers
# but ARGV is a good simple choice

strategy by delagating to an alias

I saw this really nice way of setting behaviour. You call a Student object which has a method formal_greeting that delegates to say_hi, but say_hi is aliasing say_hello which calls a superclass since the say_hello of Student is declared below.

class Person
  def say_hello
    puts 'how do you do.'
  end
end

class Student  Person
end

class Student    # reopening class
  # Assuming Person has a say_hello method...
  alias :say_hi :say_hello #this calls super
  def say_hello
    puts "Hi, there."
  end
  def formal_greeting
    # Say hello the way my superclass would.
    say_hi
  end
end
Student.new.formal_greeting

So positioning alias above say_hello definition ensures your call goes up to super class. Am I reading this correctly? if so then this is a nice strategy for designing watir tests depending on configurations needed for your test objects.