Skip to content

Commit 42add5f

Browse files
committed
Implement '==' operator for entries
1 parent d60bb76 commit 42add5f

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/net/ldap/entry.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,8 @@ def setter?(sym)
196196
sym.to_s[-1] == ?=
197197
end
198198
private :setter?
199+
200+
def ==(other)
201+
return self['dn'] == other['dn']
202+
end
199203
end # class Entry

test/test_entry.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ def test_to_h
5454
duplicate.delete(:sn)
5555
assert_not_equal duplicate, @entry.to_h
5656
end
57+
58+
def test_equal_operator
59+
@entry_two = Net::LDAP::Entry.new 'cn=Barbara,o=corp'
60+
assert_equal @entry, @entry_two
61+
62+
@entry_three = Net::LDAP::Entry.new 'cn=Bob,o=corp'
63+
assert_not_equal @entry, @entry_three
64+
end
5765
end
5866

5967
class TestEntryLDIF < Test::Unit::TestCase

0 commit comments

Comments
 (0)