forked from asynchrony/ruby-activeldap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_callback.rb
35 lines (29 loc) · 1.08 KB
/
test_callback.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require 'al-test-utils'
class TestCallback < Test::Unit::TestCase
include AlTestUtils
priority :must
priority :normal
def test_callback_after_find_and_after_initialize
make_temporary_group do |group|
found_entries = []
initialized_entries = []
@group_class.instance_variable_set("@found_entries", found_entries)
@group_class.instance_variable_set("@initialized_entries",
initialized_entries)
@group_class.module_eval do
define_method(:after_find) do
self.class.instance_variable_get("@found_entries") << self
end
define_method(:after_initialize) do
self.class.instance_variable_get("@initialized_entries") << self
end
end
assert_equal([], found_entries)
assert_equal([], initialized_entries)
found_group = @group_class.find(group.dn)
assert_equal([found_group.cn].sort, found_entries.collect {|g| g.cn}.sort)
assert_equal([found_group.cn].sort,
initialized_entries.collect {|g| g.cn}.sort)
end
end
end