ruby-net-ldap/spec/unit/ldap/filter_spec.rb
Kaspar Schiess a3824392bf + Adds a specification for the new ldap extensible filter
I am not sure about this, since I haven't been able to find
documentation about what this does. This should work, though.

Cleanup of comments and exceptions, adds specification for
Filter.ex and a parser method.
2010-03-22 15:17:26 +01:00

48 lines
1.5 KiB
Ruby

require 'spec_helper'
describe Net::LDAP::Filter do
describe "<- .ex(attr, value)" do
context "('foo', 'bar')" do
attr_reader :filter
before(:each) do
@filter = Net::LDAP::Filter.ex('foo', 'bar')
end
it "should convert to 'foo:=bar'" do
filter.to_s.should == '(foo:=bar)'
end
it "should survive roundtrip via to_s/from_rfc2254" do
Net::LDAP::Filter.from_rfc2254(filter.to_s).should == filter
end
it "should survive roundtrip conversion to/from ber" do
ber = filter.to_ber
Net::LDAP::Filter.parse_ber(ber.read_ber(Net::LDAP::AsnSyntax)).should ==
filter
end
end
context "various legal inputs" do
[
'(o:dn:=Ace Industry)',
'(:dn:2.4.8.10:=Dino)',
'(cn:dn:1.2.3.4.5:=John Smith)',
'(sn:dn:2.4.6.8.10:=Barbara Jones)',
].each do |filter_str|
context "from_rfc2254(#{filter_str.inspect})" do
attr_reader :filter
before(:each) do
@filter = Net::LDAP::Filter.from_rfc2254(filter_str)
end
it "should decode into a Net::LDAP::Filter" do
filter.should be_an_instance_of(Net::LDAP::Filter)
end
it "should survive roundtrip conversion to/from ber" do
ber = filter.to_ber
Net::LDAP::Filter.parse_ber(ber.read_ber(Net::LDAP::AsnSyntax)).should ==
filter
end
end
end
end
end
end