@@ -420,7 +420,6 @@ module Foo
420420 end
421421
422422 def test_completion_private_constants_inside_the_same_namespace
423- skip ( "Visibility handling not yet implemented in Rubydex" )
424423 source = +<<~RUBY
425424 class A
426425 CONST = 1
@@ -438,13 +437,12 @@ class A
438437 } )
439438
440439 result = server . pop_response . response
441- assert_equal ( [ "CONST" ] , result . map { |completion | completion . text_edit . new_text } )
440+ assert_includes ( result . map { |completion | completion . text_edit . new_text } , "CONST" )
442441 end
443442 end
444443 end
445444
446445 def test_completion_private_constants_from_different_namespace
447- skip ( "Visibility handling not yet implemented in Rubydex" )
448446 source = +<<~RUBY
449447 class A
450448 CONST = 1
@@ -1815,11 +1813,75 @@ def test_guessed_type_name_is_only_included_for_guessed_types
18151813 end
18161814
18171815 def test_completion_for_private_methods
1818- skip ( "Visibility handling not yet implemented in Rubydex" )
1816+ source = +<<~RUBY
1817+ class Foo
1818+ def bar
1819+ b
1820+ end
1821+
1822+ private
1823+
1824+ def baz
1825+ end
1826+ end
1827+
1828+ foo = Foo.new
1829+ foo.b
1830+ RUBY
1831+
1832+ with_server ( source ) do |server , uri |
1833+ server . process_message ( id : 1 , method : "textDocument/completion" , params : {
1834+ textDocument : { uri : uri } ,
1835+ position : { line : 2 , character : 5 } ,
1836+ } )
1837+
1838+ result = server . pop_response . response
1839+ assert_includes ( result . map ( &:label ) , "baz" )
1840+
1841+ server . process_message ( id : 1 , method : "textDocument/completion" , params : {
1842+ textDocument : { uri : uri } ,
1843+ position : { line : 12 , character : 5 } ,
1844+ } )
1845+
1846+ result = server . pop_response . response
1847+ refute_includes ( result . map ( &:label ) , "baz" )
1848+ end
18191849 end
18201850
18211851 def test_completion_for_protected_methods
1822- skip ( "Visibility handling not yet implemented in Rubydex" )
1852+ source = +<<~RUBY
1853+ class Foo
1854+ def bar
1855+ b
1856+ end
1857+
1858+ protected
1859+
1860+ def baz
1861+ end
1862+ end
1863+
1864+ foo = Foo.new
1865+ foo.b
1866+ RUBY
1867+
1868+ with_server ( source ) do |server , uri |
1869+ server . process_message ( id : 1 , method : "textDocument/completion" , params : {
1870+ textDocument : { uri : uri } ,
1871+ position : { line : 2 , character : 5 } ,
1872+ } )
1873+
1874+ result = server . pop_response . response
1875+ assert_includes ( result . map ( &:label ) , "baz" )
1876+
1877+ server . process_message ( id : 1 , method : "textDocument/completion" , params : {
1878+ textDocument : { uri : uri } ,
1879+ position : { line : 12 , character : 5 } ,
1880+ } )
1881+
1882+ result = server . pop_response . response
1883+ refute_includes ( result . map ( &:label ) , "baz" )
1884+ end
18231885 end
18241886
18251887 def test_require_relative_returns_empty_result_for_unsaved_files
0 commit comments