Sha256: d4cb8cfc3db8df8f1b339e1c0df6711f090324d368437bf24b1dfeb43581ae8d

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 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 AND into andify array string' do
    string = 'This AND That'
    expecting = '#{andify["(?: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)"]}'
    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?'
    result = Boogex.convert(string)
    assert_equal expecting, result
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
boogex-0.0.1 test/convertor_test.rb