diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 09:08:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 09:08:42 +0000 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /qa/spec/support/matchers/eventually_matcher.rb | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) | |
download | gitlab-ce-b76ae638462ab0f673e5915986070518dd3f9ad3.tar.gz |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'qa/spec/support/matchers/eventually_matcher.rb')
-rw-r--r-- | qa/spec/support/matchers/eventually_matcher.rb | 19 |
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 |