@@ -97,6 +97,90 @@ def test_hello; end
9797 end
9898 end
9999
100+ def test_collects_code_lenses
101+ source = <<~RUBY
102+ module Foo
103+ class MyTest < Test::Unit::TestCase
104+ def test_something; end
105+
106+ def test_something_else; end
107+ end
108+ end
109+ RUBY
110+
111+ with_server ( source ) do |server , uri |
112+ server . global_state . index . index_single ( URI ( "/other_file.rb" ) , <<~RUBY )
113+ module Test
114+ module Unit
115+ class TestCase; end
116+ end
117+ end
118+ RUBY
119+
120+ server . global_state . stubs ( :enabled_feature? ) . returns ( true )
121+
122+ server . process_message ( id : 1 , method : "textDocument/codeLens" , params : {
123+ textDocument : { uri : uri } ,
124+ } )
125+
126+ # Discard the indexing log message
127+ server . pop_response
128+ items = get_response ( server )
129+ assert_equal ( 9 , items . length )
130+
131+ # MyTest
132+ assert_equal ( "▶ Run" , items [ 0 ] . command . title )
133+ assert_equal (
134+ { start : { line : 1 , character : 2 } , end : { line : 1 , character : 3 } } ,
135+ JSON . parse ( items [ 0 ] . range . to_json , symbolize_names : true ) ,
136+ )
137+ assert_equal ( "▶ Run in terminal" , items [ 1 ] . command . title )
138+ assert_equal (
139+ { start : { line : 1 , character : 2 } , end : { line : 1 , character : 3 } } ,
140+ JSON . parse ( items [ 1 ] . range . to_json , symbolize_names : true ) ,
141+ )
142+ assert_equal ( "⚙ Debug" , items [ 2 ] . command . title )
143+ assert_equal (
144+ { start : { line : 1 , character : 2 } , end : { line : 1 , character : 3 } } ,
145+ JSON . parse ( items [ 2 ] . range . to_json , symbolize_names : true ) ,
146+ )
147+
148+ # test_something
149+ assert_equal ( "▶ Run" , items [ 3 ] . command . title )
150+ assert_equal (
151+ { start : { line : 2 , character : 4 } , end : { line : 2 , character : 5 } } ,
152+ JSON . parse ( items [ 3 ] . range . to_json , symbolize_names : true ) ,
153+ )
154+ assert_equal ( "▶ Run in terminal" , items [ 4 ] . command . title )
155+ assert_equal (
156+ { start : { line : 2 , character : 4 } , end : { line : 2 , character : 5 } } ,
157+ JSON . parse ( items [ 4 ] . range . to_json , symbolize_names : true ) ,
158+ )
159+ assert_equal ( "⚙ Debug" , items [ 5 ] . command . title )
160+ assert_equal (
161+ { start : { line : 2 , character : 4 } , end : { line : 2 , character : 5 } } ,
162+ JSON . parse ( items [ 5 ] . range . to_json , symbolize_names : true ) ,
163+ )
164+
165+ # test_something_else
166+ assert_equal ( "▶ Run" , items [ 6 ] . command . title )
167+ assert_equal (
168+ { start : { line : 4 , character : 4 } , end : { line : 4 , character : 5 } } ,
169+ JSON . parse ( items [ 6 ] . range . to_json , symbolize_names : true ) ,
170+ )
171+ assert_equal ( "▶ Run in terminal" , items [ 7 ] . command . title )
172+ assert_equal (
173+ { start : { line : 4 , character : 4 } , end : { line : 4 , character : 5 } } ,
174+ JSON . parse ( items [ 7 ] . range . to_json , symbolize_names : true ) ,
175+ )
176+ assert_equal ( "⚙ Debug" , items [ 8 ] . command . title )
177+ assert_equal (
178+ { start : { line : 4 , character : 4 } , end : { line : 4 , character : 5 } } ,
179+ JSON . parse ( items [ 8 ] . range . to_json , symbolize_names : true ) ,
180+ )
181+ end
182+ end
183+
100184 def test_ignores_minitest_tests_that_extend_active_support_declarative
101185 source = <<~RUBY
102186 class MyTest < ActiveSupport::TestCase
0 commit comments