summaryrefslogtreecommitdiff
path: root/qa/spec/support/matchers/eventually_matcher.rb
diff options
context:
space:
mode:
Diffstat (limited to 'qa/spec/support/matchers/eventually_matcher.rb')
-rw-r--r--qa/spec/support/matchers/eventually_matcher.rb19
1 files changed, 10 insertions, 9 deletions
diff --git a/qa/spec/support/matchers/eventually_matcher.rb b/qa/spec/support/matchers/eventually_matcher.rb
index 3f0afd6fb54..7a35a3165ae 100644
--- a/qa/spec/support/matchers/eventually_matcher.rb
+++ b/qa/spec/support/matchers/eventually_matcher.rb
@@ -9,7 +9,7 @@
# expect { Something.that.takes.time.to_appear }.not_to eventually_eq(expected_result)
#
# With duration and attempts override
-# expect { Something.that.takes.time.to_appear }.to eventually_eq(expected_result).within(duration: 10, attempts: 5)
+# expect { Something.that.takes.time.to_appear }.to eventually_eq(expected_result).within(max_duration: 10, max_attempts: 5)
module Matchers
%w[
@@ -21,9 +21,9 @@ module Matchers
be_empty
].each do |op|
RSpec::Matchers.define(:"eventually_#{op}") do |*expected|
- chain(:within) do |options = {}|
- @duration = options[:duration]
- @attempts = options[:attempts]
+ chain(:within) do |kwargs = {}|
+ @retry_args = kwargs
+ @retry_args[:sleep_interval] = 0.5 unless @retry_args[:sleep_interval]
end
def supports_block_expectations?
@@ -52,11 +52,12 @@ module Matchers
# @param [Symbol] expectation_name
# @return [Boolean]
def wait_and_check(actual, expectation_name)
- QA::Support::Retrier.retry_until(
- max_attempts: @attempts,
- max_duration: @duration,
- sleep_interval: 0.5
- ) do
+ attempt = 0
+
+ QA::Runtime::Logger.debug("Running eventually matcher with '#{operator_msg}' operator")
+ QA::Support::Retrier.retry_until(**@retry_args) do
+ QA::Runtime::Logger.debug("evaluating expectation, attempt: #{attempt += 1}")
+
public_send(expectation_name, actual)
rescue RSpec::Expectations::ExpectationNotMetError, QA::Resource::ApiFabricator::ResourceNotFoundError
false