-
Notifications
You must be signed in to change notification settings - Fork 210
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 rspec
for Docker Integration Platformdocker-compose exec app rspec
for Docker Compose setupsbin/rspec
for 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
testCommand
to the Ruby LSP's configuration options, accessible through VS Code settings or initialization options. -
GlobalState Enhancement: Extend the
GlobalState
class to store and manage the custom test command configuration. -
CodeLens Modification: Update the
BASE_COMMAND
logic inlib/ruby_lsp/listeners/code_lens.rb
to use the configured command instead of the hardcodedbundle exec ruby
orruby
. -
Command Generation: Modify the
generate_test_command
method 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.