Skip to content

Use be_within matcher to avoid test flakiness

Eugie Limpin requested to merge el-quarantine-flaky-test into master

What does this MR do and why?

Resolve #439673 (closed).

Use be_within matcher as described in https://docs.gitlab.com/ee/development/testing_guide/best_practices.html#be_like_time to avoid test flakiness.

This fixes the following error sometimes encountered when running ee/spec/services/phone_verification/users/send_verification_code_service_spec.rb

# difference of 1 between 1706494526 and 1706494827

expect { service.execute }.to change { [record.reload.sms_send_count, record.reload.sms_sent_at.to_i] }
         .from(old_values).to(new_values)
       expected `[record.reload.sms_send_count, record.reload.sms_sent_at.to_i]` to have initially been [1, 1706494827], but was [1, 1706494526]

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Edited by Eugie Limpin

Merge request reports