@@ -138,8 +138,14 @@ def on_class_node_enter(node)
138138 class_name = node . constant_path . slice
139139 superclass_name = node . superclass &.slice
140140
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+
141146 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 ) } (#|::)/\" "
143149 add_test_code_lens ( node , name : class_name , command : command , kind : :group )
144150 @group_id_stack . push ( @group_id )
145151 @group_id += 1
@@ -149,11 +155,6 @@ def on_class_node_enter(node)
149155 command = "#{ migrate_command } VERSION=#{ migration_version } "
150156 add_migrate_code_lens ( node , name : class_name , command : command )
151157 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 ]
157158 end
158159
159160 sig { params ( node : Prism ::ClassNode ) . void }
0 commit comments