rails icon indicating copy to clipboard operation
rails copied to clipboard

Move `test:prepare` task to the main rails tasks from test_unit railtie

Open simmerz opened this issue 1 year ago • 3 comments

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.

simmerz avatar Jun 22 '22 19:06 simmerz

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.

rails-bot[bot] avatar Sep 20 '22 19:09 rails-bot[bot]

Is this something that can be looked at?

simmerz avatar Sep 20 '22 20:09 simmerz

Feel free to send a PR.

rafaelfranca avatar Sep 20 '22 21:09 rafaelfranca