please excuse me, i'm not a developer but a tester and i'm no good at doing programming stuff and all. im into automation now for my testing and i choose to use ruby for it but i have a problem hope you guys could help me out of this...
i need to do a script that will check my email every 5minutes and after 20minutes of no new mail it will produce "test fail". i have found a cool code for checking email every 5min but i could not find a way to stop it after 20minutes? any help is greatly appreciated :)
here's the code:
def time_block
start_time = Time.now
Thread.new { yield }
Time.now - start_time
end
def repeat_every(seconds)
begin
time_spent = time_block { yield }
sleep(seconds - time_spent)
end while time_spent < seconds
end
repeat_every(300) { # checking of email ever 5 minutes
puts "Start checking: #{Time.now}"
# email checking here
puts "End checking: #{Time.now}"
}