Module: RSpec::Wait::Handler

Included in:
NegativeHandler, PositiveHandler
Defined in:
lib/rspec/wait/handler.rb

Instance Method Summary collapse

Instance Method Details

#handle_matcher(target, *args, &block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rspec/wait/handler.rb', line 6

def handle_matcher(target, *args, &block)
  failure = nil

  Timeout.timeout(RSpec.configuration.wait_timeout) do
    loop do
      begin
        actual = target.respond_to?(:call) ? target.call : target
        super(actual, *args, &block)
        break
      rescue RSpec::Expectations::ExpectationNotMetError => failure
        sleep RSpec.configuration.wait_delay
        retry
      end
    end
  end
rescue Timeout::Error
  raise failure || TimeoutError
end