Skip to content

test: close strong_migrations preboot note coverage gaps - #3062

Merged
mroderick merged 2 commits into
masterfrom
test/strong-migrations-preboot-coverage
Oct 29, 2026
Merged

mroderick merged 2 commits into
masterfrom
test/strong-migrations-preboot-coverage

Conversation

@mroderick

@mroderick mroderick commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to #3057's review, which found the new spec narrower than the invariants it claims. This PR widens the spec to match; no production code changes.

  • The "other checks unchanged" example now asserts the note's absence on every key outside the preboot list, not only :add_index.
  • The "exactly once" example also asserts that each message ends with the note and never starts with it. Note-last plus the single-occurrence count proves the gem text comes first for all nine keys, without hardcoding nine default wordings.
  • A new example reloads the initializer with :rename_column removed from error_messages and expects KeyError, covering the loud-failure design for a future gem version that drops a listed key.

Review notes

Small test-only diff, a skim is enough. The one pattern worth a look is the reload of config/initializers/strong_migrations.rb inside the spec: the value for the stub is captured before the stub installs, and the initializer re-runs harmlessly otherwise. Scope stays as #3057 decided: add_column_default and the other AGENTS.md-listed hazards are deliberately not on the note list.

Follow-up to #3057's review, which found the spec too narrow for the
invariants it claims:

- the "other checks unchanged" example sampled only :add_index; it now
  asserts the note's absence on every key outside the preboot list
- the "exactly once" example now also asserts the note is never the
  message prefix, which with the single-occurrence count proves the gem
  text comes first for all nine keys without hardcoding nine default
  wordings
- no test covered the loud-failure design: an example reloads the
  initializer with :rename_column removed from error_messages and
  expects KeyError, so a future gem dropping a listed key cannot fail
  silently

Mutation-checked: appending the note to every key fails the untouched-keys
example, and dropping the append fails the ordering and KeyError ones.
Review of this PR found the exactly-once example could go green while
the note came first: count == 1 plus not-start-with only rules out a
literal 'Heroku preboot' prefix, so any other prefix before the note
passes. Assert each message ends with the note; note-last plus the
count pins gem-text-first for all nine keys.

Also retitle the untouched-keys example to claim only what it asserts
(no preboot note added), and capture the stub value before the allow
call so the capture-before-stub order reads literally instead of
depending on argument evaluation order (two reviewers mis-read it).
@mroderick
mroderick marked this pull request as ready for review October 29, 2026 15:35
@mroderick
mroderick merged commit 7742a08 into master Oct 29, 2026
12 checks passed
@mroderick
mroderick deleted the test/strong-migrations-preboot-coverage branch October 29, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant