Module: Calabash::Android::Retry

Defined in:
lib/calabash-android/retry.rb

Class Method Summary collapse

Class Method Details

.retry(opts, &blk) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/calabash-android/retry.rb', line 4

def self.retry(opts, &blk)
  tries = opts[:tries]
  interval = opts[:interval]

  tries.times do |try|
    begin
      blk.call
      return

    rescue => e
      if (try + 1) >= tries
        raise
      else
        sleep interval
      end
    end
  end
end