activeldap 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +11 -0
- data/README +6 -3
- data/Rakefile +6 -6
- data/examples/al-admin/config/environment.rb +3 -3
- data/examples/groupadd +1 -1
- data/examples/groupdel +1 -1
- data/examples/groupls +1 -1
- data/examples/groupmod +1 -1
- data/examples/lpasswd +1 -1
- data/examples/ouadd +1 -1
- data/examples/useradd +1 -1
- data/examples/useradd-binary +1 -1
- data/examples/userdel +1 -1
- data/examples/userls +1 -1
- data/examples/usermod +1 -1
- data/examples/usermod-binary-add +1 -1
- data/examples/usermod-binary-add-time +1 -1
- data/examples/usermod-binary-del +1 -1
- data/examples/usermod-lang-add +1 -1
- data/lib/active_ldap.rb +6 -6
- data/lib/active_ldap/adapter/base.rb +14 -1
- data/lib/active_ldap/adapter/jndi.rb +5 -1
- data/lib/active_ldap/adapter/net_ldap.rb +7 -1
- data/lib/active_ldap/association/belongs_to_many.rb +4 -0
- data/lib/active_ldap/association/has_many.rb +5 -5
- data/lib/active_ldap/association/has_many_utils.rb +5 -6
- data/lib/active_ldap/association/has_many_wrap.rb +13 -9
- data/lib/active_ldap/association/proxy.rb +5 -1
- data/lib/active_ldap/associations.rb +1 -1
- data/lib/active_ldap/attributes.rb +7 -3
- data/lib/active_ldap/base.rb +16 -2
- data/lib/active_ldap/distinguished_name.rb +3 -6
- data/lib/active_ldap/operations.rb +11 -8
- data/lib/active_ldap/timeout_stub.rb +1 -1
- data/lib/active_ldap/xml.rb +5 -2
- data/test-unit/History.txt +54 -0
- data/test-unit/Manifest.txt +3 -3
- data/test-unit/README.txt +4 -1
- data/test-unit/images/color-diff.png +0 -0
- data/test-unit/lib/test/unit.rb +23 -42
- data/test-unit/lib/test/unit/assertionfailederror.rb +11 -0
- data/test-unit/lib/test/unit/assertions.rb +77 -8
- data/test-unit/lib/test/unit/autorunner.rb +13 -2
- data/test-unit/lib/test/unit/collector/load.rb +2 -3
- data/test-unit/lib/test/unit/color-scheme.rb +13 -1
- data/test-unit/lib/test/unit/diff.rb +223 -37
- data/test-unit/lib/test/unit/failure.rb +27 -5
- data/test-unit/lib/test/unit/omission.rb +47 -3
- data/test-unit/lib/test/unit/testcase.rb +42 -0
- data/test-unit/lib/test/unit/ui/console/testrunner.rb +189 -3
- data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +14 -0
- data/test-unit/lib/test/unit/ui/testrunner.rb +8 -0
- data/test-unit/lib/test/unit/version.rb +1 -1
- data/test-unit/sample/{tc_adder.rb → test_adder.rb} +3 -1
- data/test-unit/sample/{tc_subtracter.rb → test_subtracter.rb} +3 -1
- data/test-unit/sample/test_user.rb +1 -0
- data/test-unit/test/run-test.rb +2 -0
- data/test-unit/test/test-color-scheme.rb +7 -0
- data/test-unit/test/test-diff.rb +48 -7
- data/test-unit/test/test-omission.rb +1 -1
- data/test-unit/test/test-testcase.rb +27 -0
- data/test-unit/test/test_assertions.rb +43 -10
- data/test/al-test-utils.rb +15 -0
- data/test/test_associations.rb +46 -1
- data/test/test_attributes.rb +43 -20
- data/test/test_base.rb +60 -3
- metadata +12 -12
- data/test-unit/sample/ts_examples.rb +0 -7
@@ -56,7 +56,7 @@ module Test
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
# Omit the test
|
59
|
+
# Omit the test or part of the test.
|
60
60
|
#
|
61
61
|
# Example:
|
62
62
|
# def test_omission
|
@@ -80,12 +80,56 @@ module Test
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
+
# Omit the test or part of the test if _condition_ is
|
84
|
+
# true.
|
85
|
+
#
|
86
|
+
# Example:
|
87
|
+
# def test_omission
|
88
|
+
# omit_if("".empty?)
|
89
|
+
# # Not reached here
|
90
|
+
# end
|
91
|
+
#
|
92
|
+
# def test_omission_with_here
|
93
|
+
# omit_if(true) do
|
94
|
+
# # Not ran here
|
95
|
+
# end
|
96
|
+
# omit_if(false) do
|
97
|
+
# # Reached here
|
98
|
+
# end
|
99
|
+
# # Reached here too
|
100
|
+
# end
|
83
101
|
def omit_if(condition, *args, &block)
|
84
|
-
|
102
|
+
if condition
|
103
|
+
omit(*args, &block)
|
104
|
+
else
|
105
|
+
block.call if block
|
106
|
+
end
|
85
107
|
end
|
86
108
|
|
109
|
+
# Omit the test or part of the test if _condition_ is
|
110
|
+
# not true.
|
111
|
+
#
|
112
|
+
# Example:
|
113
|
+
# def test_omission
|
114
|
+
# omit_unless("string".empty?)
|
115
|
+
# # Not reached here
|
116
|
+
# end
|
117
|
+
#
|
118
|
+
# def test_omission_with_here
|
119
|
+
# omit_unless(true) do
|
120
|
+
# # Reached here
|
121
|
+
# end
|
122
|
+
# omit_unless(false) do
|
123
|
+
# # Not ran here
|
124
|
+
# end
|
125
|
+
# # Reached here too
|
126
|
+
# end
|
87
127
|
def omit_unless(condition, *args, &block)
|
88
|
-
|
128
|
+
if condition
|
129
|
+
block.call if block
|
130
|
+
else
|
131
|
+
omit(*args, &block)
|
132
|
+
end
|
89
133
|
end
|
90
134
|
|
91
135
|
private
|
@@ -212,6 +212,39 @@ module Test
|
|
212
212
|
@@test_order = order
|
213
213
|
end
|
214
214
|
|
215
|
+
# Defines a test in declarative syntax.
|
216
|
+
#
|
217
|
+
# The following two test definitions are the same:
|
218
|
+
#
|
219
|
+
# description "register user"
|
220
|
+
# def test_register_user
|
221
|
+
# ...
|
222
|
+
# end
|
223
|
+
#
|
224
|
+
# test "register user" do
|
225
|
+
# ...
|
226
|
+
# end
|
227
|
+
def test(test_description, &block)
|
228
|
+
normalized_description = test_description.gsub(/[^a-zA-Z\d_]+/, '_')
|
229
|
+
method_name = "test_#{normalized_description}".to_sym
|
230
|
+
define_method(method_name, &block)
|
231
|
+
description(test_description, method_name)
|
232
|
+
end
|
233
|
+
|
234
|
+
# Describes a test.
|
235
|
+
#
|
236
|
+
# The following example associates "register a
|
237
|
+
# normal user" description with "test_register"
|
238
|
+
# test.
|
239
|
+
#
|
240
|
+
# description "register a normal user"
|
241
|
+
# def test_register
|
242
|
+
# ...
|
243
|
+
# end
|
244
|
+
def description(value, target=nil)
|
245
|
+
attribute(:description, value, {}, target || [])
|
246
|
+
end
|
247
|
+
|
215
248
|
# :stopdoc:
|
216
249
|
private
|
217
250
|
def collect_test_names
|
@@ -374,6 +407,15 @@ module Test
|
|
374
407
|
"#{@method_name}(#{self.class.name})"
|
375
408
|
end
|
376
409
|
|
410
|
+
# Returns a description for the test. A description
|
411
|
+
# will be associated by Test::Unit::TestCase.test or
|
412
|
+
# Test::Unit::TestCase.description.
|
413
|
+
#
|
414
|
+
# Returns a name for the test for no description test.
|
415
|
+
def description
|
416
|
+
self[:description] || name
|
417
|
+
end
|
418
|
+
|
377
419
|
# Overridden to return #name.
|
378
420
|
def to_s
|
379
421
|
name
|
@@ -101,9 +101,7 @@ module Test
|
|
101
101
|
@faults.each_with_index do |fault, index|
|
102
102
|
nl
|
103
103
|
output_single("%3d) " % (index + 1))
|
104
|
-
|
105
|
-
output(label, fault_color(fault))
|
106
|
-
output(detail)
|
104
|
+
output_fault(fault)
|
107
105
|
end
|
108
106
|
nl
|
109
107
|
output("Finished in #{elapsed_time} seconds.")
|
@@ -118,6 +116,65 @@ module Test
|
|
118
116
|
output("%g%% passed" % pass_percentage, result_color)
|
119
117
|
end
|
120
118
|
|
119
|
+
def output_fault(fault)
|
120
|
+
if @use_color and fault.is_a?(Failure) and
|
121
|
+
fault.inspected_expected and fault.inspected_actual
|
122
|
+
output_single(fault.label, fault_color(fault))
|
123
|
+
output(":")
|
124
|
+
output_fault_backtrace(fault)
|
125
|
+
output_fault_message(fault)
|
126
|
+
else
|
127
|
+
label, detail = format_fault(fault).split(/\r?\n/, 2)
|
128
|
+
output(label, fault_color(fault))
|
129
|
+
output(detail)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def output_fault_backtrace(fault)
|
134
|
+
backtrace = fault.location
|
135
|
+
if backtrace.size == 1
|
136
|
+
output(fault.test_name +
|
137
|
+
backtrace[0].sub(/\A(.+:\d+).*/, ' [\\1]') +
|
138
|
+
":")
|
139
|
+
else
|
140
|
+
output(fault.test_name)
|
141
|
+
backtrace.each_with_index do |entry, i|
|
142
|
+
if i.zero?
|
143
|
+
prefix = "["
|
144
|
+
postfix = ""
|
145
|
+
elsif i == backtrace.size - 1
|
146
|
+
prefix = " "
|
147
|
+
postfix = "]:"
|
148
|
+
else
|
149
|
+
prefix = " "
|
150
|
+
postfix = ""
|
151
|
+
end
|
152
|
+
output(" #{prefix}#{entry}#{postfix}")
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def output_fault_message(fault)
|
158
|
+
output(fault.user_message) if fault.user_message
|
159
|
+
output_single("<")
|
160
|
+
output_single(fault.inspected_expected, color("success"))
|
161
|
+
output("> expected but was")
|
162
|
+
output_single("<")
|
163
|
+
output_single(fault.inspected_actual, color("failure"))
|
164
|
+
output(">")
|
165
|
+
from, to = prepare_for_diff(fault.expected, fault.actual)
|
166
|
+
if from and to
|
167
|
+
differ = ColorizedReadableDiffer.new(from.split(/\r?\n/),
|
168
|
+
to.split(/\r?\n/),
|
169
|
+
self)
|
170
|
+
if differ.need_diff?
|
171
|
+
output("")
|
172
|
+
output("diff:")
|
173
|
+
differ.diff
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
121
178
|
def format_fault(fault)
|
122
179
|
fault.long_display
|
123
180
|
end
|
@@ -268,6 +325,135 @@ module Test
|
|
268
325
|
0
|
269
326
|
end
|
270
327
|
end
|
328
|
+
|
329
|
+
class ColorizedReadableDiffer < Diff::ReadableDiffer
|
330
|
+
def initialize(from, to, runner)
|
331
|
+
@runner = runner
|
332
|
+
super(from, to)
|
333
|
+
end
|
334
|
+
|
335
|
+
def need_diff?(options={})
|
336
|
+
operations.each do |tag,|
|
337
|
+
return true if [:replace, :equal].include?(tag)
|
338
|
+
end
|
339
|
+
false
|
340
|
+
end
|
341
|
+
|
342
|
+
private
|
343
|
+
def output_single(something, color=nil)
|
344
|
+
@runner.send(:output_single, something, color)
|
345
|
+
end
|
346
|
+
|
347
|
+
def output(something, color=nil)
|
348
|
+
@runner.send(:output, something, color)
|
349
|
+
end
|
350
|
+
|
351
|
+
def color(name)
|
352
|
+
@runner.send(:color, name)
|
353
|
+
end
|
354
|
+
|
355
|
+
def cut_off_ratio
|
356
|
+
0
|
357
|
+
end
|
358
|
+
|
359
|
+
def default_ratio
|
360
|
+
0
|
361
|
+
end
|
362
|
+
|
363
|
+
def tag(mark, color_name, contents)
|
364
|
+
_color = color(color_name)
|
365
|
+
contents.each do |content|
|
366
|
+
output_single(mark, _color)
|
367
|
+
output_single(" ")
|
368
|
+
output(content)
|
369
|
+
end
|
370
|
+
end
|
371
|
+
|
372
|
+
def tag_deleted(contents)
|
373
|
+
tag("-", "diff-deleted-tag", contents)
|
374
|
+
end
|
375
|
+
|
376
|
+
def tag_inserted(contents)
|
377
|
+
tag("+", "diff-inserted-tag", contents)
|
378
|
+
end
|
379
|
+
|
380
|
+
def tag_equal(contents)
|
381
|
+
tag(" ", "normal", contents)
|
382
|
+
end
|
383
|
+
|
384
|
+
def tag_difference(contents)
|
385
|
+
tag("?", "diff-difference-tag", contents)
|
386
|
+
end
|
387
|
+
|
388
|
+
def diff_line(from_line, to_line)
|
389
|
+
to_operations = []
|
390
|
+
from_line, to_line, _operations = line_operations(from_line, to_line)
|
391
|
+
|
392
|
+
no_replace = true
|
393
|
+
_operations.each do |tag,|
|
394
|
+
if tag == :replace
|
395
|
+
no_replace = false
|
396
|
+
break
|
397
|
+
end
|
398
|
+
end
|
399
|
+
|
400
|
+
output_single("?", color("diff-difference-tag"))
|
401
|
+
output_single(" ")
|
402
|
+
_operations.each do |tag, from_start, from_end, to_start, to_end|
|
403
|
+
from_width = compute_width(from_line, from_start, from_end)
|
404
|
+
to_width = compute_width(to_line, to_start, to_end)
|
405
|
+
case tag
|
406
|
+
when :replace
|
407
|
+
output_single(from_line[from_start...from_end],
|
408
|
+
color("diff-deleted"))
|
409
|
+
if (from_width < to_width)
|
410
|
+
output_single(" " * (to_width - from_width))
|
411
|
+
end
|
412
|
+
to_operations << Proc.new do
|
413
|
+
output_single(to_line[to_start...to_end],
|
414
|
+
color("diff-inserted"))
|
415
|
+
if (to_width < from_width)
|
416
|
+
output_single(" " * (from_width - to_width))
|
417
|
+
end
|
418
|
+
end
|
419
|
+
when :delete
|
420
|
+
output_single(from_line[from_start...from_end],
|
421
|
+
color("diff-deleted"))
|
422
|
+
unless no_replace
|
423
|
+
to_operations << Proc.new {output_single(" " * from_width)}
|
424
|
+
end
|
425
|
+
when :insert
|
426
|
+
if no_replace
|
427
|
+
output_single(to_line[to_start...to_end],
|
428
|
+
color("diff-inserted"))
|
429
|
+
else
|
430
|
+
output_single(" " * to_width)
|
431
|
+
to_operations << Proc.new do
|
432
|
+
output_single(to_line[to_start...to_end],
|
433
|
+
color("diff-inserted"))
|
434
|
+
end
|
435
|
+
end
|
436
|
+
when :equal
|
437
|
+
output_single(from_line[from_start...from_end])
|
438
|
+
unless no_replace
|
439
|
+
to_operations << Proc.new {output_single(" " * to_width)}
|
440
|
+
end
|
441
|
+
else
|
442
|
+
raise "unknown tag: #{tag}"
|
443
|
+
end
|
444
|
+
end
|
445
|
+
output("")
|
446
|
+
|
447
|
+
unless to_operations.empty?
|
448
|
+
output_single("?", color("diff-difference-tag"))
|
449
|
+
output_single(" ")
|
450
|
+
to_operations.each do |operation|
|
451
|
+
operation.call
|
452
|
+
end
|
453
|
+
output("")
|
454
|
+
end
|
455
|
+
end
|
456
|
+
end
|
271
457
|
end
|
272
458
|
end
|
273
459
|
end
|
@@ -22,6 +22,20 @@ module Test
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
def output_fault_backtrace(fault)
|
26
|
+
backtrace = fault.location
|
27
|
+
if backtrace.size == 1
|
28
|
+
output(fault.test_name +
|
29
|
+
backtrace[0].sub(/\A(.+:\d+).*/, ' [\\1]') +
|
30
|
+
":")
|
31
|
+
else
|
32
|
+
output(fault.test_name)
|
33
|
+
backtrace.each do |entry|
|
34
|
+
output(entry)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
25
39
|
def format_fault_failure(failure)
|
26
40
|
if failure.location.size == 1
|
27
41
|
location = failure.location[0]
|
@@ -14,6 +14,14 @@ module Test
|
|
14
14
|
end
|
15
15
|
@options = options
|
16
16
|
end
|
17
|
+
|
18
|
+
def diff_target_string?(string)
|
19
|
+
Assertions::AssertionMessage.diff_target_string?(string)
|
20
|
+
end
|
21
|
+
|
22
|
+
def prepare_for_diff(from, to)
|
23
|
+
Assertions::AssertionMessage.prepare_for_diff(from, to)
|
24
|
+
end
|
17
25
|
end
|
18
26
|
end
|
19
27
|
end
|
@@ -5,13 +5,15 @@
|
|
5
5
|
require 'test/unit'
|
6
6
|
require 'adder'
|
7
7
|
|
8
|
-
class
|
8
|
+
class TestAdder < Test::Unit::TestCase
|
9
9
|
def setup
|
10
10
|
@adder = Adder.new(5)
|
11
11
|
end
|
12
|
+
|
12
13
|
def test_add
|
13
14
|
assert_equal(7, @adder.add(2), "Should have added correctly")
|
14
15
|
end
|
16
|
+
|
15
17
|
def teardown
|
16
18
|
@adder = nil
|
17
19
|
end
|
@@ -5,13 +5,15 @@
|
|
5
5
|
require 'test/unit'
|
6
6
|
require 'subtracter'
|
7
7
|
|
8
|
-
class
|
8
|
+
class TestSubtracter < Test::Unit::TestCase
|
9
9
|
def setup
|
10
10
|
@subtracter = Subtracter.new(5)
|
11
11
|
end
|
12
|
+
|
12
13
|
def test_subtract
|
13
14
|
assert_equal(3, @subtracter.subtract(2), "Should have subtracted correctly")
|
14
15
|
end
|
16
|
+
|
15
17
|
def teardown
|
16
18
|
@subtracter = nil
|
17
19
|
end
|
data/test-unit/test/run-test.rb
CHANGED
@@ -12,6 +12,13 @@ class TestUnitColorScheme < Test::Unit::TestCase
|
|
12
12
|
color("blue", :foreground => false),
|
13
13
|
"suite" => color("white", :bold => true) +
|
14
14
|
color("green", :foreground => false),
|
15
|
+
"diff-inserted-tag" => color("red", :bold => true),
|
16
|
+
"diff-deleted-tag" => color("green", :bold => true),
|
17
|
+
"diff-difference-tag" => color("cyan", :bold => true),
|
18
|
+
"diff-inserted" => color("red", :foreground => false) +
|
19
|
+
color("white", :bold => true),
|
20
|
+
"diff-deleted" => color("green", :foreground => false) +
|
21
|
+
color("white", :bold => true),
|
15
22
|
},
|
16
23
|
Test::Unit::ColorScheme.default.to_hash)
|
17
24
|
end
|