Repository navigation
Key the dummy app on every input that builds it - #18
Merged
Merged
Conversation
Three ways the harness hid failures instead of reporting them. The generated app was keyed on the Rails version alone, but active_admin:install runs inside it, so Active Admin is an input too. `AA=3.2.0 bundle exec rspec` silently reused the app built for 3.5 and reported on a build it never produced -- including the invocation the README documents. CI never saw it because runners start empty. The reuse check was `unless File.exist?(RAILS_ROOT)`, but rails new creates that directory before the template runs, so a template that failed halfway left it behind and every later run skipped regeneration and died on config/environment.rb instead of showing the real error. system's exit status was discarded as well, in both the spec helper and the rake task. Check for config/environment.rb, clear the directory first, and abort on failure. spec_helper also did `ENV['RAILS'] = Rails.version`, overwriting the variable the Gemfile reads. CI sets 7.1.0, the Gemfile resolves 7.1.6, and the rake setup child then evaluated `~> 7.1.6` against a lockfile recording `~> 7.1.0` -- Bundler re-resolves and rewrites the lock as a side effect of running tests. The only consumer was the path on the next line, which now comes from TestAppPaths. Naming follows active_admin_import, which already keys its apps this way.
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.
Three defects in how the dummy app is built and reused. All three hide failures rather than cause them, which is why none showed up as a red leg.
The cache key ignored the Active Admin version
The app was generated into
spec/rails/rails-<rails version>and reused whenever that directory existed. Butactive_admin:installandformtastic:installrun inside that app, so the Active Admin version is an input to what gets generated.So the README's own documented invocation was a lie:
The leg reported on an app it never built. CI never noticed because runners start empty, so every cell generated its own.
Now keyed on both:
rails-7.1.6-aa3.2.0. Verified by switchingAAbetween runs and watching it regenerate.A half-built app was cached forever
Two problems in one line.
rails newcreates the target directory before the template runs, so any template failure leaves the directory in place — and every later run then skips regeneration and dies onconfig/environment.rbwith aLoadErrorthat points nowhere near the actual cause. Andsystem's return value was discarded, so a failed build proceeded as if it had worked.This is not hypothetical: a stale half-built app was sitting in this working tree when the harness was first written, and it took a while to work out why.
Now it checks for
config/environment.rb— the file the suite actually loads — clears the directory first, and aborts if the build fails.tasks/test.rakelikewise aborts rather than ignoringrails new's exit status, and prints the versions it is building for.spec_helper overwrote the variable the Gemfile reads
CI sets
RAILS=7.1.0; the Gemfile asks for~> 7.1.0and resolves 7.1.6. This line then rewroteENV['RAILS']to7.1.6, and therake setupchild inherited it — so the child's Gemfile said~> 7.1.6while the lockfile recorded~> 7.1.0. Bundler sees a changed dependency and re-resolves, rewriting the lockfile as a side effect of running tests. UnderBUNDLE_FROZENit would abort outright.The round-trip bought nothing — the only consumer was the path on the next line. Gone; the path now comes from
TestAppPaths, shared by the spec helper and the rake task.The naming approach is lifted from
active_admin_import, which already keys its dummy apps this way.19 examples, 0 failures, before and after.