Stabilize GithubService spec by loosening settings.write expectations
-
Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA. As a benefit of being a GitLab Community Contributor, you receive complimentary access to GitLab Duo.
What does this MR do and why?
This MR refactors the RSpec tests for the EE::Import::GithubService to eliminate flakiness around the settings.write calls. The strict stub on settings.write plus exact‐match
have_received(...).with(...) expectations were causing intermittent
failures whenever the service passed additional keys
(e.g. extra access tokens) or reordered the hash.
This change:
- Replaces the
.to receive(:write).with(...)stub with a catch-allallow(settings).to receive(:write), so every call is intercepted. - Updates each
expect(settings).to have_received(:write).with(...)to usehash_including(...)instead of exact equality. This ensures we only assert on the three keys we care about, without breaking if extra keys are present.
By making these adjustments, the spec will no longer be brittle about
the exact hash contents and will eliminate the flaky failures related
to settings.write.
References
#540946 (closed), #540945 (closed), #540944 (closed)
Screenshots or screen recordings
N/A
How to set up and validate locally
- Check out this branch.
- Run the spec file multiple times:
bundle exec rspec ee/spec/services/ee/import/github_service_spec.rb - The tests related to
optional_stages,timeout_strategy, andpagination_limitshould now pass consistently.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by 🤖 GitLab Bot 🤖