Skip to content

Fix order-dependent youth_birthday_reminder spec (rake tasks loaded twice) - #7320

Merged
compwron merged 1 commit into
mainfrom
fix/flaky-rake-double-load
Nov 1, 2026
Merged

compwron merged 1 commit into
mainfrom
fix/flaky-rake-double-load

Conversation

@compwron

@compwron compwron commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

The docker CI job failed today on #7300 and on the devise_invitable Renovate PR, both at spec/lib/tasks/youth_birthday_reminder_spec.rb:33 (expected change by 1, but was changed by 2).

Cause: spec/seeds/seeds_spec.rb called Rails.application.load_tasks with no guard. If rake_tasks_constants_spec loaded the tasks first, the seeds spec loaded them a second time. Rake then appends each task body again, so youth_birthday_reminder ran twice per invoke. It only fails under some random orders, which is why rspec.yml usually passes.

Repro (fails before this change, passes after):

bundle exec rspec spec/lib/tasks/rake_tasks_constants_spec.rb spec/seeds/seeds_spec.rb spec/lib/tasks/youth_birthday_reminder_spec.rb --order defined

Before: 8 examples, 3 failures (2 vs 1, 4 vs 2, 2 vs 1). After: 8 examples, 0 failures.

Fix: use the same if Rake::Task.tasks.empty? guard the other two task specs already use.

🤖 Generated with Claude Code

…wice)

seeds_spec called Rails.application.load_tasks unconditionally. If it ran
after another spec had already loaded the tasks, every task got its body
registered twice, so a later youth_birthday_reminder spec saw 2
notifications where it expected 1. Guard it like the other task specs do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added 🧪 Tests Tests ruby Touches Ruby code labels Nov 1, 2026
@compwron
compwron merged commit 439040f into main Nov 1, 2026
11 checks passed
@compwron
compwron deleted the fix/flaky-rake-double-load branch November 1, 2026 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ruby Touches Ruby code 🧪 Tests Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant