activesambaldap 0.0.6 → 0.0.7
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/NEWS.en +20 -18
- data/NEWS.ja +23 -21
- data/README.en +122 -95
- data/README.ja +125 -98
- data/Rakefile +29 -64
- data/bin/asl-groupadd +1 -1
- data/bin/asl-groupadd.help +1 -0
- data/bin/asl-groupdel +1 -1
- data/bin/asl-groupdel.help +1 -0
- data/bin/asl-groupmod +1 -1
- data/bin/asl-groupmod.help +1 -0
- data/bin/asl-groupshow +1 -1
- data/bin/asl-groupshow.help +1 -0
- data/bin/asl-passwd +1 -1
- data/bin/asl-passwd.help +1 -0
- data/bin/asl-populate +2 -2
- data/bin/asl-populate.help +1 -0
- data/bin/asl-purge +1 -1
- data/bin/asl-purge.help +1 -0
- data/bin/asl-samba-computeradd +1 -1
- data/bin/asl-samba-computeradd.help +1 -0
- data/bin/asl-samba-groupadd +1 -1
- data/bin/asl-samba-groupadd.help +1 -0
- data/bin/asl-samba-groupdel +1 -1
- data/bin/asl-samba-groupdel.help +1 -0
- data/bin/asl-samba-groupmod +1 -1
- data/bin/asl-samba-groupmod.help +1 -0
- data/bin/asl-samba-useradd +1 -1
- data/bin/asl-samba-useradd.help +1 -0
- data/bin/asl-samba-userdel +1 -1
- data/bin/asl-samba-userdel.help +1 -0
- data/bin/asl-samba-usermod +1 -1
- data/bin/asl-samba-usermod.help +1 -0
- data/bin/asl-useradd +1 -1
- data/bin/asl-useradd.help +6 -4
- data/bin/asl-userdel +1 -1
- data/bin/asl-userdel.help +1 -0
- data/bin/asl-usermod +1 -1
- data/bin/asl-usermod.help +2 -0
- data/bin/asl-usershow +1 -1
- data/bin/asl-usershow.help +1 -0
- data/data/locale/ja/LC_MESSAGES/active-samba-ldap.mo +0 -0
- data/lib/active_samba_ldap/version.rb +1 -1
- data/lib/active_samba_ldap.rb +1 -1
- data/po/ja/active-samba-ldap.po +5 -5
- data/rails/{plugin/active_samba_ldap/README → README} +0 -0
- data/rails/{plugin/active_samba_ldap/init.rb → init.rb} +1 -1
- data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/scaffold_active_samba_ldap_generator.rb +0 -0
- data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/computer.rb +0 -0
- data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/dc.rb +0 -0
- data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/group.rb +0 -0
- data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/idmap.rb +0 -0
- data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/ldap.yml +0 -0
- data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/ou.rb +0 -0
- data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/samba_controller.rb +0 -0
- data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/samba_helper.rb +0 -0
- data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/samba_index.rhtml +0 -0
- data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/samba_populate.rhtml +0 -0
- data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/samba_purge.rhtml +0 -0
- data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/unix_id_pool.rb +0 -0
- data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/user.rb +0 -0
- data/test/asl-test-utils.rb +2 -2
- data/test/test_asl_usershow.rb +2 -2
- data/test/test_password.rb +2 -2
- data/test/test_user_home_directory.rb +2 -2
- data/test-unit/History.txt +76 -1
- data/test-unit/README.txt +32 -12
- data/test-unit/Rakefile +19 -1
- data/test-unit/TODO +5 -0
- data/test-unit/lib/test/unit/assertions.rb +515 -88
- data/test-unit/lib/test/unit/autorunner.rb +93 -14
- data/test-unit/lib/test/unit/collector/load.rb +1 -1
- data/test-unit/lib/test/unit/collector.rb +1 -1
- data/test-unit/lib/test/unit/color-scheme.rb +86 -0
- data/test-unit/lib/test/unit/color.rb +40 -5
- data/test-unit/lib/test/unit/diff.rb +14 -0
- data/test-unit/lib/test/unit/fixture.rb +7 -16
- data/test-unit/lib/test/unit/notification.rb +9 -0
- data/test-unit/lib/test/unit/omission.rb +14 -0
- data/test-unit/lib/test/unit/pending.rb +16 -0
- data/test-unit/lib/test/unit/priority.rb +38 -3
- data/test-unit/lib/test/unit/runner/console.rb +8 -2
- data/test-unit/lib/test/unit/testcase.rb +263 -12
- data/test-unit/lib/test/unit/ui/console/testrunner.rb +58 -30
- data/test-unit/lib/test/unit/util/method-owner-finder.rb +28 -0
- data/test-unit/lib/test/unit/version.rb +1 -1
- data/test-unit/lib/test/unit.rb +62 -0
- data/test-unit/sample/test_user.rb +22 -0
- data/test-unit/test/collector/{test_descendant.rb → test-descendant.rb} +0 -0
- data/test-unit/test/collector/{test_load.rb → test-load.rb} +1 -1
- data/test-unit/test/{test_attribute.rb → test-attribute.rb} +0 -0
- data/test-unit/test/test-color-scheme.rb +56 -0
- data/test-unit/test/{test_color.rb → test-color.rb} +10 -0
- data/test-unit/test/{test_diff.rb → test-diff.rb} +0 -0
- data/test-unit/test/{test_emacs_runner.rb → test-emacs-runner.rb} +0 -0
- data/test-unit/test/test-fixture.rb +287 -0
- data/test-unit/test/{test_notification.rb → test-notification.rb} +4 -4
- data/test-unit/test/{test_omission.rb → test-omission.rb} +6 -6
- data/test-unit/test/{test_pending.rb → test-pending.rb} +12 -6
- data/test-unit/test/{test_priority.rb → test-priority.rb} +30 -0
- data/test-unit/test/{test_testcase.rb → test-testcase.rb} +100 -4
- data/test-unit/test/test_assertions.rb +462 -73
- data/test-unit/test/{testunit_test_util.rb → testunit-test-util.rb} +4 -2
- data/test-unit/test/ui/test_testrunmediator.rb +1 -1
- data/test-unit/test/util/test-method-owner-finder.rb +38 -0
- metadata +69 -79
- data/test-unit/test/test_fixture.rb +0 -275
@@ -1,5 +1,6 @@
|
|
1
1
|
# Author:: Nathaniel Talbott.
|
2
2
|
# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
|
3
|
+
# Copyright (c) 2009 Kouhei Sutou.
|
3
4
|
# License:: Ruby license.
|
4
5
|
|
5
6
|
require 'test/unit'
|
@@ -7,6 +8,10 @@ require 'test/unit'
|
|
7
8
|
module Test
|
8
9
|
module Unit
|
9
10
|
class TC_Assertions < TestCase
|
11
|
+
backtrace_pre = "---Backtrace---"
|
12
|
+
backtrace_post = "---------------"
|
13
|
+
BACKTRACE_RE = /#{backtrace_pre}\n.+\n#{backtrace_post}/m
|
14
|
+
|
10
15
|
def check(value, message="")
|
11
16
|
add_assertion
|
12
17
|
raise AssertionFailedError.new(message) unless value
|
@@ -116,9 +121,6 @@ module Test
|
|
116
121
|
check_nothing_fails {
|
117
122
|
assert_equal("string1", "string1")
|
118
123
|
}
|
119
|
-
check_nothing_fails {
|
120
|
-
assert_equal( "string1", "string1", "successful assert_equal")
|
121
|
-
}
|
122
124
|
check_nothing_fails {
|
123
125
|
assert_equal("string1", "string1", "successful assert_equal")
|
124
126
|
}
|
@@ -166,6 +168,47 @@ EOM
|
|
166
168
|
end
|
167
169
|
end
|
168
170
|
|
171
|
+
def test_assert_equal_with_long_line
|
172
|
+
expected = ["0123456789",
|
173
|
+
"1123456789",
|
174
|
+
"2123456789",
|
175
|
+
"3123456789",
|
176
|
+
"4123456789",
|
177
|
+
"5123456789",
|
178
|
+
"6123456789",
|
179
|
+
"7123456789",
|
180
|
+
"8123456789"].join
|
181
|
+
actual = ["0000000000",
|
182
|
+
"1123456789",
|
183
|
+
"2123456789",
|
184
|
+
"3123456789",
|
185
|
+
"4123456789",
|
186
|
+
"5123456789",
|
187
|
+
"6123456789",
|
188
|
+
"7123456789",
|
189
|
+
"8123456789"].join
|
190
|
+
message = <<-EOM.chomp
|
191
|
+
<"#{expected}"> expected but was
|
192
|
+
<"#{actual}">.
|
193
|
+
|
194
|
+
diff:
|
195
|
+
- #{expected}
|
196
|
+
? ^^^^^^^^^
|
197
|
+
+ #{actual}
|
198
|
+
? ^^^^^^^^^
|
199
|
+
|
200
|
+
folded diff:
|
201
|
+
- 012345678911234567892123456789312345678941234567895123456789612345678971234567
|
202
|
+
? ^^^^^^^^^
|
203
|
+
+ 000000000011234567892123456789312345678941234567895123456789612345678971234567
|
204
|
+
? ^^^^^^^^^
|
205
|
+
898123456789
|
206
|
+
EOM
|
207
|
+
check_fails(message) do
|
208
|
+
assert_equal(expected, actual)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
169
212
|
def test_assert_equal_for_too_small_difference
|
170
213
|
message = <<-EOM.chomp
|
171
214
|
<1> expected but was
|
@@ -203,85 +246,222 @@ EOM
|
|
203
246
|
end
|
204
247
|
end
|
205
248
|
|
206
|
-
def
|
249
|
+
def test_assert_equal_with_large_string
|
250
|
+
message = <<-EOM.chomp
|
251
|
+
<#{("a\n" + "x" * 297).inspect}> expected but was
|
252
|
+
<#{"x".inspect}>.
|
253
|
+
|
254
|
+
diff:
|
255
|
+
+ x
|
256
|
+
- a
|
257
|
+
- #{"x" * 297}
|
258
|
+
|
259
|
+
folded diff:
|
260
|
+
+ x
|
261
|
+
- a
|
262
|
+
- #{"x" * 78}
|
263
|
+
- #{"x" * 78}
|
264
|
+
- #{"x" * 78}
|
265
|
+
- #{"x" * 63}
|
266
|
+
EOM
|
267
|
+
check_fails(message) do
|
268
|
+
assert_equal("a\n" + "x" * 297, "x")
|
269
|
+
end
|
270
|
+
|
271
|
+
message = <<-EOM.chomp
|
272
|
+
<#{("a\n" + "x" * 298).inspect}> expected but was
|
273
|
+
<#{"x".inspect}>.
|
274
|
+
EOM
|
275
|
+
check_fails(message) do
|
276
|
+
assert_equal("a\n" + "x" * 298, "x")
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
def test_assert_raise_success
|
207
281
|
return_value = nil
|
208
|
-
check_nothing_fails(true)
|
209
|
-
return_value = assert_raise(RuntimeError)
|
282
|
+
check_nothing_fails(true) do
|
283
|
+
return_value = assert_raise(RuntimeError) do
|
210
284
|
raise "Error"
|
211
|
-
|
212
|
-
|
213
|
-
check(return_value.kind_of?(Exception),
|
214
|
-
|
215
|
-
|
216
|
-
|
285
|
+
end
|
286
|
+
end
|
287
|
+
check(return_value.kind_of?(Exception),
|
288
|
+
"Should have returned the exception " +
|
289
|
+
"from a successful assert_raise")
|
290
|
+
check(return_value.message == "Error",
|
291
|
+
"Should have returned the correct exception " +
|
292
|
+
"from a successful assert_raise")
|
293
|
+
|
294
|
+
check_nothing_fails(true) do
|
295
|
+
assert_raise(ArgumentError, "successful assert_raise") do
|
217
296
|
raise ArgumentError.new("Error")
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
check_nothing_fails(true) do
|
301
|
+
assert_raise(RuntimeError) do
|
222
302
|
raise "Error"
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
check_nothing_fails(true) do
|
307
|
+
assert_raise(RuntimeError, "successful assert_raise") do
|
227
308
|
raise "Error"
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
check_nothing_fails(true) do
|
313
|
+
assert_raise do
|
314
|
+
raise Exception, "Any exception"
|
315
|
+
end
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
def test_assert_raise_fail
|
320
|
+
check_fails("<RuntimeError> exception expected but none was thrown.") do
|
321
|
+
assert_raise(RuntimeError) do
|
232
322
|
1 + 1
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
message = <<-EOM
|
327
|
+
failed assert_raise.
|
328
|
+
<ArgumentError> exception expected but was
|
329
|
+
Class: <RuntimeError>
|
330
|
+
Message: <"Error">
|
331
|
+
EOM
|
332
|
+
check_fails(/\A#{message}#{BACKTRACE_RE}\Z/m) do
|
333
|
+
assert_raise(ArgumentError, "failed assert_raise") do
|
237
334
|
raise "Error"
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
message = <<-EOM
|
339
|
+
Should expect a class of exception, Object.
|
340
|
+
<false> is not true.
|
341
|
+
EOM
|
342
|
+
check_fails(message.chomp) do
|
343
|
+
assert_nothing_raised(Object) do
|
242
344
|
1 + 1
|
243
|
-
|
244
|
-
|
345
|
+
end
|
346
|
+
end
|
347
|
+
end
|
245
348
|
|
349
|
+
def test_assert_raise_module
|
246
350
|
exceptions = [ArgumentError, TypeError]
|
247
351
|
modules = [Math, Comparable]
|
248
352
|
rescues = exceptions + modules
|
353
|
+
|
249
354
|
exceptions.each do |exc|
|
250
|
-
|
251
|
-
|
355
|
+
return_value = nil
|
356
|
+
check_nothing_fails(true) do
|
357
|
+
return_value = assert_raise(*rescues) do
|
252
358
|
raise exc, "Error"
|
253
|
-
|
254
|
-
|
255
|
-
check(return_value.instance_of?(exc),
|
256
|
-
|
359
|
+
end
|
360
|
+
end
|
361
|
+
check(return_value.instance_of?(exc),
|
362
|
+
"Should have returned #{exc} but was #{return_value.class}")
|
363
|
+
check(return_value.message == "Error",
|
364
|
+
"Should have returned the correct exception " +
|
365
|
+
"from a successful assert_raise")
|
257
366
|
end
|
367
|
+
|
258
368
|
modules.each do |mod|
|
259
|
-
|
260
|
-
|
369
|
+
return_value = nil
|
370
|
+
check_nothing_fails(true) do
|
371
|
+
return_value = assert_raise(*rescues) do
|
261
372
|
raise Exception.new("Error").extend(mod)
|
262
|
-
|
263
|
-
|
264
|
-
check(mod === return_value,
|
265
|
-
|
373
|
+
end
|
374
|
+
end
|
375
|
+
check(mod === return_value,
|
376
|
+
"Should have returned #{mod}")
|
377
|
+
check(return_value.message == "Error",
|
378
|
+
"Should have returned the correct exception " +
|
379
|
+
"from a successful assert_raise")
|
266
380
|
end
|
267
|
-
|
268
|
-
|
381
|
+
|
382
|
+
check_fails("<[ArgumentError, TypeError, Math, Comparable]> exception " +
|
383
|
+
"expected but none was thrown.") do
|
384
|
+
assert_raise(*rescues) do
|
269
385
|
1 + 1
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
386
|
+
end
|
387
|
+
end
|
388
|
+
|
389
|
+
message = <<-EOM
|
390
|
+
failed assert_raise.
|
391
|
+
<[ArgumentError, TypeError]> exception expected but was
|
274
392
|
Class: <RuntimeError>
|
275
393
|
Message: <"Error">
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
assert_raise(ArgumentError, TypeError, "failed assert_raise")
|
394
|
+
EOM
|
395
|
+
message = Regexp.escape(message)
|
396
|
+
check_fails(/\A#{message}#{BACKTRACE_RE}\z/m) do
|
397
|
+
assert_raise(ArgumentError, TypeError, "failed assert_raise") do
|
280
398
|
raise "Error"
|
281
|
-
|
282
|
-
|
399
|
+
end
|
400
|
+
end
|
283
401
|
end
|
284
|
-
|
402
|
+
|
403
|
+
def test_assert_raise_instance
|
404
|
+
return_value = nil
|
405
|
+
check_nothing_fails(true) do
|
406
|
+
return_value = assert_raise(RuntimeError.new("Error")) do
|
407
|
+
raise "Error"
|
408
|
+
end
|
409
|
+
end
|
410
|
+
check(return_value.kind_of?(Exception),
|
411
|
+
"Should have returned the exception " +
|
412
|
+
"from a successful assert_raise")
|
413
|
+
check(return_value.message == "Error",
|
414
|
+
"Should have returned the correct exception " +
|
415
|
+
"from a successful assert_raise")
|
416
|
+
|
417
|
+
message = <<-EOM
|
418
|
+
<RuntimeError("XXX")> exception expected but was
|
419
|
+
Class: <RuntimeError>
|
420
|
+
Message: <"Error">
|
421
|
+
EOM
|
422
|
+
message = Regexp.escape(message)
|
423
|
+
check_fails(/\A#{message}#{BACKTRACE_RE}\z/) do
|
424
|
+
return_value = assert_raise(RuntimeError.new("XXX")) do
|
425
|
+
raise "Error"
|
426
|
+
end
|
427
|
+
end
|
428
|
+
|
429
|
+
different_error_class = Class.new(StandardError)
|
430
|
+
message = <<-EOM
|
431
|
+
<\#<Class:[xa-f\\d]+>\\("Error"\\)> exception expected but was
|
432
|
+
Class: <RuntimeError>
|
433
|
+
Message: <"Error">
|
434
|
+
EOM
|
435
|
+
check_fails(/\A#{message}#{BACKTRACE_RE}\z/) do
|
436
|
+
assert_raise(different_error_class.new("Error")) do
|
437
|
+
raise "Error"
|
438
|
+
end
|
439
|
+
end
|
440
|
+
|
441
|
+
different_error = different_error_class.new("Error")
|
442
|
+
def different_error.inspect
|
443
|
+
"DifferentError: \"Error\""
|
444
|
+
end
|
445
|
+
message = <<-EOM
|
446
|
+
<\DifferentError: \\"Error\\"> exception expected but was
|
447
|
+
Class: <RuntimeError>
|
448
|
+
Message: <"Error">
|
449
|
+
EOM
|
450
|
+
check_fails(/\A#{message}#{BACKTRACE_RE}\z/) do
|
451
|
+
assert_raise(different_error) do
|
452
|
+
raise "Error"
|
453
|
+
end
|
454
|
+
end
|
455
|
+
|
456
|
+
check_nothing_fails(true) do
|
457
|
+
assert_raise(different_error_class.new("Error"),
|
458
|
+
RuntimeError.new("Error"),
|
459
|
+
RuntimeError.new("XXX")) do
|
460
|
+
raise "Error"
|
461
|
+
end
|
462
|
+
end
|
463
|
+
end
|
464
|
+
|
285
465
|
def test_assert_instance_of
|
286
466
|
check_nothing_fails {
|
287
467
|
assert_instance_of(String, "string")
|
@@ -298,8 +478,18 @@ Message: <"Error">
|
|
298
478
|
check_fails(%Q{failed assert_instance_of.\n<"string"> expected to be an instance of\n<Hash> but was\n<String>.}) {
|
299
479
|
assert_instance_of(Hash, "string", "failed assert_instance_of")
|
300
480
|
}
|
481
|
+
|
482
|
+
check_nothing_fails do
|
483
|
+
assert_instance_of([Fixnum, NilClass], 100)
|
484
|
+
end
|
485
|
+
check_fails(%Q{<"string"> expected to be an instance of\n[<Fixnum>, <NilClass>] but was\n<String>.}) do
|
486
|
+
assert_instance_of([Fixnum, NilClass], "string")
|
487
|
+
end
|
488
|
+
check_fails(%Q{<100> expected to be an instance of\n[<Numeric>, <NilClass>] but was\n<Fixnum>.}) do
|
489
|
+
assert_instance_of([Numeric, NilClass], 100)
|
490
|
+
end
|
301
491
|
end
|
302
|
-
|
492
|
+
|
303
493
|
def test_assert_nil
|
304
494
|
check_nothing_fails {
|
305
495
|
assert_nil(nil)
|
@@ -338,14 +528,21 @@ Message: <"Error">
|
|
338
528
|
check_nothing_fails {
|
339
529
|
assert_kind_of(Comparable, 1)
|
340
530
|
}
|
341
|
-
check_fails(%Q{<"string"
|
531
|
+
check_fails(%Q{<"string"> expected to be kind_of?\n<Class> but was\n<String>.}) {
|
342
532
|
assert_kind_of(Class, "string")
|
343
533
|
}
|
344
|
-
check_fails(%Q{failed assert_kind_of.\n<"string"
|
534
|
+
check_fails(%Q{failed assert_kind_of.\n<"string"> expected to be kind_of?\n<Class> but was\n<String>.}) {
|
345
535
|
assert_kind_of(Class, "string", "failed assert_kind_of")
|
346
536
|
}
|
537
|
+
|
538
|
+
check_nothing_fails do
|
539
|
+
assert_kind_of([Fixnum, NilClass], 100)
|
540
|
+
end
|
541
|
+
check_fails(%Q{<"string"> expected to be kind_of?\n[<Fixnum>, <NilClass>] but was\n<String>.}) do
|
542
|
+
assert_kind_of([Fixnum, NilClass], "string")
|
543
|
+
end
|
347
544
|
end
|
348
|
-
|
545
|
+
|
349
546
|
def test_assert_match
|
350
547
|
check_nothing_fails {
|
351
548
|
assert_match(/strin./, "string")
|
@@ -496,9 +693,9 @@ Message: <"Error">
|
|
496
693
|
end
|
497
694
|
end
|
498
695
|
|
499
|
-
def
|
696
|
+
def test_assert_throw
|
500
697
|
check_nothing_fails do
|
501
|
-
|
698
|
+
assert_throw(:thing, "message") do
|
502
699
|
throw :thing
|
503
700
|
end
|
504
701
|
end
|
@@ -507,13 +704,13 @@ Message: <"Error">
|
|
507
704
|
check_fails("message.\n" +
|
508
705
|
"<:thing> expected to be thrown but\n" +
|
509
706
|
"<#{inspect_tag(tag)}> was thrown.") do
|
510
|
-
|
707
|
+
assert_throw(:thing, "message") do
|
511
708
|
throw :thing2
|
512
709
|
end
|
513
710
|
end
|
514
711
|
check_fails("message.\n" +
|
515
712
|
"<:thing> should have been thrown.") do
|
516
|
-
|
713
|
+
assert_throw(:thing, "message") do
|
517
714
|
1 + 1
|
518
715
|
end
|
519
716
|
end
|
@@ -555,10 +752,13 @@ Message: <"Error">
|
|
555
752
|
check_nothing_fails {
|
556
753
|
assert_respond_to("thing", "to_s", "message")
|
557
754
|
}
|
558
|
-
check_fails("<0.15
|
755
|
+
check_fails("<0.15>.kind_of?(Symbol) or\n" +
|
756
|
+
"<0.15>.respond_to?(:to_str) expected") {
|
559
757
|
assert_respond_to("thing", 0.15)
|
560
758
|
}
|
561
|
-
check_fails("message.\n
|
759
|
+
check_fails("message.\n" +
|
760
|
+
"<:symbol>.respond_to?(:non_existent) expected\n" +
|
761
|
+
"(Class: <Symbol>)") {
|
562
762
|
assert_respond_to(:symbol, :non_existent, "message")
|
563
763
|
}
|
564
764
|
end
|
@@ -580,10 +780,15 @@ Message: <"Error">
|
|
580
780
|
check_fails("message.\n<0.5> and\n<0.4> expected to be within\n<0.05> of each other.") {
|
581
781
|
assert_in_delta(0.5, 0.4, 0.05, "message")
|
582
782
|
}
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
783
|
+
object = Object.new
|
784
|
+
check_fails("The arguments must respond to to_f; " +
|
785
|
+
"the first float did not.\n" +
|
786
|
+
"<#{object.inspect}>.respond_to?(:to_f) expected\n" +
|
787
|
+
"(Class: <Object>)") {
|
788
|
+
assert_in_delta(object, 0.4, 0.1)
|
789
|
+
}
|
790
|
+
check_fails("The delta should not be negative.\n" +
|
791
|
+
"<-0.1> expected to be\n>=\n<0.0>.") {
|
587
792
|
assert_in_delta(0.5, 0.4, -0.1, "message")
|
588
793
|
}
|
589
794
|
end
|
@@ -675,6 +880,190 @@ Message: <"Error">
|
|
675
880
|
end
|
676
881
|
end
|
677
882
|
|
883
|
+
def test_assert_compare
|
884
|
+
check_nothing_fails do
|
885
|
+
assert_compare(1.4, "<", 10.0)
|
886
|
+
end
|
887
|
+
|
888
|
+
check_nothing_fails do
|
889
|
+
assert_compare(2, "<=", 2)
|
890
|
+
end
|
891
|
+
|
892
|
+
check_nothing_fails do
|
893
|
+
assert_compare(14, ">=", 10.0)
|
894
|
+
end
|
895
|
+
|
896
|
+
check_nothing_fails do
|
897
|
+
assert_compare(14, ">", 13.9)
|
898
|
+
end
|
899
|
+
|
900
|
+
expected_message = <<-EOM
|
901
|
+
<15> < <10> should be true
|
902
|
+
<15> expected less than
|
903
|
+
<10>.
|
904
|
+
EOM
|
905
|
+
check_fails(expected_message.chomp) do
|
906
|
+
assert_compare(15, "<", 10)
|
907
|
+
end
|
908
|
+
|
909
|
+
expected_message = <<-EOM
|
910
|
+
<15> <= <10> should be true
|
911
|
+
<15> expected less than or equal to
|
912
|
+
<10>.
|
913
|
+
EOM
|
914
|
+
check_fails(expected_message.chomp) do
|
915
|
+
assert_compare(15, "<=", 10)
|
916
|
+
end
|
917
|
+
|
918
|
+
expected_message = <<-EOM
|
919
|
+
<10> > <15> should be true
|
920
|
+
<10> expected greater than
|
921
|
+
<15>.
|
922
|
+
EOM
|
923
|
+
check_fails(expected_message.chomp) do
|
924
|
+
assert_compare(10, ">", 15)
|
925
|
+
end
|
926
|
+
|
927
|
+
expected_message = <<-EOM
|
928
|
+
<10> >= <15> should be true
|
929
|
+
<10> expected greater than or equal to
|
930
|
+
<15>.
|
931
|
+
EOM
|
932
|
+
check_fails(expected_message.chomp) do
|
933
|
+
assert_compare(10, ">=", 15)
|
934
|
+
end
|
935
|
+
end
|
936
|
+
|
937
|
+
def test_assert_fail_assertion
|
938
|
+
check_nothing_fails do
|
939
|
+
assert_fail_assertion do
|
940
|
+
flunk
|
941
|
+
end
|
942
|
+
end
|
943
|
+
|
944
|
+
check_fails("Failed assertion was expected.") do
|
945
|
+
assert_fail_assertion do
|
946
|
+
end
|
947
|
+
end
|
948
|
+
end
|
949
|
+
|
950
|
+
def test_assert_raise_message
|
951
|
+
check_nothing_fails do
|
952
|
+
assert_raise_message("Raise!") do
|
953
|
+
raise "Raise!"
|
954
|
+
end
|
955
|
+
end
|
956
|
+
|
957
|
+
check_nothing_fails do
|
958
|
+
assert_raise_message("Raise!") do
|
959
|
+
raise Exception, "Raise!"
|
960
|
+
end
|
961
|
+
end
|
962
|
+
|
963
|
+
check_nothing_fails do
|
964
|
+
assert_raise_message(/raise/i) do
|
965
|
+
raise "Raise!"
|
966
|
+
end
|
967
|
+
end
|
968
|
+
|
969
|
+
expected_message = <<-EOM
|
970
|
+
<"Expected message"> exception message expected but was
|
971
|
+
<"Actual message">.
|
972
|
+
EOM
|
973
|
+
check_fails(expected_message.chomp) do
|
974
|
+
assert_raise_message("Expected message") do
|
975
|
+
raise "Actual message"
|
976
|
+
end
|
977
|
+
end
|
978
|
+
|
979
|
+
expected_message = <<-EOM
|
980
|
+
<"Expected message"> exception message expected but none was thrown.
|
981
|
+
EOM
|
982
|
+
check_fails(expected_message.chomp) do
|
983
|
+
assert_raise_message("Expected message") do
|
984
|
+
end
|
985
|
+
end
|
986
|
+
end
|
987
|
+
|
988
|
+
def test_assert_raise_kind_of
|
989
|
+
check_nothing_fails(true) do
|
990
|
+
assert_raise_kind_of(SystemCallError) do
|
991
|
+
raise Errno::EACCES
|
992
|
+
end
|
993
|
+
end
|
994
|
+
|
995
|
+
expected_message = <<-EOM
|
996
|
+
<SystemCallError> family exception expected but was
|
997
|
+
Class: <RuntimeError>
|
998
|
+
Message: <"XXX">
|
999
|
+
---Backtrace---
|
1000
|
+
EOM
|
1001
|
+
check_fails(/\A#{Regexp.escape(expected_message)}(?m).+\z/) do
|
1002
|
+
assert_raise_kind_of(SystemCallError) do
|
1003
|
+
raise RuntimeError, "XXX"
|
1004
|
+
end
|
1005
|
+
end
|
1006
|
+
end
|
1007
|
+
|
1008
|
+
def test_assert_const_defined
|
1009
|
+
check_nothing_fails do
|
1010
|
+
assert_const_defined(Test, :Unit)
|
1011
|
+
end
|
1012
|
+
|
1013
|
+
check_nothing_fails do
|
1014
|
+
assert_const_defined(Test, "Unit")
|
1015
|
+
end
|
1016
|
+
|
1017
|
+
check_fails("<Test>.const_defined?(<:Nonexistence>) expected.") do
|
1018
|
+
assert_const_defined(Test, :Nonexistence)
|
1019
|
+
end
|
1020
|
+
end
|
1021
|
+
|
1022
|
+
def test_assert_not_const_defined
|
1023
|
+
check_nothing_fails do
|
1024
|
+
assert_not_const_defined(Test, :Nonexistence)
|
1025
|
+
end
|
1026
|
+
|
1027
|
+
check_fails("!<Test>.const_defined?(<:Unit>) expected.") do
|
1028
|
+
assert_not_const_defined(Test, :Unit)
|
1029
|
+
end
|
1030
|
+
|
1031
|
+
check_fails("!<Test>.const_defined?(<\"Unit\">) expected.") do
|
1032
|
+
assert_not_const_defined(Test, "Unit")
|
1033
|
+
end
|
1034
|
+
end
|
1035
|
+
|
1036
|
+
def test_assert_predicate
|
1037
|
+
check_nothing_fails do
|
1038
|
+
assert_predicate([], :empty?)
|
1039
|
+
end
|
1040
|
+
|
1041
|
+
check_fails("<[1]>.empty? is true value expected but was\n<false>") do
|
1042
|
+
assert_predicate([1], :empty?)
|
1043
|
+
end
|
1044
|
+
|
1045
|
+
check_fails("<[1]>.respond_to?(:nonexistent?) expected\n" +
|
1046
|
+
"(Class: <Array>)") do
|
1047
|
+
assert_predicate([1], :nonexistent?)
|
1048
|
+
end
|
1049
|
+
end
|
1050
|
+
|
1051
|
+
def test_assert_not_predicate
|
1052
|
+
check_nothing_fails do
|
1053
|
+
assert_not_predicate([1], :empty?)
|
1054
|
+
end
|
1055
|
+
|
1056
|
+
check_fails("<[]>.empty? is false value expected but was\n<true>") do
|
1057
|
+
assert_not_predicate([], :empty?)
|
1058
|
+
end
|
1059
|
+
|
1060
|
+
check_fails("<[]>.respond_to?(:nonexistent?) expected\n" +
|
1061
|
+
"(Class: <Array>)") do
|
1062
|
+
assert_not_predicate([], :nonexistent?)
|
1063
|
+
end
|
1064
|
+
end
|
1065
|
+
|
1066
|
+
private
|
678
1067
|
def add_failure(message, location=caller)
|
679
1068
|
unless @catch_assertions
|
680
1069
|
super
|
@@ -4,9 +4,11 @@ module TestUnitTestUtil
|
|
4
4
|
assert_equal(expected, faults.collect {|fault| fault.message})
|
5
5
|
end
|
6
6
|
|
7
|
-
def
|
7
|
+
def _run_test(test_case, name)
|
8
8
|
result = Test::Unit::TestResult.new
|
9
|
-
test_case.new(name)
|
9
|
+
test = test_case.new(name)
|
10
|
+
yield(test) if block_given?
|
11
|
+
test.run(result) {}
|
10
12
|
result
|
11
13
|
end
|
12
14
|
end
|
@@ -4,7 +4,7 @@ class TestUnitUIMediator < Test::Unit::TestCase
|
|
4
4
|
def test_run_suite_with_interrupt_exception
|
5
5
|
test_case = Class.new(Test::Unit::TestCase) do
|
6
6
|
def test_raise_interrupt
|
7
|
-
raise Interrupt
|
7
|
+
raise Interrupt, "from test"
|
8
8
|
end
|
9
9
|
end
|
10
10
|
mediator = Test::Unit::UI::TestRunnerMediator.new(test_case.suite)
|