You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue is hurting my brain a little, but I'll try and explain it. It's a regression introduced by rails#44290, in the following conditions:
- You use `minitest/spec` (either direction or via a wrapper like [`minitest-spec-rails`](https://github.com/metaskills/minitest-spec-rails))
- You run tests using a regex filter to identify which tests to run (either directly or via a wrapper like [`m`](https://github.com/qrush/m))
Since rails#44290 you could not execute a test that has a space in its name using the regex filter method. This is because:
- https://github.com/rails/rails/blob/444df0eee1b537ecaa11509e819b071d4e87b519/activesupport/lib/active_support/testing/declarative.rb#L6 doesn't define the `test` method if `Spec` is defined. Recall that the `test` method does 2 things: it defines the test, but it also replaces spaces with underscores in the test method name.
- In minitest specs, you use `it` to define tests. `it` [generates a test method name](https://github.com/minitest/minitest/blob/a9fa045044b4210cfd21a512b06d1a4527d709ba/lib/minitest/spec.rb#L223..L229) by taking user input and prepending `test_` and a number. It does *not* replace spaces with underscores. So the test method is defined as `"test_002_foo bar"`.
- Since rails#44290 when you provide the test runner a filter it replaces spaces with underscores before passing the filter onto minitest. For example, the filter might become `"/test_002_foo_bar/"`.
- Minitest thus can't find the test method and doesn't run it.
The issue is in `escape_declarative_test_filter`. Rather than converting spaces to underscores, it should match both spaces *and* underscores. This covers all use cases.
Co-authored-by: jonathanhefner <[email protected]>
0 commit comments