Repository navigation
Description
I have checked that this feature is not already implemented:
- This feature does not exist
Use case:
Many development teams use containerized environments or custom test runners for their Ruby projects. Currently, Ruby LSP's CodeLens feature hardcodes the test command to bundle exec ruby or ruby.
For example, projects using:
dip rspecfor Docker Integration Platformdocker-compose exec app rspecfor Docker Compose setupsbin/rspecfor custom binstubs- Other containerized test runners
These teams cannot benefit from the CodeLens test execution feature.
Description:
I propose adding a configuration option that allows users to customize the test command prefix used by CodeLens when executing tests. This would enable the Ruby LSP to generate appropriate test commands for any development environment.
The feature should allow users to specify their preferred test runner command through VS Code settings or Ruby LSP initialization options. When a user clicks on a CodeLens test button, the Ruby LSP would use the custom command instead of the default bundle exec ruby.
For example, if a user configures "rubyLsp.testCommand": "dip rspec", clicking on a test's CodeLens should execute dip rspec /path/to/spec_file.rb --name "TestName" instead of the current bundle exec ruby -Ispec /path/to/spec_file.rb --name "TestName".
Implementation:
The implementation could involve:
-
Configuration Option: Add a new setting like
testCommandto the Ruby LSP's configuration options, accessible through VS Code settings or initialization options. -
GlobalState Enhancement: Extend the
GlobalStateclass to store and manage the custom test command configuration. -
CodeLens Modification: Update the
BASE_COMMANDlogic inlib/ruby_lsp/listeners/code_lens.rbto use the configured command instead of the hardcodedbundle exec rubyorruby. -
Command Generation: Modify the
generate_test_commandmethod to properly construct commands using the custom prefix while maintaining compatibility with different test frameworks (minitest, test-unit, rspec). -
Framework Detection: Ensure the custom command works with the existing test library detection logic, possibly adjusting the command structure based on the detected framework.
The change should be backward compatible, defaulting to the current behavior when no custom command is specified.
Activity
Splines commentedon Jun 15, 2025
Related: #2965. Also note that the Ruby LSP addon
ruby-lsp-rspecprovides anrspecCommandoption, e.g.:{ "rubyLsp.addonSettings": { "Ruby LSP RSpec": { "rspecCommand": "rspec -f d" } } }For Docker users, see this PR: #2919 and this gist.
github-actions commentedon Aug 15, 2025
This issue is being marked as stale because there was no activity in the last 2 months
vinistock commentedon Sep 5, 2025
Container related discussions were happening in a few different places, so I created #3738 to try to centralize and move the discussion forward.