ruby-lsp: Incorrect ancestor linearization for re-opens that omit the parent class

Description

Ruby LSP Information

VS Code Version

1.100.2

Ruby LSP Extension Version

0.9.25

Ruby LSP Server Version

0.23.21

Ruby LSP Add-ons

  • Standard Ruby
  • Ruby LSP Rails
  • RuboCop

Ruby Version

3.4.4

Ruby Version Manager

asdf

Installed Extensions

Click to expand
  • codesnap (1.3.4)
  • copilot (1.322.0)
  • copilot-chat (0.27.1)
  • explorer (1.18.1)
  • gitlens (17.1.0)
  • indent-rainbow (8.3.1)
  • prettier-vscode (11.0.0)
  • ruby-lsp (0.9.25)
  • vscode-eslint (3.0.10)
  • vscode-github-actions (0.27.1)
  • vscode-pull-request-github (0.110.0)
  • vscode-xml (0.29.0)
  • vscode-yaml (1.18.0)

Ruby LSP Settings

Click to expand
Workspace
{
  "formatter": "rubocop",
  "linters": [
    "rubocop"
  ]
}
User
{
  "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": "asdf"
  },
  "customRubyCommand": "",
  "formatter": "rubocop",
  "linters": [
    "rubocop"
  ],
  "bundleGemfile": "",
  "testTimeout": 30,
  "branch": "",
  "pullDiagnosticsOn": "both",
  "useBundlerCompose": false,
  "bypassTypechecker": false,
  "rubyExecutablePath": "",
  "indexing": {},
  "erbSupport": true,
  "featureFlags": {
    "all": true
  },
  "sigOpacityLevel": "1"
}

Reproduction steps

  1. Start VS Code, updated to the 0.9.25 extension
  2. Open a test file inheriting from ActionDispatch::IntegrationTest
  3. No Run | Run in terminal | Debug available
  4. In Testing tab all ruby tests are listed as @hidden
  • If I downgrade to 0.9.24 it is the same thing, but on 0.9.23 it works again.
  • It works if I open a test that inherits from ActiveSupport::TestCase or ApplicationSystemTestCase

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 18 (5 by maintainers)

Most upvoted comments

❯ BUNDLE_GEMFILE=.ruby-lsp/Gemfile bundle exec ruby script.rb
ActionDispatch::IntegrationTest
ActionDispatch::IntegrationTest::Behavior
ActionDispatch::Assertions::RoutingAssertions::WithIntegrationRouting
ActionDispatch::IntegrationTest::UrlOptions
ActionDispatch::Routing::UrlFor
ActionDispatch::Routing::PolymorphicRoutes
ActionDispatch::TestHelpers::PageDumpHelper
ActionController::TemplateAssertions
ActionDispatch::Integration::Runner
ActionDispatch::Assertions
Rails::Dom::Testing::Assertions
Rails::Dom::Testing::Assertions::SelectorAssertions
Rails::Dom::Testing::Assertions::DomAssertions
ActionDispatch::Assertions::RoutingAssertions
ActionDispatch::Assertions::ResponseAssertions
ActionDispatch::TestProcess::FixtureFile
Devise::Test::IntegrationHelpers
Object
Kernel
BasicObject

but lenses do not appear on integration tests in test/controllers/something_test.rb having class SomethingTest < ActionDispatch::IntegrationTest.

The test explorer does not have any test listed under the correspondent test file - still having the test file in list.

Nothing I’d consider to report from the output panel.

Ruby LSP Information

VS Code Version

1.100.2

Ruby LSP Extension Version

0.9.26

Ruby LSP Server Version

0.23.23

Ruby LSP Add-ons

  • Standard Ruby
  • Ruby LSP Rails
  • RuboCop

Ruby Version

3.3.7

Ruby Version Manager

rbenv

Installed Extensions

Click to expand
  • MetaJump (1.4.4)
  • MetaWord (1.3.2)
  • ascii-unicode-escape (0.1.0)
  • bash-debug (0.3.9)
  • code-spell-checker (4.0.47)
  • code-spell-checker-italian (1.1.3)
  • copilot (1.323.0)
  • copilot-chat (0.27.2)
  • crystal-lang (0.9.7)
  • docker (0.7.0)
  • dotenv (1.0.1)
  • esbonio (0.11.0)
  • expand-selection-to-scope (0.2.0)
  • git-graph (1.30.0)
  • git-project-manager (1.8.2)
  • gitlab-workflow (6.18.1)
  • gitlens (17.1.1)
  • gitlink (1.2.4)
  • hadolint (1.1.2)
  • indent-rainbow (8.3.1)
  • javascript-ejs-support (1.3.3)
  • jupyter (2025.4.1)
  • jupyter-keymap (1.1.2)
  • jupyter-renderers (1.1.0)
  • l13-diff (1.3.9)
  • markdown-all-in-one (3.6.3)
  • mermaid-markdown-syntax-highlighting (1.7.1)
  • metago (4.3.3)
  • php-docblocker (2.7.0)
  • php-pack (1.0.3)
  • rainbow-csv (3.19.0)
  • remote-containers (0.413.0)
  • remote-explorer (0.5.0)
  • remote-ssh (0.120.0)
  • remote-ssh-edit (0.87.0)
  • ruby-extensions-pack (0.1.13)
  • ruby-lsp (0.9.26)
  • shellcheck (0.37.7)
  • simple-rst (1.5.4)
  • theme-monokai-pro-vscode (2.0.6)
  • vscode-containers (2.0.1)
  • vscode-fileutils (3.10.3)
  • vscode-github-actions (0.27.1)
  • vscode-icons (12.13.0)
  • vscode-language-pack-it (1.100.2025051409)
  • vscode-mermaid-editor (0.19.1)
  • vscode-pull-request-github (0.110.0)
  • vscode-rdbg (0.2.2)
  • vscode-speech (0.14.0)
  • vscode-speech-language-pack-it-it (0.5.0)
  • vscode-standard (2.1.3)
  • vscode-svgviewer (2.0.0)
  • vscode-yaml (1.18.0)
  • vsliveshare (1.0.5948)
  • vsliveshare-pack (0.4.0)

Ruby LSP Settings

Click to expand
Workspace
{
  "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,
    "references": true
  },
  "formatter": "standard",
  "linters": [
    "standard"
  ],
  "featureFlags": {
    "all": true,
    "fullTestDiscovery": true
  }
}
User
{
  "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,
    "references": true
  },
  "featuresConfiguration": {},
  "addonSettings": {},
  "rubyVersionManager": {
    "identifier": "rbenv"
  },
  "customRubyCommand": "",
  "formatter": "standard",
  "linters": [
    "standard"
  ],
  "bundleGemfile": "",
  "testTimeout": 30,
  "branch": "",
  "pullDiagnosticsOn": "both",
  "useBundlerCompose": false,
  "bypassTypechecker": false,
  "rubyExecutablePath": "",
  "indexing": {},
  "erbSupport": true,
  "featureFlags": {
    "all": true,
    "fullTestDiscovery": true
  },
  "sigOpacityLevel": "1"
}

In order to keep working w/ same setup I’ve set

  "rubyLsp.featureFlags": {
    "fullTestDiscovery": false,
  },

and it’s working the way was working before.

Worth noticing that re-opening rails classes that way is 100% documentation-driven: https://guides.rubyonrails.org/testing.html#test-helpers

Glad it helped and happy to see the patch in the wild. Thanks for your work and support.

Thanks for the information, it was really helpful. This is actually not directly related to our new explorer implementation, but instead a bug in linearization that will be fixed by https://github.com/Shopify/ruby-lsp/pull/3572.

In order to keep working w/ same setup I’ve set

  "rubyLsp.featureFlags": {
    "fullTestDiscovery": false,
  },

and it’s working the way was working before.

This also worked in my case too at restoring the code lens

I added the script to the debug repo: https://github.com/davidwessman/debug_ruby_lsp/commit/6e59fb4bab59e6ef6ab967650b9a2ebe9a51fb57

I added some filtering and when I run it I do not get any files that end in _test.rb in the indexable_uris.

If I downgrade I still do not get those files indexed, but the test discovery still works.