Skip to content

Don't push group id to stack when encountering non-test classes #324

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

Merged
merged 1 commit into from
Apr 5, 2024

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Apr 5, 2024

Some tests use classes instead of modules for namespacing, such us:

module Foo
  class Bar
    class MyTest < ActiveSupport::TestCase
      test "something" do
      end
    end
  end
end

And when this happens, the current implementation would still push the group id to the stack, which would cause the first test group (MyTest) to already have non-nil group id. This will make the extension to think there's another parent test group, which is not the case and will cause no code lens to be shown.

This commit fixes this by not pushing the group id to the stack when encountering non-test classes, and only pop the group id when the encountered class is a test class.

Some tests use classes instead of modules for namespacing, such us:

```ruby
module Foo
  class Bar
    class MyTest < ActiveSupport::TestCase
      test "something" do
      end
    end
  end
end
```

And when this happens, the current implementation would still push the
group id to the stack, which would cause the first test group (`MyTest`)
to already have non-nil group id. This will make the extension to think
there's another parent test group, which is not the case and will cause
no code lens to be shown.

This commit fixes this by not pushing the group id to the stack when
encountering non-test classes, and only pop the group id when the
encountered class is a test class.
@st0012 st0012 added the bugfix This PR fixes an existing bug label Apr 5, 2024
@st0012 st0012 requested a review from a team as a code owner April 5, 2024 15:28
@st0012 st0012 requested review from andyw8 and KaanOzkan April 5, 2024 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This PR fixes an existing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants