test/convertor_test.rb in boogex-0.0.1 vs test/convertor_test.rb in boogex-0.1.0

- old
+ new

@@ -6,31 +6,33 @@ expecting = '(?:This|That)' result = Boogex.convert(string) assert_equal expecting, result end - it 'turns AND into andify array string' do + it 'turns boolean AND into AND array string' do string = 'This AND That' - expecting = '#{andify["(?:This)", "(?:That)"]}' + expecting = "AND(['(?:This)','(?:That)'])" result = Boogex.convert(string) assert_equal expecting, result end it 'understands bracketing' do string = '(This OR That) AND My self' - expecting = '#{andify["(?:This|That)", "(?:My self)"]}' + expecting = "AND(['(?:This|That)','(?:My self)'])" result = Boogex.convert(string) assert_equal expecting, result - - string = 'This AND (That OR (My self)' - expecting = '#{andify["(?:This|That)", "(?:My self)"]}' - result = Boogex.convert(string) - assert_equal expecting, result end it 'correctly convert this Lucene boolean query string' do string = '(((asd OR dd) AND that) AND this) OR What?' - expecting = '#{andify["#{andify["(?:asd|dd)", "(?:that)"]}", "(?:this)"]}|What?' + expecting = "AND([AND(['(?:asd|dd)','(?:that)']),'(?:this)'])|What?" + result = Boogex.convert(string) + assert_equal expecting, result + end + + it 'understands embedded AND' do + string = '((im AND researching) AND travelling)' + expecting = "AND([AND(['(?:im)','(?:researching)']),'(?:travelling)'])" result = Boogex.convert(string) assert_equal expecting, result end end