aidy
6/7/2006 10:07:00 AM
Hi Chris,
I have looked at the Pragmatic Ruby book and I think my design could be
wrong. Though I know I can override a method in a module.
This what I have:
module Territory
def search_territory(country, depot, rest={})
$ie.select_list( :name, 'criteria.countryId').select(country)
$ie.select_list( :name, 'criteria.depotId').select(depot)
$ie.select_list( :name, 'criteria.lob').select(rest[:lob])if
rest[:lob]
$ie.select_list( :name,
'criteria.territoryType').select(rest[:territory])if rest[:territory]
$ie.select_list( :name, 'criteria.viewType').select(rest[:view])if
rest[:view]
end
end
The superclass
class ST_LTD_6
def run
begin
login('aidy', '12345')
.........
search_territory("GREENLAND", "NUUK", :view => "Past")
.......
rescue => e
puts("TEST FAILED:" + e.message + "\n" + e.backtrace.join("\n"))
ensure
log_out
close_window
end
end
end
the base class
class ST_LTD_7 < ST_LTD_6
def run
super # call this method in the supercalss
search_territory("GREENLAND", "NUUK", :view=> 'All')
end
end
test=ST_LTD_7.new
test.run
Now, I have put your code in #run, because the way I interpret it, if
it goes in #initialize as soon as the object is created that method
will be invoked.
If I run the method in ST_LTD_7, what seems to happen is that the
#search_territory is invoked from ST_LTD_6 and ST_LTD_7. So in the
A-U-T,
"Past" is chosen in the combo *then* "All". What I am depseratley
trying to avoid is just copying and pasting the code again and making
one change.
Thank You
Aidy