activeldap 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +17 -0
- data/README +7 -1
- data/Rakefile +2 -1
- data/benchmark/bench-al.rb +3 -3
- data/examples/al-admin/app/helpers/users_helper.rb +1 -1
- data/examples/al-admin/config/environment.rb +4 -3
- data/examples/al-admin/config/initializers/gettext.rb +1 -0
- data/examples/al-admin/config/session_secret.txt +1 -1
- data/examples/al-admin/po/al-admin.pot +344 -0
- data/examples/al-admin/public/images/active-ldap.png +0 -0
- data/examples/al-admin/vendor/locale_rails/.gitignore +6 -0
- data/examples/al-admin/vendor/locale_rails/COPYING +56 -0
- data/examples/al-admin/vendor/locale_rails/ChangeLog +35 -0
- data/examples/al-admin/vendor/locale_rails/README.rdoc +62 -0
- data/examples/al-admin/vendor/locale_rails/Rakefile +73 -0
- data/examples/al-admin/vendor/locale_rails/lib/locale_rails.rb +18 -0
- data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_controller.rb +15 -0
- data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_controller/base.rb +82 -0
- data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_controller/caching.rb +51 -0
- data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_controller/test_process.rb +44 -0
- data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_view.rb +53 -0
- data/examples/al-admin/vendor/locale_rails/lib/locale_rails/i18n.rb +67 -0
- data/examples/al-admin/vendor/locale_rails/lib/locale_rails/version.rb +4 -0
- data/examples/al-admin/vendor/locale_rails/sample/README +22 -0
- data/examples/al-admin/vendor/locale_rails/sample/Rakefile +10 -0
- data/examples/al-admin/vendor/locale_rails/sample/app/controllers/application.rb +42 -0
- data/examples/al-admin/vendor/locale_rails/sample/app/controllers/samples_controller.rb +30 -0
- data/examples/al-admin/vendor/locale_rails/sample/app/helpers/application_helper.rb +3 -0
- data/examples/al-admin/vendor/locale_rails/sample/app/views/layouts/samples.html.erb +20 -0
- data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/_part.html.erb +68 -0
- data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/_part_nl.html.erb +2 -0
- data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/cached_action.html.erb +6 -0
- data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/index.html.erb +33 -0
- data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/index.pt.html.erb +16 -0
- data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/index_uz_UZ.html.erb +16 -0
- data/examples/al-admin/vendor/locale_rails/sample/config/boot.rb +109 -0
- data/examples/al-admin/vendor/locale_rails/sample/config/environment.rb +25 -0
- data/examples/al-admin/vendor/locale_rails/sample/config/environments/development.rb +17 -0
- data/examples/al-admin/vendor/locale_rails/sample/config/environments/production.rb +24 -0
- data/examples/al-admin/vendor/locale_rails/sample/config/environments/test.rb +22 -0
- data/examples/al-admin/vendor/locale_rails/sample/config/initializers/inflections.rb +10 -0
- data/examples/al-admin/vendor/locale_rails/sample/config/initializers/mime_types.rb +5 -0
- data/examples/al-admin/vendor/locale_rails/sample/config/initializers/new_rails_defaults.rb +17 -0
- data/examples/al-admin/vendor/locale_rails/sample/config/locales/en.yml +2 -0
- data/examples/al-admin/vendor/locale_rails/sample/config/locales/ja.yml +2 -0
- data/examples/al-admin/vendor/locale_rails/sample/config/routes.rb +13 -0
- data/examples/al-admin/vendor/locale_rails/sample/db/schema.rb +10 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/404.html +30 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/422.html +30 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/500.html +33 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/dispatch.cgi +10 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/dispatch.fcgi +24 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/dispatch.rb +10 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/favicon.ico +0 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/images/rails.png +0 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/application.js +2 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/controls.js +963 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/dragdrop.js +972 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/effects.js +1120 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/prototype.js +4221 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/robots.txt +5 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/stylesheets/locale.css +81 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/stylesheets/scaffold.css +74 -0
- data/examples/al-admin/vendor/locale_rails/sample/script/about +4 -0
- data/examples/al-admin/vendor/locale_rails/sample/script/console +3 -0
- data/examples/al-admin/vendor/locale_rails/sample/script/dbconsole +3 -0
- data/examples/al-admin/vendor/locale_rails/sample/script/destroy +3 -0
- data/examples/al-admin/vendor/locale_rails/sample/script/generate +3 -0
- data/examples/al-admin/vendor/locale_rails/sample/script/performance/benchmarker +3 -0
- data/examples/al-admin/vendor/locale_rails/sample/script/performance/profiler +3 -0
- data/examples/al-admin/vendor/locale_rails/sample/script/performance/request +3 -0
- data/examples/al-admin/vendor/locale_rails/sample/script/plugin +3 -0
- data/examples/al-admin/vendor/locale_rails/sample/script/process/inspector +3 -0
- data/examples/al-admin/vendor/locale_rails/sample/script/process/reaper +3 -0
- data/examples/al-admin/vendor/locale_rails/sample/script/process/spawner +3 -0
- data/examples/al-admin/vendor/locale_rails/sample/script/runner +3 -0
- data/examples/al-admin/vendor/locale_rails/sample/script/server +3 -0
- data/examples/al-admin/vendor/locale_rails/sample/test/performance/browsing_test.rb +9 -0
- data/examples/al-admin/vendor/locale_rails/sample/test/test_helper.rb +38 -0
- data/examples/al-admin/vendor/locale_rails/test/README +243 -0
- data/examples/al-admin/vendor/locale_rails/test/Rakefile +10 -0
- data/examples/al-admin/vendor/locale_rails/test/app/controllers/application_controller.rb +10 -0
- data/examples/al-admin/vendor/locale_rails/test/app/controllers/articles_controller.rb +17 -0
- data/examples/al-admin/vendor/locale_rails/test/app/helpers/application_helper.rb +3 -0
- data/examples/al-admin/vendor/locale_rails/test/app/views/articles/index.html.erb +1 -0
- data/examples/al-admin/vendor/locale_rails/test/app/views/articles/index_de.html.erb +1 -0
- data/examples/al-admin/vendor/locale_rails/test/app/views/articles/index_fr_FR.html.erb +1 -0
- data/examples/al-admin/vendor/locale_rails/test/app/views/articles/index_ja.html.erb +1 -0
- data/examples/al-admin/vendor/locale_rails/test/app/views/articles/list.html.erb +1 -0
- data/examples/al-admin/vendor/locale_rails/test/app/views/articles/show.html.erb +0 -0
- data/examples/al-admin/vendor/locale_rails/test/app/views/articles/show.js.rjs +0 -0
- data/examples/al-admin/vendor/locale_rails/test/config/boot.rb +110 -0
- data/examples/al-admin/vendor/locale_rails/test/config/environment.rb +42 -0
- data/examples/al-admin/vendor/locale_rails/test/config/environments/development.rb +17 -0
- data/examples/al-admin/vendor/locale_rails/test/config/environments/production.rb +28 -0
- data/examples/al-admin/vendor/locale_rails/test/config/environments/test.rb +35 -0
- data/examples/al-admin/vendor/locale_rails/test/config/initializers/backtrace_silencers.rb +7 -0
- data/examples/al-admin/vendor/locale_rails/test/config/initializers/inflections.rb +10 -0
- data/examples/al-admin/vendor/locale_rails/test/config/initializers/mime_types.rb +5 -0
- data/examples/al-admin/vendor/locale_rails/test/config/initializers/new_rails_defaults.rb +19 -0
- data/examples/al-admin/vendor/locale_rails/test/config/initializers/session_store.rb +15 -0
- data/examples/al-admin/vendor/locale_rails/test/config/locales/en.yml +5 -0
- data/examples/al-admin/vendor/locale_rails/test/config/routes.rb +46 -0
- data/examples/al-admin/vendor/locale_rails/test/db/schema.rb +0 -0
- data/examples/al-admin/vendor/locale_rails/test/public/404.html +30 -0
- data/examples/al-admin/vendor/locale_rails/test/public/422.html +30 -0
- data/examples/al-admin/vendor/locale_rails/test/public/500.html +30 -0
- data/examples/al-admin/vendor/locale_rails/test/public/favicon.ico +0 -0
- data/examples/al-admin/vendor/locale_rails/test/public/images/rails.png +0 -0
- data/examples/al-admin/vendor/locale_rails/test/public/index.html +275 -0
- data/examples/al-admin/vendor/locale_rails/test/public/javascripts/application.js +2 -0
- data/examples/al-admin/vendor/locale_rails/test/public/javascripts/controls.js +963 -0
- data/examples/al-admin/vendor/locale_rails/test/public/javascripts/dragdrop.js +973 -0
- data/examples/al-admin/vendor/locale_rails/test/public/javascripts/effects.js +1128 -0
- data/examples/al-admin/vendor/locale_rails/test/public/javascripts/prototype.js +4320 -0
- data/examples/al-admin/vendor/locale_rails/test/public/robots.txt +5 -0
- data/examples/al-admin/vendor/locale_rails/test/script/about +4 -0
- data/examples/al-admin/vendor/locale_rails/test/script/console +3 -0
- data/examples/al-admin/vendor/locale_rails/test/script/dbconsole +3 -0
- data/examples/al-admin/vendor/locale_rails/test/script/destroy +3 -0
- data/examples/al-admin/vendor/locale_rails/test/script/generate +3 -0
- data/examples/al-admin/vendor/locale_rails/test/script/performance/benchmarker +3 -0
- data/examples/al-admin/vendor/locale_rails/test/script/performance/profiler +3 -0
- data/examples/al-admin/vendor/locale_rails/test/script/plugin +3 -0
- data/examples/al-admin/vendor/locale_rails/test/script/runner +3 -0
- data/examples/al-admin/vendor/locale_rails/test/script/server +3 -0
- data/examples/al-admin/vendor/locale_rails/test/test/functional/articles_controller_test.rb +161 -0
- data/examples/al-admin/vendor/locale_rails/test/test/performance/browsing_test.rb +9 -0
- data/examples/al-admin/vendor/locale_rails/test/test/test_helper.rb +38 -0
- data/lib/active_ldap.rb +9 -4
- data/lib/active_ldap/adapter/base.rb +3 -3
- data/lib/active_ldap/adapter/jndi.rb +1 -1
- data/lib/active_ldap/adapter/jndi_connection.rb +1 -3
- data/lib/active_ldap/adapter/ldap.rb +11 -11
- data/lib/active_ldap/adapter/ldap_ext.rb +25 -3
- data/lib/active_ldap/adapter/net_ldap.rb +9 -2
- data/lib/active_ldap/association/collection.rb +14 -2
- data/lib/active_ldap/base.rb +13 -5
- data/lib/active_ldap/configuration.rb +1 -0
- data/lib/active_ldap/ldap_error.rb +3 -3
- data/lib/active_ldap/ldif.rb +1 -1
- data/lib/active_ldap/operations.rb +2 -0
- data/lib/active_ldap/schema/syntaxes.rb +2 -2
- data/lib/active_ldap/validations.rb +37 -26
- data/lib/active_ldap/xml.rb +2 -0
- data/po/active-ldap.pot +38 -58
- data/test-unit/COPYING +56 -0
- data/test-unit/GPL +340 -0
- data/test-unit/History.txt +65 -3
- data/test-unit/Manifest.txt +5 -0
- data/test-unit/PSFL +271 -0
- data/test-unit/README.txt +6 -1
- data/test-unit/lib/test/unit.rb +6 -1
- data/test-unit/lib/test/unit/assertions.rb +129 -13
- data/test-unit/lib/test/unit/autorunner.rb +21 -16
- data/test-unit/lib/test/unit/collector.rb +1 -8
- data/test-unit/lib/test/unit/collector/dir.rb +1 -1
- data/test-unit/lib/test/unit/collector/load.rb +15 -7
- data/test-unit/lib/test/unit/color-scheme.rb +6 -2
- data/test-unit/lib/test/unit/diff.rb +17 -1
- data/test-unit/lib/test/unit/error.rb +4 -0
- data/test-unit/lib/test/unit/failure.rb +4 -0
- data/test-unit/lib/test/unit/notification.rb +8 -4
- data/test-unit/lib/test/unit/omission.rb +4 -0
- data/test-unit/lib/test/unit/pending.rb +4 -0
- data/test-unit/lib/test/unit/priority.rb +2 -3
- data/test-unit/lib/test/unit/testcase.rb +18 -7
- data/test-unit/lib/test/unit/ui/console/testrunner.rb +5 -3
- data/test-unit/lib/test/unit/util/backtracefilter.rb +1 -0
- data/test-unit/lib/test/unit/util/output.rb +31 -0
- data/test-unit/lib/test/unit/version.rb +1 -1
- data/test-unit/test/collector/test-descendant.rb +2 -4
- data/test-unit/test/collector/test-load.rb +121 -8
- data/test-unit/test/collector/test_objectspace.rb +7 -5
- data/test-unit/test/test-color-scheme.rb +4 -2
- data/test-unit/test/test-testcase.rb +48 -38
- data/test-unit/test/test_assertions.rb +87 -5
- data/test-unit/test/util/test-output.rb +11 -0
- data/test/al-test-utils.rb +6 -1
- data/test/fixtures/lower_case_object_class_schema.rb +802 -0
- data/test/test_associations.rb +20 -1
- data/test/test_base.rb +50 -3
- data/test/test_ldif.rb +10 -1
- data/test/test_syntax.rb +12 -0
- data/test/test_validation.rb +0 -2
- metadata +225 -56
@@ -66,7 +66,7 @@ class TestUnitCollectorDescendant < Test::Unit::TestCase
|
|
66
66
|
collector.filter = [Proc.new {false}, Proc.new {true}]
|
67
67
|
end
|
68
68
|
|
69
|
-
assert_collect(
|
69
|
+
assert_collect(empty_suite) do |collector|
|
70
70
|
collector.filter = [Proc.new {true}, Proc.new {false}]
|
71
71
|
end
|
72
72
|
|
@@ -90,13 +90,11 @@ class TestUnitCollectorDescendant < Test::Unit::TestCase
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
-
expected = empty_suite
|
94
93
|
suite1 = Test::Unit::TestSuite.new(@test_case1.name)
|
95
94
|
suite1 << @test_case1.new("test_1")
|
96
95
|
suite2 = Test::Unit::TestSuite.new(@test_case2.name)
|
97
96
|
suite2 << @test_case2.new("test_0")
|
98
|
-
|
99
|
-
assert_collect(expected) do |collector|
|
97
|
+
assert_collect(empty_suite) do |collector|
|
100
98
|
filters = [Proc.new {|test| test.method_name == 'test_1' ? true : nil},
|
101
99
|
Proc.new {|test| test.method_name == 'test_0' ? true : nil},
|
102
100
|
Proc.new {false}]
|
@@ -13,8 +13,9 @@ class TestUnitCollectorLoad < Test::Unit::TestCase
|
|
13
13
|
::Object.const_set(@temporary_test_cases_module_name, Module.new)
|
14
14
|
|
15
15
|
@test_dir = Pathname(Dir.tmpdir) + "test-unit"
|
16
|
-
@
|
17
|
-
@test_dir
|
16
|
+
@extra_test_dir = Pathname(Dir.tmpdir) + "test-unit-extra"
|
17
|
+
ensure_clean_directory(@test_dir)
|
18
|
+
ensure_clean_directory(@extra_test_dir)
|
18
19
|
end
|
19
20
|
|
20
21
|
setup
|
@@ -196,6 +197,72 @@ EOT
|
|
196
197
|
end
|
197
198
|
end
|
198
199
|
|
200
|
+
setup
|
201
|
+
def setup_sub_git_test_cases
|
202
|
+
@sub_git_test_dir = @sub_test_dir + ".git"
|
203
|
+
@sub_git_test_dir.mkpath
|
204
|
+
|
205
|
+
@sub_git_test_case11 = @sub_git_test_dir + "test_case11.rb"
|
206
|
+
|
207
|
+
@sub_git_test_case11.open("w") do |test_case|
|
208
|
+
test_case.puts(<<-EOT)
|
209
|
+
module #{@temporary_test_cases_module_name}
|
210
|
+
class SubGitTestCase11 < Test::Unit::TestCase
|
211
|
+
def test11
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
EOT
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
setup
|
220
|
+
def setup_extra_top_level_test_cases
|
221
|
+
@test_cases12 = @extra_test_dir + "test_cases12.rb"
|
222
|
+
@test_cases12.open("w") do |test_case|
|
223
|
+
test_case.puts(<<-EOT)
|
224
|
+
module #{@temporary_test_cases_module_name}
|
225
|
+
class TestCase121 < Test::Unit::TestCase
|
226
|
+
def test121_1
|
227
|
+
end
|
228
|
+
|
229
|
+
def test121_2
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
class TestCase122 < Test::Unit::TestCase
|
234
|
+
def test122_1
|
235
|
+
end
|
236
|
+
|
237
|
+
def test122_2
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
EOT
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
setup
|
246
|
+
def setup_sub_level_extra_test_cases
|
247
|
+
@sub_extra_test_dir = @extra_test_dir + "sub"
|
248
|
+
@sub_extra_test_dir.mkpath
|
249
|
+
|
250
|
+
@cases13_test = @sub_extra_test_dir + "13cases_test.rb"
|
251
|
+
@cases13_test.open("w") do |test_case|
|
252
|
+
test_case.puts(<<-EOT)
|
253
|
+
module #{@temporary_test_cases_module_name}
|
254
|
+
class SubTestCase13 < Test::Unit::TestCase
|
255
|
+
def test13_1
|
256
|
+
end
|
257
|
+
|
258
|
+
def test13_2
|
259
|
+
end
|
260
|
+
end
|
261
|
+
end
|
262
|
+
EOT
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
199
266
|
def teardown
|
200
267
|
@test_dir.rmtree if @test_dir.exist?
|
201
268
|
::Object.send(:remove_const, @temporary_test_cases_module_name)
|
@@ -212,6 +279,21 @@ EOT
|
|
212
279
|
@sub_test_dir.to_s)
|
213
280
|
end
|
214
281
|
|
282
|
+
def test_simple_collect_test_suffix
|
283
|
+
assert_collect([:suite, {:name => @extra_test_dir.basename.to_s},
|
284
|
+
[:suite, {:name => _test_case_name("TestCase121")},
|
285
|
+
[:test, {:name => "test121_1"}],
|
286
|
+
[:test, {:name => "test121_2"}]],
|
287
|
+
[:suite, {:name => _test_case_name("TestCase122")},
|
288
|
+
[:test, {:name => "test122_1"}],
|
289
|
+
[:test, {:name => "test122_2"}]],
|
290
|
+
[:suite, {:name => @sub_extra_test_dir.basename.to_s},
|
291
|
+
[:suite, {:name => _test_case_name("SubTestCase13")},
|
292
|
+
[:test, {:name => "test13_1"}],
|
293
|
+
[:test, {:name => "test13_2"}]]]],
|
294
|
+
@extra_test_dir.to_s)
|
295
|
+
end
|
296
|
+
|
215
297
|
def test_multilevel_collect
|
216
298
|
assert_collect([:suite, {:name => "."},
|
217
299
|
[:suite, {:name => _test_case_name("TestCase1")},
|
@@ -234,13 +316,39 @@ EOT
|
|
234
316
|
end
|
235
317
|
|
236
318
|
def test_collect_file
|
237
|
-
assert_collect([:suite, {:name =>
|
238
|
-
[:
|
239
|
-
|
240
|
-
[:test, {:name => "test1_2"}]]],
|
319
|
+
assert_collect([:suite, {:name => _test_case_name("TestCase1")},
|
320
|
+
[:test, {:name => "test1_1"}],
|
321
|
+
[:test, {:name => "test1_2"}]],
|
241
322
|
@test_case1.to_s)
|
323
|
+
end
|
242
324
|
|
243
|
-
|
325
|
+
def test_collect_file_no_pattern_match_file_name
|
326
|
+
assert_collect([:suite, {:name => _test_case_name("NoLoadSubTestCase5")},
|
327
|
+
[:test, {:name => "test5_1"}],
|
328
|
+
[:test, {:name => "test5_2"}]],
|
329
|
+
@no_load_sub_test_case5.to_s)
|
330
|
+
end
|
331
|
+
|
332
|
+
def test_collect_file_test_cases
|
333
|
+
assert_collect([:suite, {:name => "[#{@test_cases12}]"},
|
334
|
+
[:suite, {:name => _test_case_name("TestCase121")},
|
335
|
+
[:test, {:name => "test121_1"}],
|
336
|
+
[:test, {:name => "test121_2"}]],
|
337
|
+
[:suite, {:name => _test_case_name("TestCase122")},
|
338
|
+
[:test, {:name => "test122_1"}],
|
339
|
+
[:test, {:name => "test122_2"}]]],
|
340
|
+
@test_cases12.to_s)
|
341
|
+
end
|
342
|
+
|
343
|
+
def test_collect_files
|
344
|
+
assert_collect([:suite,
|
345
|
+
{:name => "[#{@test_case1}, #{@test_case2}]"},
|
346
|
+
[:suite, {:name => _test_case_name("TestCase1")},
|
347
|
+
[:test, {:name => "test1_1"}],
|
348
|
+
[:test, {:name => "test1_2"}]],
|
349
|
+
[:suite, {:name => _test_case_name("TestCase2")},
|
350
|
+
[:test, {:name => "test2"}]]],
|
351
|
+
@test_case1.to_s, @test_case2.to_s)
|
244
352
|
end
|
245
353
|
|
246
354
|
def test_nil_pattern
|
@@ -278,7 +386,7 @@ EOT
|
|
278
386
|
[:test, {:name => "test4_2"}]],
|
279
387
|
[:suite, {:name => _test_case_name("SubTestCase6")},
|
280
388
|
[:test, {:name => "test6"}]]],
|
281
|
-
|
389
|
+
[:suite, {:name => @sub2_test_dir.basename.to_s},
|
282
390
|
[:suite, {:name => _test_case_name("Sub2TestCase8")},
|
283
391
|
[:test, {:name => "test8_1"}],
|
284
392
|
[:test, {:name => "test8_2"}]],
|
@@ -299,6 +407,11 @@ EOT
|
|
299
407
|
end
|
300
408
|
end
|
301
409
|
|
410
|
+
def ensure_clean_directory(directory)
|
411
|
+
directory.rmtree if directory.exist?
|
412
|
+
directory.mkpath
|
413
|
+
end
|
414
|
+
|
302
415
|
def keep_required_files
|
303
416
|
required_files = $".dup
|
304
417
|
yield
|
@@ -72,7 +72,7 @@ module Test
|
|
72
72
|
assert_equal(empty_suite, @c.collect)
|
73
73
|
|
74
74
|
@c.filter = [proc{true}, proc{false}]
|
75
|
-
assert_equal(
|
75
|
+
assert_equal(empty_suite, @c.collect)
|
76
76
|
|
77
77
|
@c.filter = [proc{nil}, proc{false}]
|
78
78
|
assert_equal(empty_suite, @c.collect)
|
@@ -87,10 +87,12 @@ module Test
|
|
87
87
|
assert_equal(expected, @c.collect)
|
88
88
|
|
89
89
|
expected = TestSuite.new(ObjectSpace::NAME)
|
90
|
-
|
91
|
-
|
92
|
-
@c.filter = [proc{|t| t.method_name == 'test_1' ? true : nil},
|
93
|
-
|
90
|
+
TestSuite.new(@tc1.name) << @tc1.new('test_1')
|
91
|
+
TestSuite.new(@tc2.name) << @tc2.new('test_0')
|
92
|
+
@c.filter = [proc{|t| t.method_name == 'test_1' ? true : nil},
|
93
|
+
proc{|t| t.method_name == 'test_0' ? true : nil},
|
94
|
+
proc{false}]
|
95
|
+
assert_equal(empty_suite, @c.collect)
|
94
96
|
end
|
95
97
|
end
|
96
98
|
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
class TestUnitColorScheme < Test::Unit::TestCase
|
2
2
|
def test_default
|
3
3
|
assert_equal({
|
4
|
-
"success" => color("green", :
|
5
|
-
|
4
|
+
"success" => color("green", :foreground => false) +
|
5
|
+
color("white", :bold => true),
|
6
|
+
"failure" => color("red", :foreground => false) +
|
7
|
+
color("white", :bold => true),
|
6
8
|
"pending" => color("magenta", :bold => true),
|
7
9
|
"omission" => color("blue", :bold => true),
|
8
10
|
"notification" => color("cyan", :bold => true),
|
@@ -7,6 +7,7 @@ require 'test/unit'
|
|
7
7
|
module Test
|
8
8
|
module Unit
|
9
9
|
class TestTestCase < TestCase
|
10
|
+
self.test_order = :random
|
10
11
|
def test_creation
|
11
12
|
tc = Class.new(TestCase) do
|
12
13
|
def test_with_arguments(arg1, arg2)
|
@@ -469,52 +470,68 @@ module Test
|
|
469
470
|
end
|
470
471
|
|
471
472
|
def test_defined_order
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
end
|
473
|
+
test_case = Class.new(Test::Unit::TestCase) do
|
474
|
+
def test_z
|
475
|
+
end
|
476
476
|
|
477
|
-
|
478
|
-
|
477
|
+
def test_1
|
478
|
+
end
|
479
479
|
|
480
|
-
|
481
|
-
end
|
480
|
+
def test_a
|
482
481
|
end
|
482
|
+
end
|
483
483
|
|
484
|
-
|
485
|
-
|
484
|
+
assert_equal(["test_1", "test_a", "test_z"],
|
485
|
+
test_case.suite.tests.collect {|test| test.method_name})
|
486
486
|
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
end
|
487
|
+
test_case.test_order = :defined
|
488
|
+
assert_equal(["test_z", "test_1", "test_a"],
|
489
|
+
test_case.suite.tests.collect {|test| test.method_name})
|
491
490
|
end
|
492
491
|
|
493
492
|
def test_declarative_style
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
end
|
493
|
+
test_case = Class.new(Test::Unit::TestCase) do
|
494
|
+
test "declarative style test definition" do
|
495
|
+
end
|
498
496
|
|
499
|
-
|
500
|
-
|
497
|
+
test "include parenthesis" do
|
498
|
+
end
|
501
499
|
|
502
|
-
|
503
|
-
end
|
500
|
+
test "1 + 2 = 3" do
|
504
501
|
end
|
502
|
+
end
|
505
503
|
|
506
|
-
|
504
|
+
test_case.test_order = :defined
|
507
505
|
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
506
|
+
assert_equal(["test_declarative_style_test_definition",
|
507
|
+
"test_include_parenthesis",
|
508
|
+
"test_1_2_3"],
|
509
|
+
test_case.suite.tests.collect {|test| test.method_name})
|
510
|
+
|
511
|
+
assert_equal(["declarative style test definition",
|
512
|
+
"include parenthesis",
|
513
|
+
"1 + 2 = 3"],
|
514
|
+
test_case.suite.tests.collect {|test| test.description})
|
515
|
+
end
|
516
|
+
|
517
|
+
def test_redefine_method
|
518
|
+
test_case = Class.new(Test::Unit::TestCase) do
|
519
|
+
def test_name
|
520
|
+
end
|
521
|
+
alias_method :test_name2, :test_name
|
512
522
|
|
513
|
-
|
514
|
-
|
515
|
-
"1 + 2 = 3"],
|
516
|
-
test_case.suite.tests.collect {|test| test.description})
|
523
|
+
def test_name
|
524
|
+
end
|
517
525
|
end
|
526
|
+
|
527
|
+
suite = test_case.suite
|
528
|
+
assert_equal(["test_name", "test_name2"],
|
529
|
+
suite.tests.collect {|test| test.method_name})
|
530
|
+
result = TestResult.new
|
531
|
+
suite.run(result) {}
|
532
|
+
assert_equal("2 tests, 0 assertions, 0 failures, " +
|
533
|
+
"0 errors, 0 pendings, 0 omissions, 1 notifications",
|
534
|
+
result.summary)
|
518
535
|
end
|
519
536
|
|
520
537
|
private
|
@@ -522,13 +539,6 @@ module Test
|
|
522
539
|
add_assertion
|
523
540
|
raise AssertionFailedError.new(message) unless passed
|
524
541
|
end
|
525
|
-
|
526
|
-
def keep_test_order
|
527
|
-
order = TestCase.test_order
|
528
|
-
yield
|
529
|
-
ensure
|
530
|
-
TestCase.test_order = order
|
531
|
-
end
|
532
542
|
end
|
533
543
|
end
|
534
544
|
end
|
@@ -1,6 +1,8 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
1
3
|
# Author:: Nathaniel Talbott.
|
2
4
|
# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
|
3
|
-
# Copyright (c) 2009 Kouhei Sutou.
|
5
|
+
# Copyright (c) 2009-2010 Kouhei Sutou. All rights reserved.
|
4
6
|
# License:: Ruby license.
|
5
7
|
|
6
8
|
require 'test/unit'
|
@@ -275,6 +277,57 @@ EOM
|
|
275
277
|
end
|
276
278
|
end
|
277
279
|
|
280
|
+
def test_assert_equal_with_max_diff_target_string_size
|
281
|
+
key = "TEST_UNIT_MAX_DIFF_TARGET_STRING_SIZE"
|
282
|
+
before_value = ENV[key]
|
283
|
+
ENV[key] = "100"
|
284
|
+
begin
|
285
|
+
message = <<-EOM.chomp
|
286
|
+
<#{("a\n" + "x" * 97).inspect}> expected but was
|
287
|
+
<#{"x".inspect}>.
|
288
|
+
|
289
|
+
diff:
|
290
|
+
+ x
|
291
|
+
- a
|
292
|
+
- #{"x" * 97}
|
293
|
+
|
294
|
+
folded diff:
|
295
|
+
+ x
|
296
|
+
- a
|
297
|
+
#{(["- " + ("x" * 78)]).join("\n")}
|
298
|
+
- #{"x" * 19}
|
299
|
+
EOM
|
300
|
+
check_fails(message) do
|
301
|
+
assert_equal("a\n" + "x" * 97, "x")
|
302
|
+
end
|
303
|
+
|
304
|
+
message = <<-EOM.chomp
|
305
|
+
<#{("a\n" + "x" * 98).inspect}> expected but was
|
306
|
+
<#{"x".inspect}>.
|
307
|
+
EOM
|
308
|
+
check_fails(message) do
|
309
|
+
assert_equal("a\n" + "x" * 98, "x")
|
310
|
+
end
|
311
|
+
ensure
|
312
|
+
ENV[key] = before_value
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
def test_assert_equal_with_different_encoding
|
317
|
+
utf8_string = "こんにちは"
|
318
|
+
unless utf8_string.respond_to?(:force_encoding)
|
319
|
+
omit("encoding test is for Ruby >= 1.9")
|
320
|
+
end
|
321
|
+
ascii_8bit_string = utf8_string.dup.force_encoding("ascii-8bit")
|
322
|
+
message = <<-EOM.chomp
|
323
|
+
<"こんにちは">("UTF-8") expected but was
|
324
|
+
<#{ascii_8bit_string.inspect}>("ASCII-8BIT").
|
325
|
+
EOM
|
326
|
+
check_fails(message) do
|
327
|
+
assert_equal(utf8_string, ascii_8bit_string)
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
278
331
|
def test_assert_raise_success
|
279
332
|
return_value = nil
|
280
333
|
check_nothing_fails(true) do
|
@@ -775,13 +828,19 @@ EOM
|
|
775
828
|
end
|
776
829
|
assert_in_delta(0.1, float_thing, 0.1)
|
777
830
|
}
|
778
|
-
check_fails("message.\n
|
831
|
+
check_fails("message.\n" +
|
832
|
+
"<0.5> expected but was\n" +
|
833
|
+
"<0.4> (tolerance <0.05>).\n" +
|
834
|
+
"\n" +
|
835
|
+
"Relation:\n" +
|
836
|
+
"<<0.4> < <0.5>-<0.05>(0.45) <= <0.5>+<0.05>(0.55)>") {
|
779
837
|
assert_in_delta(0.5, 0.4, 0.05, "message")
|
780
838
|
}
|
781
839
|
object = Object.new
|
840
|
+
inspected_object = AssertionMessage.convert(object)
|
782
841
|
check_fails("The arguments must respond to to_f; " +
|
783
842
|
"the first float did not.\n" +
|
784
|
-
"<#{
|
843
|
+
"<#{inspected_object}>.respond_to?(:to_f) expected\n" +
|
785
844
|
"(Class: <Object>)") {
|
786
845
|
assert_in_delta(object, 0.4, 0.1)
|
787
846
|
}
|
@@ -1085,17 +1144,40 @@ EOM
|
|
1085
1144
|
assert_alias_method(object, :other, :original_method)
|
1086
1145
|
end
|
1087
1146
|
|
1088
|
-
|
1147
|
+
inspected_object = AssertionMessage.convert(object)
|
1148
|
+
check_fails("<#{inspected_object}>.nonexistent doesn't exist\n" +
|
1089
1149
|
"(Class: <Object>)") do
|
1090
1150
|
assert_alias_method(object, :nonexistent, :original_method)
|
1091
1151
|
end
|
1092
1152
|
|
1093
|
-
check_fails("<#{
|
1153
|
+
check_fails("<#{inspected_object}>.nonexistent doesn't exist\n" +
|
1094
1154
|
"(Class: <Object>)") do
|
1095
1155
|
assert_alias_method(object, :alias_method, :nonexistent)
|
1096
1156
|
end
|
1097
1157
|
end
|
1098
1158
|
|
1159
|
+
def test_assert_path_exist
|
1160
|
+
check_nothing_fails do
|
1161
|
+
assert_path_exist(__FILE__)
|
1162
|
+
end
|
1163
|
+
|
1164
|
+
nonexistent_file = __FILE__ + ".nonexistent"
|
1165
|
+
check_fails("<#{nonexistent_file.inspect}> expected to exist") do
|
1166
|
+
assert_path_exist(nonexistent_file)
|
1167
|
+
end
|
1168
|
+
end
|
1169
|
+
|
1170
|
+
def test_assert_path_not_exist
|
1171
|
+
nonexistent_file = __FILE__ + ".nonexistent"
|
1172
|
+
check_nothing_fails do
|
1173
|
+
assert_path_not_exist(nonexistent_file)
|
1174
|
+
end
|
1175
|
+
|
1176
|
+
check_fails("<#{__FILE__.inspect}> expected to not exist") do
|
1177
|
+
assert_path_not_exist(__FILE__)
|
1178
|
+
end
|
1179
|
+
end
|
1180
|
+
|
1099
1181
|
private
|
1100
1182
|
def add_failure(message, location=caller, options=nil)
|
1101
1183
|
unless @catch_assertions
|