Skip to content

Gem rspec-expectations incorrectly detected as rspec for testing framework #3110

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

Closed
nhumble-sa opened this issue Jan 29, 2025 · 1 comment
Closed
Labels
bug Something isn't working vscode This pull request should be included in the VS Code extension's release notes

Comments

@nhumble-sa
Copy link
Contributor

nhumble-sa commented Jan 29, 2025

Description

Ruby LSP Information

VS Code Version

1.96.4

Ruby LSP Extension Version

0.8.19

Ruby LSP Server Version

0.23.7

Ruby LSP Add-ons

  • Ruby LSP Rails

Ruby Version

3.3.6

Ruby Version Manager

asdf

Installed Extensions

Click to expand
  • EditorConfig (0.16.4)
  • asdf (1.1.26)
  • bash-debug (0.3.9)
  • better-comments (3.0.2)
  • code-spell-checker (4.0.34)
  • color-highlight (2.8.0)
  • color-info (0.7.2)
  • copilot (1.260.0)
  • copilot-chat (0.23.2)
  • debugpy (2024.14.0)
  • dotenv (1.0.1)
  • ecdc (1.8.0)
  • even-better-toml (0.21.2)
  • gc-excelviewer (4.2.62)
  • github-vscode-theme (6.3.5)
  • gitignore (0.9.0)
  • gitlens (16.2.1)
  • html-preview-vscode (0.2.5)
  • indent-rainbow (8.3.1)
  • inline-sql-syntax (2.16.0)
  • isort (2023.10.1)
  • markdown-all-in-one (3.6.2)
  • markdown-mermaid (1.27.0)
  • opensslutils (1.1.1)
  • prettier-vscode (11.0.0)
  • python (2024.22.2)
  • rails (0.22.0)
  • rails-routes (0.6.3)
  • rainbow-csv (3.15.1)
  • redis-for-vscode (1.2.0)
  • remote-containers (0.394.0)
  • ruby-lsp (0.8.19)
  • spectral (1.1.4)
  • sqltools (0.28.3)
  • sqltools-driver-pg (0.5.4)
  • steep-vscode (0.10.0)
  • syntax-highlighter (0.5.0)
  • test-adapter-converter (0.2.1)
  • vscode-axe-linter (4.10.3)
  • vscode-better-align (1.4.2)
  • vscode-commons (0.0.6)
  • vscode-docker (1.29.4)
  • vscode-edit-csv (0.11.2)
  • vscode-eslint (3.0.10)
  • vscode-github-actions (0.27.0)
  • vscode-html-css (2.0.13)
  • vscode-icons (12.11.0)
  • vscode-markdownlint (0.58.2)
  • vscode-openapi (4.31.0)
  • vscode-pull-request-github (0.102.0)
  • vscode-pylance (2024.12.1)
  • vscode-svgviewer (2.0.0)
  • vscode-test-explorer (2.22.1)
  • vscode-toggle-quotes (0.3.6)
  • vscode-versionlens (1.16.2)
  • vscode-yaml (1.15.0)

Ruby LSP Settings

Click to expand
Workspace
{
  "indexing": {
    "excludedPatterns": [
      "**/test/**/*.rb"
    ],
    "includedPatterns": [
      "**/bin/**/*"
    ],
    "excludedGems": [
      "rubocop",
      "rubocop-capybara",
      "rubocop-factory_bot",
      "rubocop-performance",
      "rubocop-rails"
    ],
    "excludedMagicComments": [
      "compiled: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,
    "all": true
  },
  "featuresConfiguration": {},
  "addonSettings": {},
  "rubyVersionManager": {
    "identifier": "auto"
  },
  "customRubyCommand": "",
  "formatter": "auto",
  "linters": null,
  "bundleGemfile": "",
  "testTimeout": 30,
  "branch": "",
  "pullDiagnosticsOn": "both",
  "useBundlerCompose": false,
  "bypassTypechecker": false,
  "rubyExecutablePath": "",
  "indexing": {
    "excludedPatterns": [
      "**/test/**/*.rb"
    ],
    "includedPatterns": [
      "**/bin/**/*"
    ],
    "excludedGems": [
      "rubocop",
      "rubocop-capybara",
      "rubocop-factory_bot",
      "rubocop-performance",
      "rubocop-rails"
    ],
    "excludedMagicComments": [
      "compiled:true"
    ]
  },
  "erbSupport": true,
  "featureFlags": {
    "all": true
  }
}

Reproduction steps

If you have any direct gem dependencies that start with rspec it will detect that you're using rspec as the testing framework. This is a false-positive as we use that gem to have rspec-like tests with minitest. Ideally it should look for the rails script first and use that for testing. That is more likely to work with a wider range of test frameworks if the project is a rails one. Failing that, it would be nice to be able to manually set the testing framework in the project's settings to skip the auto-detection.

  1. Load a ruby project in VSCode
  2. Open a Ruby file
  3. See the detected test library (example below)

Output from Ruby LSP

2025-01-29 14:09:21.932 [info] (arculix-core) Detected test library: rspec
@nhumble-sa nhumble-sa added bug Something isn't working vscode This pull request should be included in the VS Code extension's release notes labels Jan 29, 2025
@vinistock
Copy link
Member

Thank you for the bug report. The best solution is to use our ancestor linearization logic to detect to which framework the current test belongs to, which is described in #1334. Trying to detect based on dependencies or project structure is prone to false positives/negatives.

I'll close this issue to centralize all discussions in #1334.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working vscode This pull request should be included in the VS Code extension's release notes
Projects
None yet
Development

No branches or pull requests

2 participants