@@ -138,8 +138,14 @@ def on_class_node_enter(node)
138
138
class_name = node . constant_path . slice
139
139
superclass_name = node . superclass &.slice
140
140
141
+ # We need to use a stack because someone could define a nested class
142
+ # inside a controller. When we exit that nested class declaration, we are
143
+ # back in a controller context. This part is used in other places in the LSP
144
+ @constant_name_stack << [ class_name , superclass_name ]
145
+
141
146
if class_name . end_with? ( "Test" )
142
- command = "#{ test_command } #{ @path } "
147
+ fully_qualified_name = @constant_name_stack . map ( &:first ) . join ( "::" )
148
+ command = "#{ test_command } #{ @path } --name \" /#{ Shellwords . escape ( fully_qualified_name ) } (#|::)/\" "
143
149
add_test_code_lens ( node , name : class_name , command : command , kind : :group )
144
150
@group_id_stack . push ( @group_id )
145
151
@group_id += 1
@@ -149,11 +155,6 @@ def on_class_node_enter(node)
149
155
command = "#{ migrate_command } VERSION=#{ migration_version } "
150
156
add_migrate_code_lens ( node , name : class_name , command : command )
151
157
end
152
-
153
- # We need to use a stack because someone could define a nested class
154
- # inside a controller. When we exit that nested class declaration, we are
155
- # back in a controller context. This part is used in other places in the LSP
156
- @constant_name_stack << [ class_name , superclass_name ]
157
158
end
158
159
159
160
sig { params ( node : Prism ::ClassNode ) . void }
0 commit comments