Skip to content

test: abort with a clear message when built assets are missing - #7204

Open
costajohnt wants to merge 1 commit into
rubyforgood:mainfrom
costajohnt:fix/document-css-build-for-specs
Open

costajohnt wants to merge 1 commit into
rubyforgood:mainfrom
costajohnt:fix/document-css-build-for-specs

Conversation

@costajohnt

Copy link
Copy Markdown
Contributor

What github issue is this PR for, if any?

Resolves #7100

What changed, and why?

On a fresh checkout, app/assets/builds/ is empty (it is gitignored and only populated by npm run build and npm run build:css). manifest.js links that directory, and link_directory only declares files that exist, so a layout that links tailwind.css raises AssetNotPrecompiledError with advice to edit the manifest, which is already correct. A missing application.js fails with "not present in the asset pipeline".

  • spec/rails_helper.rb: abort at boot when any of the three bundles the layouts link (application.js, all_casa_admin.js, tailwind.css) is missing, naming the commands that build them. Sits next to the existing pending-migration abort and follows the same pattern.
  • README.md: note under Running Tests that bin/rails spec builds the bundles first (it runs spec:prepare, which jsbundling/cssbundling hook into), while a bare bundle exec rspec does not.

Two things from the issue that did not hold up:

  • chore: disable on-demand asset compilation and normalize Gemfile.lock platforms (#7040) #7071 only changed config/environments/production.rb; the test environment still has config.assets.compile = true. The cause is the missing build output, not on-demand compilation being off.
  • npm run build:css works from a clean npm ci here (arm64 macOS, Node 24.18, npm 11): @tailwindcss/cli and the tailwindcss bin are installed and the CSS is written. So I left package.json alone.

bin/setup already runs both builds since #7051, so that part of the issue was done.

How is this tested? (please write rspec and jest tests!) 💖💪

No spec: the guard runs while rails_helper loads and aborts the process, and the repo has no precedent for subprocess specs. Checked by hand:

  • bundle exec rspec spec/requests/case_court_reports_spec.rb:14:28:37 with the bundles built: 3 examples, 0 failures.
  • With app/assets/builds/tailwind.css removed, bundle exec rspec spec/requests/case_court_reports_spec.rb:14 exits 1 and prints Missing built assets: tailwind.css. Run \npm run build` and `npm run build:css`, or use `bin/rails spec`, which builds them.` before anything else.
  • With tailwind.css removed, bin/rails spec SPEC=... rebuilds it and passes, which is why the README wording distinguishes the two.
  • bundle exec standardrb spec/rails_helper.rb clean.

CI runs rails assets:precompile before rspec, so the guard cannot fire there.

Screenshots please :)

Terminal output with tailwind.css removed:

$ bundle exec rspec spec/requests/case_court_reports_spec.rb:14
Missing built assets: tailwind.css. Run `npm run build` and `npm run build:css`, or use `bin/rails spec`, which builds them.

@github-actions github-actions Bot added the ruby Touches Ruby code label Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ruby Touches Ruby code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Specs rendering the casa_app layout fail locally: tailwind.css was not declared to be precompiled

1 participant