Module: Maxitest::Timeout

Defined in:
lib/maxitest/timeout.rb

Defined Under Namespace

Classes: TestCaseTimeout

Instance Method Summary collapse

Instance Method Details

#run(&block) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/maxitest/timeout.rb', line 16

def run(*, &block)
  # NOTE: having a default def maxitest_timeout would break using let(:maxitest_timeout)
  timeout = (defined?(maxitest_timeout) ? maxitest_timeout : Maxitest.timeout || 5)
  if timeout == false
    super
  else
    begin
      ::Timeout.timeout(timeout, TestCaseTimeout) { super }
    rescue TestCaseTimeout => e
      failures << UnexpectedError.new(e)
    end
  end
end