Module: ApiMaker::SpecHelper::WaitForExpect

Included in:
ApiMaker::SpecHelper
Defined in:
lib/api_maker/spec_helper/wait_for_expect.rb

Instance Method Summary collapse

Instance Method Details

#wait_for_expect(*args) ⇒ Object

Waits for an expect to not fail - this is great because it whines



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/api_maker/spec_helper/wait_for_expect.rb', line 3

def wait_for_expect(*args)
  last_error = nil

  begin
    wait_for_browser(*args) do
      yield
      true
    rescue RSpec::Expectations::ExpectationNotMetError => e
      last_error = e
      false
    end
  rescue WaitUtil::TimeoutError => e
    raise last_error if last_error

    raise e
  end
end