@@ -359,43 +359,6 @@ def test_something; end
359359 end
360360 end
361361
362- def test_files_are_indexed_lazily_if_needed
363- path = File . join ( Dir . pwd , "lib" , "foo.rb" )
364- File . write ( path , <<~RUBY )
365- class FooTest < Test::Unit::TestCase
366- def test_something; end
367- end
368- RUBY
369-
370- begin
371- with_server do |server , uri |
372- server . global_state . index . index_single ( uri , <<~RUBY )
373- module Test
374- module Unit
375- class TestCase; end
376- end
377- end
378- RUBY
379-
380- server . process_message (
381- id : 1 ,
382- method : "rubyLsp/discoverTests" ,
383- params : { textDocument : { uri : URI ::Generic . from_path ( path : path ) } } ,
384- )
385-
386- items = get_response ( server )
387- assert_equal (
388- [ "FooTest" ] ,
389- items . map { |i | i [ :label ] } ,
390- )
391- assert_equal ( [ "test_something" ] , items [ 0 ] [ :children ] . map { |i | i [ :label ] } )
392- assert_all_items_tagged_with ( items , :test_unit )
393- end
394- ensure
395- FileUtils . rm ( path )
396- end
397- end
398-
399362 def test_does_not_raise_on_duplicate_test_ids
400363 source = <<~RUBY
401364 module Foo
@@ -898,13 +861,15 @@ def assert_all_items_tagged_with(items, tag)
898861 end
899862
900863 def with_minitest_test ( source , &block )
901- with_server ( source ) do |server , uri |
902- server . global_state . index . index_single ( uri , <<~RUBY )
903- module Minitest
904- class Test; end
905- end
906- RUBY
864+ source_with_minitest = <<~RUBY
865+ #{ source }
907866
867+ module Minitest
868+ class Test; end
869+ end
870+ RUBY
871+
872+ with_server ( source_with_minitest ) do |server , uri |
908873 server . process_message ( id : 1 , method : "rubyLsp/discoverTests" , params : {
909874 textDocument : { uri : uri } ,
910875 } )
@@ -916,15 +881,17 @@ class Test; end
916881 end
917882
918883 def with_test_unit ( source , &block )
919- with_server ( source ) do | server , uri |
920- server . global_state . index . index_single ( uri , <<~RUBY )
921- module Test
922- module Unit
923- class TestCase; end
924- end
884+ source_with_test_unit = <<~RUBY
885+ #{ source }
886+
887+ module Test
888+ module Unit
889+ class TestCase; end
925890 end
926- RUBY
891+ end
892+ RUBY
927893
894+ with_server ( source_with_test_unit ) do |server , uri |
928895 server . process_message ( id : 1 , method : "rubyLsp/discoverTests" , params : {
929896 textDocument : { uri : uri } ,
930897 } )
@@ -936,24 +903,26 @@ class TestCase; end
936903 end
937904
938905 def with_active_support_declarative_tests ( source , &block )
939- with_server ( source ) do |server , uri |
940- server . global_state . index . index_single ( uri , <<~RUBY )
941- module Minitest
942- class Test; end
943- end
906+ source_with_test_case = <<~RUBY
907+ #{ source }
944908
945- module ActiveSupport
946- module Testing
947- module Declarative
948- end
949- end
909+ module Minitest
910+ class Test; end
911+ end
950912
951- class TestCase < Minitest::Test
952- extend Testing::Declarative
913+ module ActiveSupport
914+ module Testing
915+ module Declarative
953916 end
954917 end
955- RUBY
956918
919+ class TestCase < Minitest::Test
920+ extend Testing::Declarative
921+ end
922+ end
923+ RUBY
924+
925+ with_server ( source_with_test_case ) do |server , uri |
957926 server . process_message ( id : 1 , method : "rubyLsp/discoverTests" , params : {
958927 textDocument : { uri : uri } ,
959928 } )
@@ -965,14 +934,16 @@ class TestCase < Minitest::Test
965934 end
966935
967936 def with_minitest_spec_configured ( source , &block )
968- with_server ( source ) do |server , uri |
969- server . global_state . index . index_single ( uri , <<~RUBY )
970- module Minitest
971- class Test; end
972- class Spec < Test; end
973- end
974- RUBY
937+ source_with_spec = <<~RUBY
938+ #{ source }
939+
940+ module Minitest
941+ class Test; end
942+ class Spec < Test; end
943+ end
944+ RUBY
975945
946+ with_server ( source_with_spec ) do |server , uri |
976947 server . process_message ( id : 1 , method : "rubyLsp/discoverTests" , params : {
977948 textDocument : { uri : uri } ,
978949 } )
0 commit comments