ActiveSambaLdap 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/NEWS.en +40 -0
- data/NEWS.ja +44 -0
- data/README.en +366 -0
- data/README.ja +361 -0
- data/Rakefile +168 -0
- data/bin/asl-groupadd +73 -0
- data/bin/asl-groupadd.help +1 -0
- data/bin/asl-groupdel +61 -0
- data/bin/asl-groupdel.help +1 -0
- data/bin/asl-groupmod +137 -0
- data/bin/asl-groupmod.help +1 -0
- data/bin/asl-groupshow +33 -0
- data/bin/asl-groupshow.help +1 -0
- data/bin/asl-passwd +90 -0
- data/bin/asl-passwd.help +1 -0
- data/bin/asl-populate +101 -0
- data/bin/asl-populate.help +1 -0
- data/bin/asl-purge +26 -0
- data/bin/asl-purge.help +1 -0
- data/bin/asl-samba-computeradd +96 -0
- data/bin/asl-samba-computeradd.help +1 -0
- data/bin/asl-samba-groupadd +57 -0
- data/bin/asl-samba-groupadd.help +1 -0
- data/bin/asl-samba-groupdel +55 -0
- data/bin/asl-samba-groupdel.help +1 -0
- data/bin/asl-samba-groupmod +99 -0
- data/bin/asl-samba-groupmod.help +1 -0
- data/bin/asl-samba-useradd +100 -0
- data/bin/asl-samba-useradd.help +1 -0
- data/bin/asl-samba-userdel +49 -0
- data/bin/asl-samba-userdel.help +1 -0
- data/bin/asl-samba-usermod +94 -0
- data/bin/asl-samba-usermod.help +1 -0
- data/bin/asl-useradd +264 -0
- data/bin/asl-useradd.help +1 -0
- data/bin/asl-userdel +84 -0
- data/bin/asl-userdel.help +1 -0
- data/bin/asl-usermod +335 -0
- data/bin/asl-usermod.help +1 -0
- data/bin/asl-usershow +33 -0
- data/bin/asl-usershow.help +1 -0
- data/lib/active_samba_ldap.rb +42 -0
- data/lib/active_samba_ldap/account_entry.rb +208 -0
- data/lib/active_samba_ldap/base.rb +137 -0
- data/lib/active_samba_ldap/command.rb +100 -0
- data/lib/active_samba_ldap/computer.rb +24 -0
- data/lib/active_samba_ldap/computer_account_entry.rb +34 -0
- data/lib/active_samba_ldap/configuration.rb +333 -0
- data/lib/active_samba_ldap/dc.rb +19 -0
- data/lib/active_samba_ldap/entry.rb +81 -0
- data/lib/active_samba_ldap/get_text_support.rb +12 -0
- data/lib/active_samba_ldap/group.rb +17 -0
- data/lib/active_samba_ldap/group_entry.rb +187 -0
- data/lib/active_samba_ldap/idmap.rb +19 -0
- data/lib/active_samba_ldap/ou.rb +20 -0
- data/lib/active_samba_ldap/populate.rb +257 -0
- data/lib/active_samba_ldap/reloadable.rb +15 -0
- data/lib/active_samba_ldap/samba_account_entry.rb +225 -0
- data/lib/active_samba_ldap/samba_entry.rb +26 -0
- data/lib/active_samba_ldap/samba_group_entry.rb +143 -0
- data/lib/active_samba_ldap/unix_id_pool.rb +43 -0
- data/lib/active_samba_ldap/user.rb +44 -0
- data/lib/active_samba_ldap/user_account_entry.rb +30 -0
- data/lib/active_samba_ldap/version.rb +3 -0
- data/lib/samba/encrypt.rb +86 -0
- data/misc/rd2html.rb +42 -0
- data/po/ja/active-samba-ldap.po +465 -0
- data/rails/README +30 -0
- data/rails/init.rb +33 -0
- data/rails_generators/scaffold_active_samba_ldap/scaffold_active_samba_ldap_generator.rb +27 -0
- data/rails_generators/scaffold_active_samba_ldap/templates/computer.rb +3 -0
- data/rails_generators/scaffold_active_samba_ldap/templates/dc.rb +3 -0
- data/rails_generators/scaffold_active_samba_ldap/templates/group.rb +3 -0
- data/rails_generators/scaffold_active_samba_ldap/templates/idmap.rb +3 -0
- data/rails_generators/scaffold_active_samba_ldap/templates/ldap.yml +24 -0
- data/rails_generators/scaffold_active_samba_ldap/templates/ou.rb +3 -0
- data/rails_generators/scaffold_active_samba_ldap/templates/samba_controller.rb +12 -0
- data/rails_generators/scaffold_active_samba_ldap/templates/samba_helper.rb +2 -0
- data/rails_generators/scaffold_active_samba_ldap/templates/samba_index.rhtml +17 -0
- data/rails_generators/scaffold_active_samba_ldap/templates/samba_populate.rhtml +15 -0
- data/rails_generators/scaffold_active_samba_ldap/templates/samba_purge.rhtml +10 -0
- data/rails_generators/scaffold_active_samba_ldap/templates/unix_id_pool.rb +3 -0
- data/rails_generators/scaffold_active_samba_ldap/templates/user.rb +3 -0
- data/setup.rb +1585 -0
- data/test-unit/History.txt +107 -0
- data/test-unit/README.txt +52 -0
- data/test-unit/Rakefile +40 -0
- data/test-unit/TODO +5 -0
- data/test-unit/bin/testrb +5 -0
- data/test-unit/lib/test/unit.rb +342 -0
- data/test-unit/lib/test/unit/assertionfailederror.rb +14 -0
- data/test-unit/lib/test/unit/assertions.rb +1149 -0
- data/test-unit/lib/test/unit/attribute.rb +125 -0
- data/test-unit/lib/test/unit/autorunner.rb +329 -0
- data/test-unit/lib/test/unit/collector.rb +43 -0
- data/test-unit/lib/test/unit/collector/descendant.rb +23 -0
- data/test-unit/lib/test/unit/collector/dir.rb +108 -0
- data/test-unit/lib/test/unit/collector/load.rb +135 -0
- data/test-unit/lib/test/unit/collector/objectspace.rb +34 -0
- data/test-unit/lib/test/unit/color-scheme.rb +86 -0
- data/test-unit/lib/test/unit/color.rb +96 -0
- data/test-unit/lib/test/unit/diff.rb +538 -0
- data/test-unit/lib/test/unit/error.rb +124 -0
- data/test-unit/lib/test/unit/exceptionhandler.rb +39 -0
- data/test-unit/lib/test/unit/failure.rb +110 -0
- data/test-unit/lib/test/unit/fixture.rb +176 -0
- data/test-unit/lib/test/unit/notification.rb +125 -0
- data/test-unit/lib/test/unit/omission.rb +143 -0
- data/test-unit/lib/test/unit/pending.rb +146 -0
- data/test-unit/lib/test/unit/priority.rb +181 -0
- data/test-unit/lib/test/unit/runner/console.rb +52 -0
- data/test-unit/lib/test/unit/runner/emacs.rb +8 -0
- data/test-unit/lib/test/unit/testcase.rb +425 -0
- data/test-unit/lib/test/unit/testresult.rb +89 -0
- data/test-unit/lib/test/unit/testsuite.rb +110 -0
- data/test-unit/lib/test/unit/ui/console/outputlevel.rb +14 -0
- data/test-unit/lib/test/unit/ui/console/testrunner.rb +223 -0
- data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +49 -0
- data/test-unit/lib/test/unit/ui/testrunner.rb +20 -0
- data/test-unit/lib/test/unit/ui/testrunnermediator.rb +77 -0
- data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +41 -0
- data/test-unit/lib/test/unit/util/backtracefilter.rb +41 -0
- data/test-unit/lib/test/unit/util/method-owner-finder.rb +28 -0
- data/test-unit/lib/test/unit/util/observable.rb +90 -0
- data/test-unit/lib/test/unit/util/procwrapper.rb +48 -0
- data/test-unit/lib/test/unit/version.rb +7 -0
- data/test-unit/sample/adder.rb +13 -0
- data/test-unit/sample/subtracter.rb +12 -0
- data/test-unit/sample/tc_adder.rb +18 -0
- data/test-unit/sample/tc_subtracter.rb +18 -0
- data/test-unit/sample/test_user.rb +22 -0
- data/test-unit/sample/ts_examples.rb +7 -0
- data/test-unit/test/collector/test-descendant.rb +135 -0
- data/test-unit/test/collector/test-load.rb +333 -0
- data/test-unit/test/collector/test_dir.rb +406 -0
- data/test-unit/test/collector/test_objectspace.rb +98 -0
- data/test-unit/test/run-test.rb +13 -0
- data/test-unit/test/test-attribute.rb +86 -0
- data/test-unit/test/test-color-scheme.rb +56 -0
- data/test-unit/test/test-color.rb +47 -0
- data/test-unit/test/test-diff.rb +477 -0
- data/test-unit/test/test-emacs-runner.rb +60 -0
- data/test-unit/test/test-fixture.rb +287 -0
- data/test-unit/test/test-notification.rb +33 -0
- data/test-unit/test/test-omission.rb +81 -0
- data/test-unit/test/test-pending.rb +70 -0
- data/test-unit/test/test-priority.rb +119 -0
- data/test-unit/test/test-testcase.rb +507 -0
- data/test-unit/test/test_assertions.rb +1082 -0
- data/test-unit/test/test_error.rb +26 -0
- data/test-unit/test/test_failure.rb +33 -0
- data/test-unit/test/test_testresult.rb +113 -0
- data/test-unit/test/test_testsuite.rb +129 -0
- data/test-unit/test/testunit-test-util.rb +14 -0
- data/test-unit/test/ui/test_testrunmediator.rb +20 -0
- data/test-unit/test/util/test-method-owner-finder.rb +38 -0
- data/test-unit/test/util/test_backtracefilter.rb +41 -0
- data/test-unit/test/util/test_observable.rb +102 -0
- data/test-unit/test/util/test_procwrapper.rb +36 -0
- data/test/asl-test-utils.rb +276 -0
- data/test/command.rb +67 -0
- data/test/config.yaml.sample +17 -0
- data/test/run-test.rb +20 -0
- data/test/test_asl_groupadd.rb +69 -0
- data/test/test_asl_groupdel.rb +88 -0
- data/test/test_asl_groupmod.rb +259 -0
- data/test/test_asl_groupshow.rb +21 -0
- data/test/test_asl_passwd.rb +126 -0
- data/test/test_asl_populate.rb +92 -0
- data/test/test_asl_purge.rb +21 -0
- data/test/test_asl_useradd.rb +712 -0
- data/test/test_asl_userdel.rb +75 -0
- data/test/test_asl_usermod.rb +549 -0
- data/test/test_asl_usershow.rb +27 -0
- data/test/test_entry.rb +21 -0
- data/test/test_group.rb +21 -0
- data/test/test_password.rb +51 -0
- data/test/test_samba_encrypt.rb +35 -0
- data/test/test_user_home_directory.rb +43 -0
- metadata +314 -0
@@ -0,0 +1,52 @@
|
|
1
|
+
module Test
|
2
|
+
module Unit
|
3
|
+
AutoRunner.register_runner(:console) do |auto_runner|
|
4
|
+
require 'test/unit/ui/console/testrunner'
|
5
|
+
Test::Unit::UI::Console::TestRunner
|
6
|
+
end
|
7
|
+
|
8
|
+
AutoRunner.setup_option do |auto_runner, opts|
|
9
|
+
require 'test/unit/ui/console/outputlevel'
|
10
|
+
|
11
|
+
output_levels = [
|
12
|
+
[:silent, UI::Console::OutputLevel::SILENT],
|
13
|
+
[:progress, UI::Console::OutputLevel::PROGRESS_ONLY],
|
14
|
+
[:normal, UI::Console::OutputLevel::NORMAL],
|
15
|
+
[:verbose, UI::Console::OutputLevel::VERBOSE],
|
16
|
+
]
|
17
|
+
opts.on('-v', '--verbose=[LEVEL]', output_levels,
|
18
|
+
"Set the output level (default is verbose).",
|
19
|
+
"(#{auto_runner.keyword_display(output_levels)})") do |level|
|
20
|
+
level ||= output_levels.assoc(:verbose)[1]
|
21
|
+
auto_runner.runner_options[:output_level] = level
|
22
|
+
end
|
23
|
+
|
24
|
+
use_color_options = [
|
25
|
+
[:auto, :auto],
|
26
|
+
["-", false],
|
27
|
+
["no", false],
|
28
|
+
["false", false],
|
29
|
+
["+", true],
|
30
|
+
["yes", true],
|
31
|
+
["true", true],
|
32
|
+
]
|
33
|
+
opts.on("--[no-]use-color=[auto]", use_color_options,
|
34
|
+
"Uses color output",
|
35
|
+
"(default is auto)") do |use_color|
|
36
|
+
case use_color
|
37
|
+
when nil
|
38
|
+
use_color = true
|
39
|
+
when :auto
|
40
|
+
use_color = nil
|
41
|
+
end
|
42
|
+
auto_runner.runner_options[:use_color] = use_color
|
43
|
+
end
|
44
|
+
|
45
|
+
opts.on("--progress-row-max=MAX", Integer,
|
46
|
+
"Uses MAX as max terminal width for progress mark",
|
47
|
+
"(default is auto)") do |max|
|
48
|
+
auto_runner.runner_options[:progress_row_max] = max
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,425 @@
|
|
1
|
+
#--
|
2
|
+
#
|
3
|
+
# Author:: Nathaniel Talbott.
|
4
|
+
# Copyright::
|
5
|
+
# * Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved.
|
6
|
+
# * Copyright (c) 2008-2009 Kouhei Sutou <tt><kou@clear-code.com></tt>
|
7
|
+
# License:: Ruby license.
|
8
|
+
|
9
|
+
require 'test/unit/attribute'
|
10
|
+
require 'test/unit/fixture'
|
11
|
+
require 'test/unit/exceptionhandler'
|
12
|
+
require 'test/unit/assertions'
|
13
|
+
require 'test/unit/failure'
|
14
|
+
require 'test/unit/error'
|
15
|
+
require 'test/unit/pending'
|
16
|
+
require 'test/unit/omission'
|
17
|
+
require 'test/unit/notification'
|
18
|
+
require 'test/unit/priority'
|
19
|
+
require 'test/unit/testsuite'
|
20
|
+
require 'test/unit/assertionfailederror'
|
21
|
+
require 'test/unit/util/backtracefilter'
|
22
|
+
require 'test/unit/util/method-owner-finder'
|
23
|
+
|
24
|
+
module Test
|
25
|
+
module Unit
|
26
|
+
|
27
|
+
# Ties everything together. If you subclass and add your own
|
28
|
+
# test methods, it takes care of making them into tests and
|
29
|
+
# wrapping those tests into a suite. It also does the
|
30
|
+
# nitty-gritty of actually running an individual test and
|
31
|
+
# collecting its results into a Test::Unit::TestResult object.
|
32
|
+
#
|
33
|
+
# You can run two hooks before/after a TestCase run.
|
34
|
+
#
|
35
|
+
# Example:
|
36
|
+
# class TestMyClass < Test::Unit::TestCase
|
37
|
+
# class << self
|
38
|
+
# def startup
|
39
|
+
# ...
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
# def shutdown
|
43
|
+
# ...
|
44
|
+
# end
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
# def setup
|
48
|
+
# ...
|
49
|
+
# end
|
50
|
+
#
|
51
|
+
# def teardown
|
52
|
+
# ...
|
53
|
+
# end
|
54
|
+
#
|
55
|
+
# def test_my_method1
|
56
|
+
# ...
|
57
|
+
# end
|
58
|
+
#
|
59
|
+
# def test_my_method2
|
60
|
+
# ...
|
61
|
+
# end
|
62
|
+
# end
|
63
|
+
#
|
64
|
+
# Here is a call order:
|
65
|
+
# * startup
|
66
|
+
# * setup
|
67
|
+
# * test_my_method1
|
68
|
+
# * teardown
|
69
|
+
# * setup
|
70
|
+
# * test_my_method2
|
71
|
+
# * teardown
|
72
|
+
# * shutdown
|
73
|
+
class TestCase
|
74
|
+
include Attribute
|
75
|
+
include Fixture
|
76
|
+
include ExceptionHandler
|
77
|
+
include ErrorHandler
|
78
|
+
include FailureHandler
|
79
|
+
include TestCasePendingSupport
|
80
|
+
include TestCaseOmissionSupport
|
81
|
+
include TestCaseNotificationSupport
|
82
|
+
include Priority
|
83
|
+
include Assertions
|
84
|
+
include Util::BacktraceFilter
|
85
|
+
|
86
|
+
STARTED = name + "::STARTED" # :nodoc:
|
87
|
+
FINISHED = name + "::FINISHED" # :nodoc:
|
88
|
+
|
89
|
+
DESCENDANTS = [] # :nodoc:
|
90
|
+
AVAILABLE_ORDERS = [:alphabetic, :random, :defined] # :nodoc:
|
91
|
+
|
92
|
+
class << self
|
93
|
+
def inherited(sub_class) # :nodoc:
|
94
|
+
DESCENDANTS << sub_class
|
95
|
+
end
|
96
|
+
|
97
|
+
@@added_methods = []
|
98
|
+
def method_added(name) # :nodoc:
|
99
|
+
super
|
100
|
+
@@added_methods << name.to_s
|
101
|
+
end
|
102
|
+
|
103
|
+
# Rolls up all of the test* methods in the fixture into
|
104
|
+
# one suite, creating a new instance of the fixture for
|
105
|
+
# each method.
|
106
|
+
def suite
|
107
|
+
suite = TestSuite.new(name, self)
|
108
|
+
collect_test_names.each do |test|
|
109
|
+
catch(:invalid_test) do
|
110
|
+
suite << new(test)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
if suite.empty?
|
114
|
+
catch(:invalid_test) do
|
115
|
+
suite << new("default_test")
|
116
|
+
end
|
117
|
+
end
|
118
|
+
suite
|
119
|
+
end
|
120
|
+
|
121
|
+
# Called before every test case runs. Can be used
|
122
|
+
# to set up fixture information used in test case
|
123
|
+
# scope.
|
124
|
+
#
|
125
|
+
# Here is an example test case:
|
126
|
+
# class TestMyClass < Test::Unit::TestCase
|
127
|
+
# class << self
|
128
|
+
# def startup
|
129
|
+
# ...
|
130
|
+
# end
|
131
|
+
# end
|
132
|
+
#
|
133
|
+
# def setup
|
134
|
+
# ...
|
135
|
+
# end
|
136
|
+
#
|
137
|
+
# def test_my_class1
|
138
|
+
# ...
|
139
|
+
# end
|
140
|
+
#
|
141
|
+
# def test_my_class2
|
142
|
+
# ...
|
143
|
+
# end
|
144
|
+
# end
|
145
|
+
#
|
146
|
+
# Here is a call order:
|
147
|
+
# * startup
|
148
|
+
# * setup
|
149
|
+
# * test_my_class1 (or test_my_class2)
|
150
|
+
# * setup
|
151
|
+
# * test_my_class2 (or test_my_class1)
|
152
|
+
#
|
153
|
+
# Note that you should not assume test order. Tests
|
154
|
+
# should be worked in any order.
|
155
|
+
def startup
|
156
|
+
end
|
157
|
+
|
158
|
+
# Called after every test case runs. Can be used to tear
|
159
|
+
# down fixture information used in test case scope.
|
160
|
+
#
|
161
|
+
# Here is an example test case:
|
162
|
+
# class TestMyClass < Test::Unit::TestCase
|
163
|
+
# class << self
|
164
|
+
# def shutdown
|
165
|
+
# ...
|
166
|
+
# end
|
167
|
+
# end
|
168
|
+
#
|
169
|
+
# def teardown
|
170
|
+
# ...
|
171
|
+
# end
|
172
|
+
#
|
173
|
+
# def test_my_class1
|
174
|
+
# ...
|
175
|
+
# end
|
176
|
+
#
|
177
|
+
# def test_my_class2
|
178
|
+
# ...
|
179
|
+
# end
|
180
|
+
# end
|
181
|
+
#
|
182
|
+
# Here is a call order:
|
183
|
+
# * test_my_class1 (or test_my_class2)
|
184
|
+
# * teardown
|
185
|
+
# * test_my_class2 (or test_my_class1)
|
186
|
+
# * teardown
|
187
|
+
# * shutdown
|
188
|
+
#
|
189
|
+
# Note that you should not assume test order. Tests
|
190
|
+
# should be worked in any order.
|
191
|
+
def shutdown
|
192
|
+
end
|
193
|
+
|
194
|
+
@@test_order = AVAILABLE_ORDERS.first
|
195
|
+
|
196
|
+
# Returns the current test order. This returns
|
197
|
+
# +:alphabetic+ by default.
|
198
|
+
def test_order
|
199
|
+
@@test_order
|
200
|
+
end
|
201
|
+
|
202
|
+
# Sets the current test order.
|
203
|
+
#
|
204
|
+
# Here are the available _order_:
|
205
|
+
# [:alphabetic]
|
206
|
+
# Default. Tests are sorted in alphabetic order.
|
207
|
+
# [:random]
|
208
|
+
# Tests are sorted in random order.
|
209
|
+
# [:defined]
|
210
|
+
# Tests are sorted in defined order.
|
211
|
+
def test_order=(order)
|
212
|
+
@@test_order = order
|
213
|
+
end
|
214
|
+
|
215
|
+
# :stopdoc:
|
216
|
+
private
|
217
|
+
def collect_test_names
|
218
|
+
method_names = public_instance_methods(true).collect do |name|
|
219
|
+
name.to_s
|
220
|
+
end
|
221
|
+
test_names = method_names.find_all do |method_name|
|
222
|
+
method_name =~ /^test./
|
223
|
+
end
|
224
|
+
send("sort_test_names_in_#{test_order}_order", test_names)
|
225
|
+
end
|
226
|
+
|
227
|
+
def sort_test_names_in_alphabetic_order(test_names)
|
228
|
+
test_names.sort
|
229
|
+
end
|
230
|
+
|
231
|
+
def sort_test_names_in_random_order(test_names)
|
232
|
+
test_names.sort_by {rand(test_names.size)}
|
233
|
+
end
|
234
|
+
|
235
|
+
def sort_test_names_in_defined_order(test_names)
|
236
|
+
test_names.sort do |test1, test2|
|
237
|
+
test1_defined_order = @@added_methods.index(test1)
|
238
|
+
test2_defined_order = @@added_methods.index(test2)
|
239
|
+
if test1_defined_order and test2_defined_order
|
240
|
+
test1_defined_order <=> test2_defined_order
|
241
|
+
elsif test1_defined_order
|
242
|
+
1
|
243
|
+
elsif test2_defined_order
|
244
|
+
-1
|
245
|
+
else
|
246
|
+
test1 <=> test2
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
250
|
+
# :startdoc:
|
251
|
+
end
|
252
|
+
|
253
|
+
attr_reader :method_name
|
254
|
+
|
255
|
+
# Creates a new instance of the fixture for running the
|
256
|
+
# test represented by test_method_name.
|
257
|
+
def initialize(test_method_name)
|
258
|
+
throw :invalid_test unless respond_to?(test_method_name)
|
259
|
+
test_method = method(test_method_name)
|
260
|
+
throw :invalid_test if test_method.arity > 0
|
261
|
+
owner = Util::MethodOwnerFinder.find(self, test_method_name)
|
262
|
+
if owner.class != Module and self.class != owner
|
263
|
+
throw :invalid_test
|
264
|
+
end
|
265
|
+
@method_name = test_method_name
|
266
|
+
@test_passed = true
|
267
|
+
@interrupted = false
|
268
|
+
end
|
269
|
+
|
270
|
+
# Runs the individual test method represented by this
|
271
|
+
# instance of the fixture, collecting statistics, failures
|
272
|
+
# and errors in result.
|
273
|
+
def run(result)
|
274
|
+
begin
|
275
|
+
@_result = result
|
276
|
+
yield(STARTED, name)
|
277
|
+
begin
|
278
|
+
run_setup
|
279
|
+
run_test
|
280
|
+
rescue Exception
|
281
|
+
@interrupted = true
|
282
|
+
raise unless handle_exception($!)
|
283
|
+
ensure
|
284
|
+
begin
|
285
|
+
run_teardown
|
286
|
+
rescue Exception
|
287
|
+
raise unless handle_exception($!)
|
288
|
+
end
|
289
|
+
end
|
290
|
+
result.add_run
|
291
|
+
yield(FINISHED, name)
|
292
|
+
ensure
|
293
|
+
# @_result = nil # For test-spec's after_all :<
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
# Called before every test method runs. Can be used
|
298
|
+
# to set up fixture information.
|
299
|
+
#
|
300
|
+
# You can add additional setup tasks by the following
|
301
|
+
# code:
|
302
|
+
# class TestMyClass < Test::Unit::TestCase
|
303
|
+
# def setup
|
304
|
+
# ...
|
305
|
+
# end
|
306
|
+
#
|
307
|
+
# setup
|
308
|
+
# def my_setup1
|
309
|
+
# ...
|
310
|
+
# end
|
311
|
+
#
|
312
|
+
# setup
|
313
|
+
# def my_setup2
|
314
|
+
# ...
|
315
|
+
# end
|
316
|
+
#
|
317
|
+
# def test_my_class
|
318
|
+
# ...
|
319
|
+
# end
|
320
|
+
# end
|
321
|
+
#
|
322
|
+
# Here is a call order:
|
323
|
+
# * setup
|
324
|
+
# * my_setup1
|
325
|
+
# * my_setup2
|
326
|
+
# * test_my_class
|
327
|
+
def setup
|
328
|
+
end
|
329
|
+
|
330
|
+
# Called after every test method runs. Can be used to tear
|
331
|
+
# down fixture information.
|
332
|
+
#
|
333
|
+
# You can add additional teardown tasks by the following
|
334
|
+
# code:
|
335
|
+
# class TestMyClass < Test::Unit::TestCase
|
336
|
+
# def teardown
|
337
|
+
# ...
|
338
|
+
# end
|
339
|
+
#
|
340
|
+
# teardown
|
341
|
+
# def my_teardown1
|
342
|
+
# ...
|
343
|
+
# end
|
344
|
+
#
|
345
|
+
# teardown
|
346
|
+
# def my_teardown2
|
347
|
+
# ...
|
348
|
+
# end
|
349
|
+
#
|
350
|
+
# def test_my_class
|
351
|
+
# ...
|
352
|
+
# end
|
353
|
+
# end
|
354
|
+
#
|
355
|
+
# Here is a call order:
|
356
|
+
# * test_my_class
|
357
|
+
# * my_teardown2
|
358
|
+
# * my_teardown1
|
359
|
+
# * teardown
|
360
|
+
def teardown
|
361
|
+
end
|
362
|
+
|
363
|
+
def default_test
|
364
|
+
flunk("No tests were specified")
|
365
|
+
end
|
366
|
+
|
367
|
+
def size
|
368
|
+
1
|
369
|
+
end
|
370
|
+
|
371
|
+
# Returns a human-readable name for the specific test that
|
372
|
+
# this instance of TestCase represents.
|
373
|
+
def name
|
374
|
+
"#{@method_name}(#{self.class.name})"
|
375
|
+
end
|
376
|
+
|
377
|
+
# Overridden to return #name.
|
378
|
+
def to_s
|
379
|
+
name
|
380
|
+
end
|
381
|
+
|
382
|
+
# It's handy to be able to compare TestCase instances.
|
383
|
+
def ==(other)
|
384
|
+
return false unless(other.kind_of?(self.class))
|
385
|
+
return false unless(@method_name == other.method_name)
|
386
|
+
self.class == other.class
|
387
|
+
end
|
388
|
+
|
389
|
+
def interrupted?
|
390
|
+
@interrupted
|
391
|
+
end
|
392
|
+
|
393
|
+
private
|
394
|
+
def current_result
|
395
|
+
@_result
|
396
|
+
end
|
397
|
+
|
398
|
+
def run_test
|
399
|
+
__send__(@method_name)
|
400
|
+
end
|
401
|
+
|
402
|
+
def handle_exception(exception)
|
403
|
+
self.class.exception_handlers.each do |handler|
|
404
|
+
return true if send(handler, exception)
|
405
|
+
end
|
406
|
+
false
|
407
|
+
end
|
408
|
+
|
409
|
+
# Returns whether this individual test passed or
|
410
|
+
# not. Primarily for use in teardown so that artifacts
|
411
|
+
# can be left behind if the test fails.
|
412
|
+
def passed?
|
413
|
+
@test_passed
|
414
|
+
end
|
415
|
+
|
416
|
+
def problem_occurred
|
417
|
+
@test_passed = false
|
418
|
+
end
|
419
|
+
|
420
|
+
def add_assertion
|
421
|
+
current_result.add_assertion
|
422
|
+
end
|
423
|
+
end
|
424
|
+
end
|
425
|
+
end
|