rspec navigatable it_behaves_like/shared_examples使用lsp
我有一个旧版项目,该项目使用共享_examples的特征很大,在实际规格和共享_examples实现之间导航非常不便。
目前,唯一的方法是使用“某个示例”名称在项目中全球搜索。
RSpec.shared_examples "some example" do |parameter|
let(:something) { parameter }
it "uses the given parameter" do
expect(something).to eq(parameter)
end
end
RSpec.describe SomeClass do
# "some example" has to become *something*
# I can click and navigate to(jump-to-definition)
include_examples "some example", "parameter1"
end
我想将LSP/SolarGraph用于此类导航。
也许有人以前这样做,愿意分享他们的做法?
I have a legacy project that uses shared_examples feature a lot and it is very inconvenient to navigate between actual specs and shared_examples implementation.
For now, the only way to do it is to search globally within a project using "some example" example name.
RSpec.shared_examples "some example" do |parameter|
let(:something) { parameter }
it "uses the given parameter" do
expect(something).to eq(parameter)
end
end
RSpec.describe SomeClass do
# "some example" has to become *something*
# I can click and navigate to(jump-to-definition)
include_examples "some example", "parameter1"
end
I would like to use LSP/Solargraph for this kind of navigation.
Perhaps anyone did this before and willing to share how they did it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,这比我预期的要简单。
只需将您的示例名称作为字符串常数提取,然后将其放在
rspec.shared_examples
实现旁边的某个地方即可。提示:如果它对您不起作用,请检查
.solargraph.yml
config,将“ spec/**/*”
排除在默认情况下。This turned out simpler than I expected.
Just extract your example name as a string constant and put it somewhere next to
RSpec.shared_examples
implementation.HINT: In case it doesn't work for you, check
.solargraph.yml
config which excludes"spec/**/*"
from indexing by default.