ruby-lsp-shoulda-context 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Readme.md +1 -0
- data/lib/ruby_lsp/ruby-lsp-shoulda-context/code_lens.rb +14 -4
- data/lib/ruby_lsp/shoulda_context/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4b10df0b5e20922d4a1fea43701d1d852e1b7cd7c12301d63052fbd0ddd261c
|
4
|
+
data.tar.gz: b3771e57c473df35dc734f48852800d75a337b2e75ab5f2d0341db6902851749
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0aff200cb4d3e4e66af8f63b90ae3ad49aacebc1ceb47f3c1a546aa715a63fb2fd7effe1313183147ad8e55fdddb81d6ab758edf3a085d74ba3c7e4399743481
|
7
|
+
data.tar.gz: ac3e55b5c6c23f934450c3a3f567b4e5a53eedac8508ee37cb163de856484988a9cfd5adc42471cc873278a58ee30e5e5ba63853bc31730554c72e8eb2ac581c
|
data/Readme.md
CHANGED
@@ -44,5 +44,6 @@ Everyone interacting in the RubyLsp::ShouldaContext project's codebases, issue t
|
|
44
44
|
- [ ] Make exec method conditional to rails or Minitest setup
|
45
45
|
- [x] Make inner context or inner should with collissions with outer DSL not collide using full name of the test (Currently if 2 tests have the same name both are executed)
|
46
46
|
- [x] Provide grouping with classes that ends with "..Test" syntax (Note: The codelens is duplicated becuase lsp support minitest by default and LSP responses are merged)
|
47
|
+
- [ ] Provide support for Inner Classes
|
47
48
|
|
48
49
|
**Note**: This project is in very early stage and could have major bugs
|
@@ -31,6 +31,7 @@ module RubyLsp
|
|
31
31
|
@_response = T.let([], ResponseType)
|
32
32
|
# Listener is only initialized if uri.to_standardized_path is valid
|
33
33
|
@path = T.let(T.must(uri.to_standardized_path), String)
|
34
|
+
@class_name = T.let("", String)
|
34
35
|
@group_id = T.let(1, Integer)
|
35
36
|
@group_id_stack = T.let([], T::Array[Integer])
|
36
37
|
@pattern = T.let("test_: ", String)
|
@@ -46,6 +47,12 @@ module RubyLsp
|
|
46
47
|
case node.message
|
47
48
|
when "should"
|
48
49
|
name = generate_name(node)
|
50
|
+
|
51
|
+
# If is top level should without context the DSL is different
|
52
|
+
if @group_id_stack.length == 1
|
53
|
+
@pattern += "#{@class_name} "
|
54
|
+
end
|
55
|
+
|
49
56
|
@pattern += "should #{name} "
|
50
57
|
add_test_code_lens(node, name: name, kind: :example)
|
51
58
|
when "context"
|
@@ -65,7 +72,13 @@ module RubyLsp
|
|
65
72
|
case node.message
|
66
73
|
when "should"
|
67
74
|
name = generate_name(node)
|
75
|
+
|
68
76
|
@pattern = remove_last_pattern_in_string(@pattern, "should #{name} ")
|
77
|
+
|
78
|
+
# If is top level should without context the DSL is different
|
79
|
+
if @group_id_stack.length == 1
|
80
|
+
@pattern = remove_last_pattern_in_string(@pattern, "#{@class_name} ")
|
81
|
+
end
|
69
82
|
when "context"
|
70
83
|
return unless valid_group?(node)
|
71
84
|
|
@@ -78,6 +91,7 @@ module RubyLsp
|
|
78
91
|
sig { params(node: Prism::ClassNode).void }
|
79
92
|
def on_class_node_enter(node)
|
80
93
|
class_name = node.constant_path.slice
|
94
|
+
@class_name = remove_last_pattern_in_string(class_name, "Test")
|
81
95
|
|
82
96
|
if @path && class_name.end_with?("Test")
|
83
97
|
add_test_code_lens(
|
@@ -102,10 +116,6 @@ module RubyLsp
|
|
102
116
|
string.sub(/#{pattern}$/, "")
|
103
117
|
end
|
104
118
|
|
105
|
-
def pattern_only_has_test?(pattern)
|
106
|
-
pattern == "test_: "
|
107
|
-
end
|
108
|
-
|
109
119
|
sig { params(node: Prism::CallNode).returns(T::Boolean) }
|
110
120
|
def valid_group?(node)
|
111
121
|
!node.block.nil?
|