Class: GollyUtils::Testing::Helpers::WithinTime

Inherits:
Object
  • Object
show all
Defined in:
lib/golly-utils/testing/rspec/within_time.rb

Overview

See Also:

Instance Method Summary collapse

Constructor Details

#initialize(timeout, sleep_time = 0.1) ⇒ WithinTime

Returns a new instance of WithinTime.

Parameters:

  • timeout (Numeric)

    The maximum number of time units (to be specified after a call to this) to wait for a condition to be met.

  • sleep_time (Numeric) (defaults to: 0.1)

    The number of seconds to wait after an unsuccessful attempt before trying again.



26
27
28
29
30
31
32
33
34
# File 'lib/golly-utils/testing/rspec/within_time.rb', line 26

def initialize(timeout, sleep_time=0.1)
  timeout= timeout.to_f
  raise unless timeout > 0
  @timeout= timeout

  sleep_time= sleep_time.to_f
  raise unless sleep_time > 0
  @sleep_time= sleep_time
end

Instance Method Details

#hours(&block) ⇒ Object Also known as: hour, hr, hrs



38
# File 'lib/golly-utils/testing/rspec/within_time.rb', line 38

def hours  (&block) run 3600    , block end

#minutes(&block) ⇒ Object Also known as: minute, min



37
# File 'lib/golly-utils/testing/rspec/within_time.rb', line 37

def minutes(&block) run   60    , block end

#ms(&block) ⇒ Object Also known as: msec



35
# File 'lib/golly-utils/testing/rspec/within_time.rb', line 35

def ms     (&block) run    0.001, block end

#seconds(&block) ⇒ Object Also known as: second, sec



36
# File 'lib/golly-utils/testing/rspec/within_time.rb', line 36

def seconds(&block) run    1    , block end