Sha256: e7374639f54e33c357da9fabbe86b7db86e6b83ba4489cde6a4c49f8b4f7d3cf

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
boogex-0.1.0 test/convertor_test.rb