RSpec support modules are not indexed
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 2k
- Forks
- 281
- Avg merge
- 2h 14m
- Merged PRs (30d)
- 6
Description
Description
Ruby LSP Information
VS Code Version
1.95.0
Ruby LSP Extension Version
0.8.12
Ruby LSP Server Version
0.21.3
Ruby LSP Addons
- Ruby LSP Rails
Ruby Version
3.1.6
Ruby Version Manager
rbenv
Installed Extensions
Click to expand
- gitlens (15.6.2)
- java (1.36.0)
- makefile-tools (0.11.13)
- remote-containers (0.388.0)
- ruby-extensions-pack (0.1.12)
- ruby-lsp (0.8.12)
- test-adapter-converter (0.2.1)
- vscode-docker (1.29.3)
- vscode-github-actions (0.27.0)
- vscode-gradle (3.16.4)
- vscode-java-debug (0.58.1)
- vscode-java-dependency (0.24.0)
- vscode-java-pack (0.29.0)
- vscode-maven (0.44.0)
- vscode-rdbg (0.2.2)
- vscode-ruby-test-adapter (0.9.2)
- vscode-test-explorer (2.22.1)
Ruby LSP Settings
Click to expand
Workspace
{}
User
{
"enableExperimentalFeatures": false,
"enabledFeatures": {
"codeActions": true,
"diagnostics": true,
"documentHighlights": true,
"documentLink": true,
"documentSymbols": true,
"foldingRanges": true,
"formatting": true,
"hover": true,
"inlayHint": true,
"onTypeFormatting": true,
"selectionRanges": true,
"semanticHighlighting": true,
"completion": true,
"codeLens": true,
"definition": true,
"workspaceSymbol": true,
"signatureHelp": true,
"typeHierarchy": true
},
"featuresConfiguration": {},
"addonSettings": {},
"rubyVersionManager": {
"identifier": "auto"
},
"customRubyCommand": "",
"formatter": "rubocop",
"linters": null,
"bundleGemfile": "",
"testTimeout": 30,
"branch": "",
"pullDiagnosticsOn": "both",
"useBundlerCompose": false,
"bypassTypechecker": false,
"rubyExecutablePath": "",
"indexing": {
"excludedPatterns": [
"node_modules/**/*",
"tmp/**/*",
"spec/**/*_spec.rb",
"db/**/*",
"factories/**/*",
"script/**/*"
]
},
"erbSupport": true,
"useLauncher": false
}
Reproduction steps
While it's possible to specify includePatterns and excludePatterns for rubyLsp.indexing, those values are concatenated to the default values for those settings. That makes it impossible to configure ruby-lsp to index RSpec support files.
For example, RSpec will add spec to $LOAD_PATH, so we can add some support file to spec/my_helper_module.rb, for example, and include that module in a context. Here's an example on how it works:
module LoggedInAsAdmin
extend RSpec::Core::SharedContext
before(:example) do
log_in_as :admin
end
end
describe "admin section" do
include LoggedInAsAdmin
# ...
end
In the example above, LoggedInAsAdmin is not going to be indexed, so we can't jump to its definition from VSCode.
Currently, it's not possible to override the exclusion pattern "spec/**/*" defined by default, from VSCode settings.
We should be allowed to override those exclusions in order to enable indexing of RSpec support files.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with lib/ruby_indexer/lib/ruby_indexer/configuration.rb at the default exclusion pattern referenced in the issue, then trace how rubyLsp.indexing includePatterns and excludePatterns are combined. Verify how VS Code settings are applied and make it possible to override the default spec/**/* exclusion so support files such as spec/my_helper_module.rb are indexed. Done means RSpec support module definitions can be indexed and navigated to from VS Code.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100