-
Notifications
You must be signed in to change notification settings - Fork 172
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
CodeLens support for minitest spec-style tests #1265
CodeLens support for minitest spec-style tests #1265
Conversation
438e6f1
to
0a4c9d1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good so far! Most of the team is off until early January, so there may a little delay before we can follow up.
lib/ruby_lsp/requests/code_lens.rb
Outdated
@@ -47,6 +47,8 @@ class CodeLens < ExtensibleListener | |||
) | |||
ACCESS_MODIFIERS = T.let([:public, :private, :protected], T::Array[Symbol]) | |||
SUPPORTED_TEST_LIBRARIES = T.let(["minitest", "test-unit"], T::Array[String]) | |||
DESCRIBE_KEYWORD = T.let(:describe, Symbol) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will need some more discussion, but we may want to start splitting up code_lens.rb
into some separate responsibilities.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, this could be cleaner as file tends to increase and manage multiple scenarios. Let me know if there is a decision about it after team holidays 🎄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine to keep as is for this PR at least. We talked about the possibility of moving the Gemfile code lenses into hover instead, which might be better than splitting code lens and would go well with #1279.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is acted, feel free to assign me, I like the idea, even more since feedback about too much noise in the Gemfile. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey! I owed you the issue I mentioned. Here it is in case you're interested in tackling it #1339.
b0769d9
to
ab49cec
Compare
Looks great! I tried testing it on https://github.com/Shopify/tapioca by adding |
Hi @andyw8, this is a good catch. Quite hard to use both VS Code extensions and ruby-lsp server in debug mode with a third repository. 😁 There are actually two issues with
I hope this message is as clear as this is in my mind 😄 |
ab49cec
to
1882b59
Compare
This makes sense and it's a weakness of our current approach. If Ideally, when we keep track of inheritance, we can check if the test inherits from
Does Minitest allow you to run a test class like the ones used in Tapioca? If so, I think both the |
Giving this kind of code (without rails dependency and the fix in extension): require "minitest/autorun"
class Foo
end
class FooSpec < Minitest::Spec
describe Foo do
it "test_one" do; end
end
end You'll be able to run it with minitest, each level. But commands generated are:
The class level will run nothing, as this |
The section of the Minitest readme dealing with |
Looking at minitest's spec tests and ruby/spec, one of the biggest user of this pattern, I kinda feel Tapioca uses it in an unconventional way. So it may not be the best test subject for this feature. |
I'm experimenting with Tapioca to see what's involved in switching over, it doesn't seem there's much. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do need to accomodate the mixed syntax, that can be separate, so let's go ahead with this.
I don't think this is accurate, since the documentation of
|
Motivation
Closes: #820
Add test code lenses to files wrote in minitest spec-style.
Implementation
Following what is already done by previous implementation:
describe
&it
keyword and get name and command testgroup_id
fordescribe
onon_call_node_enter
group_id
fordescribe
onon_call_node_leave
Automated Tests
I've added fixture & expectation file as other code lens cases.
Manual Tests
test/fixtures/minitest_spec_tests.rb
screenshots