Repository navigation
Fix generator tests - #1054
Merged
Merged
Fix generator tests#1054
Conversation
Rails main compares database configs by value, so establish_connection
with an identical :memory: config reuses the existing pool, and closing
the connection only checks it back in. Tables created by one test leaked
into the next ("table flipper_features already exists"). Remove the
connection in teardown so each test gets a fresh database.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Otherwise $stdout stays a StringIO and every later generator test fails with "can't convert Tempfile into StringIO", burying the real failure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dpep
commented
Oct 3, 2026
|
|
||
| teardown do | ||
| ActiveRecord::Base.connection.close | ||
| ActiveRecord::Base.remove_connection |
Collaborator
Author
There was a problem hiding this comment.
Drop the pool, not just the connection: Rails reuses a pool for an identical config, which would keep this :memory: db alive across tests.
dpep
commented
Oct 3, 2026
| output.string | ||
| ensure | ||
| $stderr = original_stderr | ||
| $stdout = original_stdout |
Collaborator
Author
There was a problem hiding this comment.
Restore even on failure, or later tests inherit the StringIO
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the seed-dependent
rails maincanary failure intest_rails(example).Rails main compares database configs by value (
HashConfig#==), soestablish_connectionreuses the existing pool for the same:memory:config.UpdateGeneratorTest's teardown only checked the connection back in, so tables leaked between tests:table "flipper_features" already exists.ActiveRecord::Base.remove_connection, which drops the pool.silencerestores$stdoutin anensure. Without it, that one failure left$stdoutas aStringIO, and 9 later tests failed incapturewithcan't convert Tempfile into StringIO.