@@ -80,28 +80,52 @@ def test_exact_method_match
8080    assert_equal  'RDoc::Markup::AttributeManager' ,  strip_highlights ( results [ 0 ] [ 'namespace' ] ) 
8181  end 
8282
83-   def  test_exact_class_beats_exact_method 
83+   def  test_capitalized_query_prioritizes_exact_class 
8484    results  =  run_search ( 
85-       query : 'attribute ' , 
85+       query : 'String ' , 
8686      data : { 
87-         searchIndex : [ 'attribute() ' ,  'attribute ' ] , 
88-         longSearchIndex : [ 'rdoc::markup#attribute() ' ,  'attribute ' ] , 
87+         searchIndex : [ 'string ' ,  'string() ' ] , 
88+         longSearchIndex : [ 'string ' ,  'object#string() ' ] , 
8989        info : [ 
90-           [ 'attribute ' ,  'RDoc::Markup ' ,  'RDoc/Markup .html#method-i-attribute ' ,  '() ' ,  'Attribute method ' ,  '' ,  'method ' ] , 
91-           [ 'Attribute ' ,  '' ,  'Attribute .html' ,  '' ,  'Attribute class (hypothetical) ' ,  '' ,  'class ' ] 
90+           [ 'String ' ,  '' ,  'String .html' ,  '' ,  'String class ' ,  '' ,  'class ' ] , 
91+           [ 'string ' ,  'Object ' ,  'Object .html#method-i-string ' ,  '() ' ,  'String method ' ,  '' ,  'method ' ] 
9292        ] 
9393      } 
9494    ) 
9595
9696    assert_equal  2 ,  results . length 
97-     # Exact class match  (Pass 0) should beat  exact method match  (Pass 1) 
98-     assert_equal  'Attribute ' ,  strip_highlights ( results [ 0 ] [ 'title' ] ) 
97+     # Capitalized query: exact class  (Pass 0) beats  exact method (Pass 1) 
98+     assert_equal  'String ' ,  strip_highlights ( results [ 0 ] [ 'title' ] ) 
9999    assert_equal  '' ,  results [ 0 ] [ 'namespace' ] 
100-     assert_equal  'Attribute .html' ,  results [ 0 ] [ 'path' ] 
100+     assert_equal  'String .html' ,  results [ 0 ] [ 'path' ] 
101101
102102    # Method comes second 
103-     assert_equal  'attribute' ,  strip_highlights ( results [ 1 ] [ 'title' ] ) 
104-     assert_equal  'RDoc::Markup' ,  strip_highlights ( results [ 1 ] [ 'namespace' ] ) 
103+     assert_equal  'string' ,  strip_highlights ( results [ 1 ] [ 'title' ] ) 
104+     assert_equal  'Object' ,  strip_highlights ( results [ 1 ] [ 'namespace' ] ) 
105+   end 
106+ 
107+   def  test_lowercase_query_prioritizes_method 
108+     results  =  run_search ( 
109+       query : 'options' , 
110+       data : { 
111+         searchIndex : [ 'options' ,  'options()' ] , 
112+         longSearchIndex : [ 'rdoc::options' ,  'rdoc::codeobject#options()' ] , 
113+         info : [ 
114+           [ 'Options' ,  'RDoc' ,  'RDoc/Options.html' ,  '' ,  'Options class' ,  '' ,  'class' ] , 
115+           [ 'options' ,  'RDoc::CodeObject' ,  'RDoc/CodeObject.html#method-i-options' ,  '()' ,  'Options method' ,  '' ,  'method' ] 
116+         ] 
117+       } 
118+     ) 
119+ 
120+     assert_equal  2 ,  results . length 
121+     # Lowercase query should prioritize method over class 
122+     assert_equal  'options' ,  strip_highlights ( results [ 0 ] [ 'title' ] ) 
123+     assert_equal  'RDoc::CodeObject' ,  strip_highlights ( results [ 0 ] [ 'namespace' ] ) 
124+     assert_equal  'RDoc/CodeObject.html#method-i-options' ,  results [ 0 ] [ 'path' ] 
125+ 
126+     # Class comes second 
127+     assert_equal  'Options' ,  strip_highlights ( results [ 1 ] [ 'title' ] ) 
128+     assert_equal  'RDoc' ,  strip_highlights ( results [ 1 ] [ 'namespace' ] ) 
105129  end 
106130
107131  def  test_beginning_match 
0 commit comments