-
Notifications
You must be signed in to change notification settings - Fork 31
Add Rails test command resolution #596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Rails allows writing tests with the syntax `test "should do something"`, but internally converts these to standard Minitest method names `test_should_do_something`. This normalization ensures our test identifiers match what Rails uses at runtime, allowing proper test discovery and execution.
465c4a5
to
9d04fcb
Compare
)) | ||
end | ||
elsif tags.include?("test_file") | ||
full_files << path if children.empty? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens when the children is not empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We continue to concat the children into the queue. But if the children are empty, that indicates that we are trying to run that entire file and so we must append it to full_files
.
)) | ||
end | ||
elsif tags.include?("test_file") | ||
full_files << path if children.empty? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We continue to concat the children into the queue. But if the children are empty, that indicates that we are trying to run that entire file and so we must append it to full_files
.
Closes Shopify/ruby-lsp#3179, closes Shopify/ruby-lsp#3170
This PR builds on #591’s test discovery support by generating test commands for Rails tests discovered in VS Code’s Test Explorer.
Before
Tests defined via
test "…"
appeared in the explorer, but clicking Run did nothing as no command was emitted.After
Now clicking Run emits the exact
bin/rails test …
command Rails uses at runtime.Added command resolution for:
Dir.glob
on*_test.rb/test_*.rb
--name "/GroupTest(#|::)/"
file:line
entriesFor this to work, we normalize string-based test names (e.g.,
"should do something"
) by prefixingtest_
and replacing spaces with underscores (test_#{test_name.gsub(/\s+/, '_')}
), matching Rails' ownActiveSupport::Testing::Declarative#test
helper. This ensures our test IDs line up with the methods Rails actually runs (e.g.,test_should_do_something
).