Skip to content
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

Minitest spec code lenses break when describe contains interpolation #1605

Open
Earlopain opened this issue Mar 13, 2024 · 2 comments · May be fixed by #1609
Open

Minitest spec code lenses break when describe contains interpolation #1605

Earlopain opened this issue Mar 13, 2024 · 2 comments · May be fixed by #1609
Labels
bug Something isn't working pinned This issue or pull request is pinned and won't be marked as stale

Comments

@Earlopain
Copy link
Contributor

Description

There's a bit more to this but overall this is the gist of it.

describe pushes to the group_id_stack. If a describe can't be handled a code lens will not be created, which in turn means that it inside of that describe block references a group that doesn't exist (that at least is my current understanding of why this happens).

You can reproduce this with the following snippet:

describe Foo do
  describe "string_#{interpolation}" do
    it "does_something"
  end

  it "it_level_one"
end

image
The green button is still there for some reason, but the other code lens that would in theory work does not get displayed.

The following should also not break, however I'm not sure how many codelenses it should actually display. One for describe Foo and the bottommost it for sure. Ideally for the describe with a normal string and its testcase as well but the first one might be simpler to implement as a first pass.

describe Foo do
  describe "string_#{interpolation}" do
    it "does_something"

    describe "normal_string" do
      it "does_something_else"
    end
  end

  it "it_level_one"
end
@Earlopain Earlopain added the bug Something isn't working label Mar 13, 2024
@vinistock vinistock added the pinned This issue or pull request is pinned and won't be marked as stale label Mar 13, 2024
@vinistock
Copy link
Member

Thank you for the bug report!

I think we might be able to fix this by using a more elaborate regex when interpolation is present. For example, if we have

describe "something #{var} other thing" do
end

We could push something <dynamic reference> other thing to the stack to ensure we maintain the structure properly. And for running it, we could turn the dynamic references into match all regexes, something like /something .* other thing/, which would I think is enough to match them.

@Earlopain
Copy link
Contributor Author

Oh, that's a great idea. I will implement this

@andyw8 andyw8 changed the title Minitest spec code lenses break when describe containts interpolation Minitest spec code lenses break when describe contains interpolation Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pinned This issue or pull request is pinned and won't be marked as stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants