@@ -26,8 +26,8 @@ class SampleTest < ActiveSupport::TestCase
2626 assert_equal ( 2 , test_class [ :children ] . length )
2727
2828 test_labels = test_class [ :children ] . map { |i | i [ :label ] }
29- assert_includes ( test_labels , "first test " )
30- assert_includes ( test_labels , "second test " )
29+ assert_includes ( test_labels , "test_first_test " )
30+ assert_includes ( test_labels , "test_second_test " )
3131 assert_all_items_tagged_with ( items , :rails )
3232 end
3333 end
@@ -52,7 +52,7 @@ class EmptyTest < ActiveSupport::TestCase
5252 assert_equal ( 2 , test_class [ :children ] . length )
5353
5454 test_labels = test_class [ :children ] . map { |i | i [ :label ] }
55- assert_includes ( test_labels , "<empty test name >" )
55+ assert_includes ( test_labels , "test_<empty_test_name >" )
5656 assert_all_items_tagged_with ( items , :rails )
5757 end
5858 end
@@ -110,11 +110,11 @@ def test_second_test
110110 test "handles tests with special characters in name" do
111111 source = <<~RUBY
112112 class SpecialCharsTest < ActiveSupport::TestCase
113- test "test with spaces and punctuation!" do
113+ test "spaces and punctuation!" do
114114 assert true
115115 end
116116
117- test "test with unicode: 你好" do
117+ test "unicode: 你好" do
118118 assert true
119119 end
120120 end
@@ -127,12 +127,107 @@ class SpecialCharsTest < ActiveSupport::TestCase
127127 assert_equal ( 2 , test_class [ :children ] . length )
128128
129129 test_labels = test_class [ :children ] . map { |i | i [ :label ] }
130- assert_includes ( test_labels , "test with spaces and punctuation !" )
131- assert_includes ( test_labels , "test with unicode: 你好 " )
130+ assert_includes ( test_labels , "test_spaces_and_punctuation !" )
131+ assert_includes ( test_labels , "test_unicode:_你好 " )
132132 assert_all_items_tagged_with ( items , :rails )
133133 end
134134 end
135135
136+ test "resolve test command entire files" do
137+ base_dir = Gem . win_platform? ? "D:/other/test" : "/other/test"
138+ test_paths = [
139+ File . join ( base_dir , "fake_test.rb" ) ,
140+ File . join ( base_dir , "fake_test2.rb" ) ,
141+ ]
142+ Dir . stubs ( :glob ) . returns ( test_paths )
143+
144+ with_server do |server |
145+ sleep ( 0.1 ) while RubyLsp ::Addon . addons . first . instance_variable_get ( :@rails_runner_client ) . is_a? ( NullClient )
146+
147+ server . process_message ( {
148+ id : 1 ,
149+ method : "rubyLsp/resolveTestCommands" ,
150+ params : {
151+ items : [
152+ {
153+ id : "file:///test/server_test.rb" ,
154+ uri : "file:///test/server_test.rb" ,
155+ label : "/test/server_test.rb" ,
156+ tags : [ "test_file" , "framework:rails" ] ,
157+ children : [ ] ,
158+ } ,
159+ {
160+ id : "file:///other/test" ,
161+ uri : "file:///other/test" ,
162+ label : "/other/test" ,
163+ tags : [ "test_dir" , "framework:rails" ] ,
164+ children : [ ] ,
165+ } ,
166+ ] ,
167+ } ,
168+ } )
169+
170+ result = pop_result ( server )
171+ response = result . response
172+
173+ assert_equal (
174+ [
175+ "#{ RailsTestStyle ::BASE_COMMAND } /test/server_test.rb #{ test_paths . join ( " " ) } " ,
176+ ] ,
177+ response [ :commands ] ,
178+ )
179+ end
180+ end
181+
182+ test "resolve test command group test" do
183+ with_server do |server |
184+ sleep ( 0.1 ) while RubyLsp ::Addon . addons . first . instance_variable_get ( :@rails_runner_client ) . is_a? ( NullClient )
185+
186+ server . process_message ( {
187+ id : 1 ,
188+ method : "rubyLsp/resolveTestCommands" ,
189+ params : {
190+ items : [
191+ {
192+ id : "GroupTest" ,
193+ uri : "file:///test/group_test.rb" ,
194+ label : "GroupTest" ,
195+ range : {
196+ start : { line : 0 , character : 0 } ,
197+ end : { line : 30 , character : 3 } ,
198+ } ,
199+ tags : [ "framework:rails" , "test_group" ] ,
200+ children : [
201+ {
202+ id : "GroupTest#test_example" ,
203+ uri : "file:///test/group_test.rb" ,
204+ label : "test_example" ,
205+ range : {
206+ start : { line : 1 , character : 2 } ,
207+ end : { line : 10 , character : 3 } ,
208+ } ,
209+ tags : [ "framework:rails" ] ,
210+ children : [ ] ,
211+ } ,
212+ ] ,
213+ } ,
214+ ] ,
215+ } ,
216+ } )
217+
218+ result = pop_result ( server )
219+ response = result . response
220+
221+ assert_equal (
222+ [
223+ "#{ RailsTestStyle ::BASE_COMMAND } /test/group_test.rb --name \" /GroupTest(#|::)/\" " ,
224+ "#{ RailsTestStyle ::BASE_COMMAND } /test/group_test.rb:2" ,
225+ ] ,
226+ response [ :commands ] ,
227+ )
228+ end
229+ end
230+
136231 private
137232
138233 def with_active_support_declarative_tests ( source , file : "/fake.rb" , &block )
0 commit comments