File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,13 @@ def attribute_names
133133 @myhash . keys
134134 end
135135
136+ ##
137+ # Creates a duplicate of the internal Hash containing the attributes
138+ # of the entry.
139+ def to_h
140+ @myhash . dup
141+ end
142+
136143 ##
137144 # Accesses each of the attributes present in the Entry.
138145 #
Original file line number Diff line number Diff line change @@ -39,6 +39,21 @@ def test_case_insensitive_attribute_names
3939 assert_equal [ 'Jensen' ] , @entry [ 'Sn' ]
4040 assert_equal [ 'Jensen' ] , @entry [ 'SN' ]
4141 end
42+
43+ def test_to_h
44+ @entry [ 'sn' ] = 'Jensen'
45+ expected = {
46+ dn : [ 'cn=Barbara,o=corp' ] ,
47+ sn : [ 'Jensen' ] ,
48+ }
49+ duplicate = @entry . to_h
50+ assert_equal expected , duplicate
51+
52+ # check that changing the duplicate
53+ # does not affect the internal state
54+ duplicate . delete ( :sn )
55+ assert_not_equal duplicate , @entry . to_h
56+ end
4257end
4358
4459class TestEntryLDIF < Test ::Unit ::TestCase
You can’t perform that action at this time.
0 commit comments