Skip to content

Conversation

@nathanscottdaniels
Copy link
Contributor

The problem

If you have a spec with a let variable named one of the "reserved" words such as context or describe this gem interprets any usage of those variables as test group. This breaks the VS Code integration since these aren't actually test groups and tests don't actually exist within them.

context is a pretty common and innocuous variable name so this causes a very large number of our specs to not work with this spec.

To repro

Use this spec

RSpec.describe("Context bug") do
  let(:context) { "foo" }

  before do
    context
  end

  it("bar") { expect(true) }
end

Observe broken awareness of the spec, lack of code lens support, and incorrect labeling of the context variable as a spec.
image

The cause

There is a validation to see if a node is actually a test group, but it passes too easily. It's treated as a node group even if there is no block associated with it. In addition, there was no validation performed in test_discovery,

The fix

Actually ensure the node has a block before allowing it to be treated as a test group.

Behold

image

@nathanscottdaniels nathanscottdaniels marked this pull request as ready for review July 29, 2025 01:31
@nathanscottdaniels
Copy link
Contributor Author

@st0012 anybody home? 👀

@st0012
Copy link
Owner

st0012 commented Sep 8, 2025

Can you add some regression tests covering these cases?

@st0012 st0012 added the bug Something isn't working label Sep 8, 2025
@nathanscottdaniels
Copy link
Contributor Author

Can you add some regression tests covering these cases?

Done! 🫡

Copy link
Owner

@st0012 st0012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@st0012 st0012 merged commit 4acddc0 into st0012:main Sep 13, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants