Skip to content

Implement '==' operator for entries #381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/net/ldap/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,8 @@ def setter?(sym)
sym.to_s[-1] == ?=
end
private :setter?

def ==(other)
other.instance_of?(self.class) && @myhash == other.to_h
end
end # class Entry
11 changes: 11 additions & 0 deletions test/test_entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ def test_to_h
duplicate.delete(:sn)
assert_not_equal duplicate, @entry.to_h
end

def test_equal_operator
entry_two = Net::LDAP::Entry.new 'cn=Barbara,o=corp'
assert_equal @entry, entry_two

@entry['sn'] = 'Jensen'
assert_not_equal @entry, entry_two

entry_two['sn'] = 'Jensen'
assert_equal @entry, entry_two
end
end

class TestEntryLDIF < Test::Unit::TestCase
Expand Down