diff --git a/README.md b/README.md index eedce41dcf..8d7bce3153 100644 --- a/README.md +++ b/README.md @@ -246,7 +246,7 @@ new tab in the browser. To see local email previews, check out http://localhost:3000/rails/mailers ### Running Tests - - run the ruby test suite `bin/rails spec` + - run the ruby test suite `bin/rails spec`. It builds the JS and CSS bundles first; a bare `bundle exec rspec` does not, so run `npm run build` and `npm run build:css` (or `bin/setup`) once before using it - run the javascript test suite `npm run test` If you have trouble running tests, check out CI scripts in [`.github/workflows/`](.github/workflows/) for sample commands. diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 005c9d840d..67ed69e0a9 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -42,6 +42,15 @@ abort e.to_s.strip end +# app/assets/builds/ is gitignored and only populated by `npm run build` and +# `npm run build:css`. Until then any layout that links those bundles fails, +# and for tailwind.css with a misleading AssetNotPrecompiledError that points +# at manifest.js. Fail early with the real fix instead. +missing_assets = %w[application.js all_casa_admin.js tailwind.css].reject { |asset| Rails.root.join("app/assets/builds", asset).exist? } +if missing_assets.any? + abort "Missing built assets: #{missing_assets.join(", ")}. Run `npm run build` and `npm run build:css`, or use `bin/rails spec`, which builds them." +end + ci_environment = (ENV["GITHUB_ACTIONS"] || ENV["CI"]).present? RSpec.configure do |config|