blob: 91ec0e59e371c99278a6c0512e936936734242ab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# frozen_string_literal: true
module QA
module Resource
module Events
MAX_WAIT = 60
RAISE_ON_FAILURE = true
EventNotFoundError = Class.new(RuntimeError)
module Base
def events(action: nil)
path = [api_get_events]
path << "?action=#{CGI.escape(action)}" if action
parse_body(api_get_from("#{path.join}"))
end
private
def api_get_events
"#{api_get_path}/events"
end
def wait_for_event
event_found = Support::Waiter.wait_until(max_duration: max_wait, raise_on_failure: raise_on_failure) do
yield
end
raise EventNotFoundError, "Timed out waiting for event" unless event_found
end
def max_wait
MAX_WAIT
end
def raise_on_failure
RAISE_ON_FAILURE
end
end
end
end
end
|