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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8507f756d0b208adca8b52c8d852897a5d641eafc10e4f426d52a1f996e77be4
4
- data.tar.gz: 2ce268a5a67e65f5dedb35ef95e4a0f5007c3fa87e0a39c774214e88fc2d9910
3
+ metadata.gz: f4b10df0b5e20922d4a1fea43701d1d852e1b7cd7c12301d63052fbd0ddd261c
4
+ data.tar.gz: b3771e57c473df35dc734f48852800d75a337b2e75ab5f2d0341db6902851749
5
5
  SHA512:
6
- metadata.gz: 6f3b09e7a7d238b18adddbd2d76cce47d2b4d0c97064ad3ea4344a1c6344a0a7eb81eee4dbe7d6378e83b2c1c694c78acd2ecea3e904798e5865b54f730dabcb
7
- data.tar.gz: 3caae73f44f1d790c0336369ae3ac28f00ad2dc9cf742b254c57b3ece19842fdb5b696ceed6916cf7b7eb453a0a05e217ff29d774d410cd0e89fcf7b268d7c43
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?
@@ -3,6 +3,6 @@
3
3
 
4
4
  module RubyLsp
5
5
  module ShouldaContext
6
- VERSION = "0.3.2"
6
+ VERSION = "0.3.3"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lsp-shoulda-context
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Domingo Edwards