Module: FluQ::Testing

Extended by:
Testing
Included in:
Testing
Defined in:
lib/fluq/testing.rb

Constant Summary collapse

EXCEPTION_TRACKER =
->ex { FluQ::Testing.exceptions.push(ex) }

Instance Method Summary collapse

Instance Method Details

#exceptionsObject



14
15
16
# File 'lib/fluq/testing.rb', line 14

def exceptions
  @exceptions ||= []
end

#track_exceptions!(logger = FluQ.logger) ⇒ Object



18
19
20
21
# File 'lib/fluq/testing.rb', line 18

def track_exceptions!(logger = FluQ.logger)
  return if logger.exception_handlers.include?(EXCEPTION_TRACKER)
  logger.exception_handler(&EXCEPTION_TRACKER)
end

#wait_until(opts = {}, &block) ⇒ Object



7
8
9
10
11
12
# File 'lib/fluq/testing.rb', line 7

def wait_until(opts = {}, &block)
  tick = opts[:tick] || 0.01
  max  = opts[:max]  || (tick * 50)
  Timeout.timeout(max) { sleep(tick) until block.call }
rescue Timeout::Error
end