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.
Motivation / Background
This Pull Request has been created because we're using Packwerk for our Rails app. We'd like to have tests for code in a package be defined in the directory for that package, e.g.
packages/a/test
. However, there is not a trivial way to make Rails's standardtest
/test:all
etc. commands also run these tests. Our current solution is a custom rake file that redefines the tasks to include the packages' tests, but ideally this would be supported by Rails itself.Detail
This Pull Request changes
Rails::TestUnit::Runner
to support specifying default test paths usingRails::Paths::Path
. This mirrors howRails::Engine
andRails::Application
can be configured to use different paths from the standard. It also loadsconfig/tests.rb
if present, otherwise there is not a good place to configure the paths.For the example above, the
config/tests.rb
would contain something like:Additional information
This is my first time contributing to Rails, so I suspect this pattern does not fully follow Rails conventions, however I have at least checked that it works. I have not tested it with a project that uses
rspec
as I am unfamiliar with it.I would say the most questionable parts are:
Rails::TestUnit::Runner
the right class for this configuration?Rails::Paths::Path
the best solution for specifying these paths?config/tests.rb
be introduced or is there a better way to run code before tests that I am unaware of?Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
main
(if not - rebase it).(I have not investigated how to test this and do not wish to spend too much time on it before I know the final implementation and whether this feature is wanted)