rails
rails copied to clipboard
Move `test:prepare` task to the main rails tasks from test_unit railtie
Presently, test:prepare
is only defined in the test_unit railtie rake task as a placeholder to be hooked on to.
The tailwindcss-rails
, cssbundling-rails
and jsbundling-rails
all enhance the task to allow tests to pre-compile to app/assets/build
.
However, for those of us using RSpec, there is no way without additional configuration to pre-compile those assets (we don't want to run assets:precompile
either because that's utterly confusing for the developer when changes made to app/assets/* subsequently don't appear to work).
Because the Rakefile in a Rails app loads all the application rake tasks by default, then those from gems and then those in lib/tasks last of all, not including test_unit means there's no sensible way to ensure that a placeholder task exists before tailwindcss-rails etc enhance it, short of specifically putting the gems higher in the gemfile - that's not clear to the developer, and doesn't follow the convention that Rails should be easy to work with.
rspec-rails
already invokes test:prepare
if it is defined, so it seems to me to make a great deal of sense to move this placeholder into the main rails tasks and then document it as a placeholder to be enhanced by other tasks.
If you're amenable to that, I'd be happy to raise a PR for it.
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails team are limited, and so we are asking for your help.
If you can still reproduce this error on the 7-0-stable
branch or on main
, please reply with all of the information you have about it in order to keep the issue open.
Thank you for all your contributions.
Is this something that can be looked at?
Feel free to send a PR.