Don't delete /tmp
before generator tests
#1744
Merged
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.
I think I finally discovered why the directory
/tmp
was being deleted, a behaviour that has been confusing us lately. (See #1731, #1726, #1695).The issue appears to be with the generator specs. These load this configuration when they run:
administrate/spec/support/generator_spec_helpers.rb
Lines 54 to 61 in 520a544
In this code,
destination
andprepare_destination
are helpers provided by Rails to assist when testing generators. See https://api.rubyonrails.org/v3.2.2/classes/Rails/Generators/TestCase.htmlTurns out that
prepare_destination
prepares the destination by... rimraffing it. See: https://github.com/rails/rails/blob/557014d45aeed82ed1e79b83ab59697392a1a5de/railties/lib/rails/generators/test_case.rb#L235So if we set
/tmp
as destination, it will be destroyed ahead of each generator spec example.To fix this, I'm telling it to use a specific subdirectory that can be deleted at will, avoiding further harm.