Sha256: 1bc43694f17cd5c54889f8a2b352cd9c8c01a7e2830100c91faa1db9ab641291

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

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

  it 'understands double embedded AND' do
    string = 'Peeps OR ((dude OR roos) AND (what OR Footy))'
    expecting = "Peeps|AND(['(?:dude|roos)','(?:what|Footy)'])"
    result = Boogex.convert(string)
    assert_equal expecting, result
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
boogex-0.1.1 test/convertor_test.rb