Skip to content

Fix SpecStyle to not receive Prism events #71

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

elmuerte
Copy link

Calling super will still register for events. The parent class TestDiscovery also registers SpecStyle for Prism event. While handling the events it tries to access a nil variable when entering a class or module and thus completely break code analysis of normal ruby files.

The parent class TestDiscovery also registers SpecStyle for Prism event. While handling the events it tries to access a nil variable when entering a class or module and thus completely break code analysis of normal ruby files.
@st0012 st0012 added the bug Something isn't working label May 31, 2025
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.

Good catch! Is it possible to also add a regression test for it?

@elmuerte
Copy link
Author

elmuerte commented Jun 2, 2025

I added a test case to verify that the patch effectively disables initialization of the SpecStyle

@st0012
Copy link
Owner

st0012 commented Jun 3, 2025

Sorry, I mean is it possible to add an integration test like other specs in this project that can reproduce the issue? Or a test setup that can reproduce the error you mentioned would help too.

@elmuerte
Copy link
Author

elmuerte commented Jun 4, 2025

That would effectively be feeding the ruby-lsp (with the patched SpecStyle) a ruby source file which contains a module and class block. Without the fixed code it should fail, with the fixed code it would pass.
I'll see what I can do.

The improperly patched SpecStyle would fail when the Ruby LSP was
handling a 'textDocument/foldingRange' message (probably others too)
for a source while with module and class blocks as it was still
receiving events from Prism (which we do not want) for the RSpec
addon.
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