require "#{File.dirname(__FILE__)}/test_helper" describe Boogex do it 'turns OR into |' do string = 'This OR That' expecting = '(?:This|That)' result = Boogex.convert(string) assert_equal expecting, result end it 'turns boolean AND into AND array string' do string = 'This AND 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 = "AND(['(?: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 = "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