Sha256: 94299fe344e80143b2f639cf7651059ed1ef9ae3eb29e645323d381932a1115e

Contents?: true

Size: 924 Bytes

Versions: 1

Compression:

Stored size: 924 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe LdapQuery::Filter do
  describe 'should return filter string' do
    it { expect(described_class.cn('fooBar').to_s).to eq('(cn=fooBar)') }
    it { expect(described_class.person('fooBar').to_s).to eq('(&(cn=fooBar)(objectClass=person))') }
    it { expect{ described_class.person }.to raise_error(ArgumentError) }

    it { expect(described_class.other('someAttr', 'fooBar').to_s).to eq('(someAttr=fooBar)')}
  end


  describe 'clean_str' do
    it { expect(described_class.cn('    bob jones').to_s).to eq('(cn=bob jones)') }
    it { expect(described_class.cn('    bob jones', wildcard: true).to_s).to eq('(cn=*bob*jones*)') }

    # using custome attr && value
    it { expect(described_class.other(:attr, 'misc').to_s).to eq('(attr=misc)') }
    it { expect(described_class.other(:attr, 'misc', wildcard: true).to_s).to eq('(attr=*misc*)') }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ldap_query-0.0.1 spec/ldap_lookup/filter_spec.rb