activegroonga 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. data/README.textile +55 -0
  2. data/Rakefile +45 -165
  3. data/{license/LGPL → doc/text/lgpl.txt} +0 -0
  4. data/doc/text/news.textile +60 -0
  5. data/doc/text/tutorial.textile +3 -0
  6. data/lib/active_groonga/base.rb +50 -2
  7. data/lib/active_groonga/railtie.rb +6 -5
  8. data/lib/active_groonga/railties/groonga.rake +8 -4
  9. data/lib/active_groonga/result_set.rb +133 -8
  10. data/lib/active_groonga/version.rb +1 -1
  11. data/test/active-groonga-test-utils.rb +6 -0
  12. data/test/run-test.rb +11 -24
  13. data/test/test-base.rb +10 -4
  14. data/test/test-result-set.rb +121 -9
  15. metadata +90 -138
  16. data/AUTHORS +0 -1
  17. data/NEWS.ja.rdoc +0 -46
  18. data/NEWS.rdoc +0 -46
  19. data/README.ja.rdoc +0 -52
  20. data/README.rdoc +0 -52
  21. data/test-unit-notify/Rakefile +0 -47
  22. data/test-unit-notify/lib/test/unit/notify.rb +0 -104
  23. data/test-unit/COPYING +0 -56
  24. data/test-unit/GPL +0 -340
  25. data/test-unit/PSFL +0 -271
  26. data/test-unit/Rakefile +0 -53
  27. data/test-unit/TODO +0 -5
  28. data/test-unit/bin/testrb +0 -5
  29. data/test-unit/html/bar.svg +0 -153
  30. data/test-unit/html/developer.svg +0 -469
  31. data/test-unit/html/favicon.ico +0 -0
  32. data/test-unit/html/favicon.svg +0 -82
  33. data/test-unit/html/heading-mark.svg +0 -393
  34. data/test-unit/html/index.html +0 -247
  35. data/test-unit/html/index.html.ja +0 -270
  36. data/test-unit/html/install.svg +0 -636
  37. data/test-unit/html/logo.svg +0 -483
  38. data/test-unit/html/test-unit.css +0 -339
  39. data/test-unit/html/tutorial.svg +0 -559
  40. data/test-unit/lib/test/unit.rb +0 -328
  41. data/test-unit/lib/test/unit/assertionfailederror.rb +0 -25
  42. data/test-unit/lib/test/unit/assertions.rb +0 -1334
  43. data/test-unit/lib/test/unit/attribute.rb +0 -125
  44. data/test-unit/lib/test/unit/autorunner.rb +0 -363
  45. data/test-unit/lib/test/unit/collector.rb +0 -36
  46. data/test-unit/lib/test/unit/collector/descendant.rb +0 -23
  47. data/test-unit/lib/test/unit/collector/dir.rb +0 -108
  48. data/test-unit/lib/test/unit/collector/load.rb +0 -144
  49. data/test-unit/lib/test/unit/collector/objectspace.rb +0 -34
  50. data/test-unit/lib/test/unit/color-scheme.rb +0 -106
  51. data/test-unit/lib/test/unit/color.rb +0 -96
  52. data/test-unit/lib/test/unit/diff.rb +0 -740
  53. data/test-unit/lib/test/unit/error.rb +0 -130
  54. data/test-unit/lib/test/unit/exceptionhandler.rb +0 -39
  55. data/test-unit/lib/test/unit/failure.rb +0 -136
  56. data/test-unit/lib/test/unit/fixture.rb +0 -176
  57. data/test-unit/lib/test/unit/notification.rb +0 -129
  58. data/test-unit/lib/test/unit/omission.rb +0 -191
  59. data/test-unit/lib/test/unit/pending.rb +0 -150
  60. data/test-unit/lib/test/unit/priority.rb +0 -180
  61. data/test-unit/lib/test/unit/runner/console.rb +0 -52
  62. data/test-unit/lib/test/unit/runner/emacs.rb +0 -8
  63. data/test-unit/lib/test/unit/runner/tap.rb +0 -8
  64. data/test-unit/lib/test/unit/testcase.rb +0 -483
  65. data/test-unit/lib/test/unit/testresult.rb +0 -121
  66. data/test-unit/lib/test/unit/testsuite.rb +0 -110
  67. data/test-unit/lib/test/unit/ui/console/outputlevel.rb +0 -14
  68. data/test-unit/lib/test/unit/ui/console/testrunner.rb +0 -430
  69. data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +0 -63
  70. data/test-unit/lib/test/unit/ui/tap/testrunner.rb +0 -82
  71. data/test-unit/lib/test/unit/ui/testrunner.rb +0 -53
  72. data/test-unit/lib/test/unit/ui/testrunnermediator.rb +0 -77
  73. data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +0 -41
  74. data/test-unit/lib/test/unit/util/backtracefilter.rb +0 -42
  75. data/test-unit/lib/test/unit/util/method-owner-finder.rb +0 -28
  76. data/test-unit/lib/test/unit/util/observable.rb +0 -90
  77. data/test-unit/lib/test/unit/util/output.rb +0 -31
  78. data/test-unit/lib/test/unit/util/procwrapper.rb +0 -48
  79. data/test-unit/lib/test/unit/version.rb +0 -7
  80. data/test-unit/sample/adder.rb +0 -13
  81. data/test-unit/sample/subtracter.rb +0 -12
  82. data/test-unit/sample/test_adder.rb +0 -20
  83. data/test-unit/sample/test_subtracter.rb +0 -20
  84. data/test-unit/sample/test_user.rb +0 -23
  85. data/test-unit/test/collector/test-descendant.rb +0 -133
  86. data/test-unit/test/collector/test-load.rb +0 -442
  87. data/test-unit/test/collector/test_dir.rb +0 -406
  88. data/test-unit/test/collector/test_objectspace.rb +0 -100
  89. data/test-unit/test/run-test.rb +0 -15
  90. data/test-unit/test/test-attribute.rb +0 -86
  91. data/test-unit/test/test-color-scheme.rb +0 -69
  92. data/test-unit/test/test-color.rb +0 -47
  93. data/test-unit/test/test-diff.rb +0 -518
  94. data/test-unit/test/test-emacs-runner.rb +0 -60
  95. data/test-unit/test/test-fixture.rb +0 -287
  96. data/test-unit/test/test-notification.rb +0 -33
  97. data/test-unit/test/test-omission.rb +0 -81
  98. data/test-unit/test/test-pending.rb +0 -70
  99. data/test-unit/test/test-priority.rb +0 -119
  100. data/test-unit/test/test-testcase.rb +0 -544
  101. data/test-unit/test/test_assertions.rb +0 -1197
  102. data/test-unit/test/test_error.rb +0 -26
  103. data/test-unit/test/test_failure.rb +0 -33
  104. data/test-unit/test/test_testresult.rb +0 -113
  105. data/test-unit/test/test_testsuite.rb +0 -129
  106. data/test-unit/test/testunit-test-util.rb +0 -14
  107. data/test-unit/test/ui/test_tap.rb +0 -33
  108. data/test-unit/test/ui/test_testrunmediator.rb +0 -20
  109. data/test-unit/test/util/test-method-owner-finder.rb +0 -38
  110. data/test-unit/test/util/test-output.rb +0 -11
  111. data/test-unit/test/util/test_backtracefilter.rb +0 -41
  112. data/test-unit/test/util/test_observable.rb +0 -102
  113. data/test-unit/test/util/test_procwrapper.rb +0 -36
@@ -1,180 +0,0 @@
1
- module Test
2
- module Unit
3
- module Priority
4
- class << self
5
- def included(base)
6
- base.extend(ClassMethods)
7
-
8
- base.class_eval do
9
- setup :priority_setup, :before => :prepend
10
- teardown :priority_teardown, :after => :append
11
- end
12
- end
13
-
14
- @@enabled = false
15
- def enabled?
16
- @@enabled
17
- end
18
-
19
- def enable
20
- require "fileutils"
21
- require "tmpdir"
22
- @@enabled = true
23
- end
24
-
25
- def disable
26
- @@enabled = false
27
- end
28
-
29
- @@default = :normal
30
- def default
31
- @@default || :normal
32
- end
33
-
34
- def default=(default)
35
- @@default = default
36
- end
37
-
38
- def available_values
39
- Checker.available_priorities
40
- end
41
- end
42
-
43
- class Checker
44
- class << self
45
- def have_priority?(name)
46
- singleton_class = (class << self; self; end)
47
- singleton_class.method_defined?(priority_check_method_name(name))
48
- end
49
-
50
- def need_to_run?(test)
51
- priority = test[:priority] || Priority.default
52
- if have_priority?(priority)
53
- send(priority_check_method_name(priority), test)
54
- else
55
- true
56
- end
57
- end
58
-
59
- def available_priorities
60
- methods(false).collect do |name|
61
- /\Arun_priority_(.+)\?\z/ =~ name.to_s
62
- $1
63
- end.compact
64
- end
65
-
66
- def run_priority_must?(test)
67
- true
68
- end
69
-
70
- def run_priority_important?(test)
71
- rand > 0.1
72
- end
73
-
74
- def run_priority_high?(test)
75
- rand > 0.3
76
- end
77
-
78
- def run_priority_normal?(test)
79
- rand > 0.5
80
- end
81
-
82
- def run_priority_low?(test)
83
- rand > 0.75
84
- end
85
-
86
- def run_priority_never?(test)
87
- false
88
- end
89
-
90
- private
91
- def priority_check_method_name(priority_name)
92
- "run_priority_#{priority_name}?"
93
- end
94
- end
95
-
96
- attr_reader :test
97
- def initialize(test)
98
- @test = test
99
- end
100
-
101
- def setup
102
- FileUtils.rm_f(passed_file)
103
- end
104
-
105
- def teardown
106
- if @test.send(:passed?)
107
- FileUtils.touch(passed_file)
108
- else
109
- FileUtils.rm_f(passed_file)
110
- end
111
- end
112
-
113
- def need_to_run?
114
- !previous_test_success? or self.class.need_to_run?(@test)
115
- end
116
-
117
- private
118
- def previous_test_success?
119
- File.exist?(passed_file)
120
- end
121
-
122
- def result_dir
123
- components = [".test-result",
124
- @test.class.name || "AnonymousTestCase",
125
- escaped_method_name]
126
- parent_directories = [File.dirname($0), Dir.pwd]
127
- if Process.respond_to?(:uid)
128
- parent_directories << File.join(Dir.tmpdir, Process.uid.to_s)
129
- end
130
- parent_directories.each do |parent_directory|
131
- dir = File.expand_path(File.join(parent_directory, *components))
132
- begin
133
- FileUtils.mkdir_p(dir)
134
- return dir
135
- rescue Errno::EACCES
136
- end
137
- end
138
-
139
- raise Errno::EACCES, parent_directories.join(", ")
140
- end
141
-
142
- def passed_file
143
- File.join(result_dir, "passed")
144
- end
145
-
146
- def escaped_method_name
147
- @test.method_name.to_s.gsub(/[!?=]$/) do |matched|
148
- case matched
149
- when "!"
150
- ".destructive"
151
- when "?"
152
- ".predicate"
153
- when "="
154
- ".equal"
155
- end
156
- end
157
- end
158
- end
159
-
160
- module ClassMethods
161
- def priority(name, *tests)
162
- unless Checker.have_priority?(name)
163
- raise ArgumentError, "unknown priority: #{name}"
164
- end
165
- attribute(:priority, name, {:keep => true}, *tests)
166
- end
167
- end
168
-
169
- def priority_setup
170
- return unless Priority.enabled?
171
- Checker.new(self).setup
172
- end
173
-
174
- def priority_teardown
175
- return unless Priority.enabled?
176
- Checker.new(self).teardown
177
- end
178
- end
179
- end
180
- end
@@ -1,52 +0,0 @@
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
@@ -1,8 +0,0 @@
1
- module Test
2
- module Unit
3
- AutoRunner.register_runner(:emacs) do |auto_runner|
4
- require 'test/unit/ui/emacs/testrunner'
5
- Test::Unit::UI::Emacs::TestRunner
6
- end
7
- end
8
- end
@@ -1,8 +0,0 @@
1
- module Test
2
- module Unit
3
- AutoRunner.register_runner(:tap) do |auto_runner|
4
- require 'test/unit/ui/tap/testrunner'
5
- Test::Unit::UI::Tap::TestRunner
6
- end
7
- end
8
- end
@@ -1,483 +0,0 @@
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/output'
23
- require 'test/unit/util/method-owner-finder'
24
-
25
- module Test
26
- module Unit
27
-
28
- # Ties everything together. If you subclass and add your own
29
- # test methods, it takes care of making them into tests and
30
- # wrapping those tests into a suite. It also does the
31
- # nitty-gritty of actually running an individual test and
32
- # collecting its results into a Test::Unit::TestResult object.
33
- #
34
- # You can run two hooks before/after a TestCase run.
35
- #
36
- # Example:
37
- # class TestMyClass < Test::Unit::TestCase
38
- # class << self
39
- # def startup
40
- # ...
41
- # end
42
- #
43
- # def shutdown
44
- # ...
45
- # end
46
- # end
47
- #
48
- # def setup
49
- # ...
50
- # end
51
- #
52
- # def teardown
53
- # ...
54
- # end
55
- #
56
- # def test_my_method1
57
- # ...
58
- # end
59
- #
60
- # def test_my_method2
61
- # ...
62
- # end
63
- # end
64
- #
65
- # Here is a call order:
66
- # * startup
67
- # * setup
68
- # * test_my_method1
69
- # * teardown
70
- # * setup
71
- # * test_my_method2
72
- # * teardown
73
- # * shutdown
74
- class TestCase
75
- include Attribute
76
- include Fixture
77
- include ExceptionHandler
78
- include ErrorHandler
79
- include FailureHandler
80
- include TestCasePendingSupport
81
- include TestCaseOmissionSupport
82
- include TestCaseNotificationSupport
83
- include Priority
84
- include Assertions
85
- include Util::BacktraceFilter
86
- include Util::Output
87
-
88
- STARTED = name + "::STARTED" # :nodoc:
89
- FINISHED = name + "::FINISHED" # :nodoc:
90
-
91
- DESCENDANTS = [] # :nodoc:
92
- AVAILABLE_ORDERS = [:alphabetic, :random, :defined] # :nodoc:
93
-
94
- class << self
95
- def inherited(sub_class) # :nodoc:
96
- DESCENDANTS << sub_class
97
- end
98
-
99
- @@added_methods = {}
100
- def method_added(name) # :nodoc:
101
- super
102
- added_methods = (@@added_methods[self] ||= [])
103
- stringified_name = name.to_s
104
- if added_methods.include?(stringified_name)
105
- attribute(:redefined, true, {}, stringified_name)
106
- end
107
- added_methods << stringified_name
108
- end
109
-
110
- # Rolls up all of the test* methods in the fixture into
111
- # one suite, creating a new instance of the fixture for
112
- # each method.
113
- def suite
114
- suite = TestSuite.new(name, self)
115
- collect_test_names.each do |test|
116
- catch(:invalid_test) do
117
- suite << new(test)
118
- end
119
- end
120
- if suite.empty?
121
- catch(:invalid_test) do
122
- suite << new("default_test")
123
- end
124
- end
125
- suite
126
- end
127
-
128
- # Called before every test case runs. Can be used
129
- # to set up fixture information used in test case
130
- # scope.
131
- #
132
- # Here is an example test case:
133
- # class TestMyClass < Test::Unit::TestCase
134
- # class << self
135
- # def startup
136
- # ...
137
- # end
138
- # end
139
- #
140
- # def setup
141
- # ...
142
- # end
143
- #
144
- # def test_my_class1
145
- # ...
146
- # end
147
- #
148
- # def test_my_class2
149
- # ...
150
- # end
151
- # end
152
- #
153
- # Here is a call order:
154
- # * startup
155
- # * setup
156
- # * test_my_class1 (or test_my_class2)
157
- # * setup
158
- # * test_my_class2 (or test_my_class1)
159
- #
160
- # Note that you should not assume test order. Tests
161
- # should be worked in any order.
162
- def startup
163
- end
164
-
165
- # Called after every test case runs. Can be used to tear
166
- # down fixture information used in test case scope.
167
- #
168
- # Here is an example test case:
169
- # class TestMyClass < Test::Unit::TestCase
170
- # class << self
171
- # def shutdown
172
- # ...
173
- # end
174
- # end
175
- #
176
- # def teardown
177
- # ...
178
- # end
179
- #
180
- # def test_my_class1
181
- # ...
182
- # end
183
- #
184
- # def test_my_class2
185
- # ...
186
- # end
187
- # end
188
- #
189
- # Here is a call order:
190
- # * test_my_class1 (or test_my_class2)
191
- # * teardown
192
- # * test_my_class2 (or test_my_class1)
193
- # * teardown
194
- # * shutdown
195
- #
196
- # Note that you should not assume test order. Tests
197
- # should be worked in any order.
198
- def shutdown
199
- end
200
-
201
- @@test_orders = {}
202
-
203
- # Returns the current test order. This returns
204
- # +:alphabetic+ by default.
205
- def test_order
206
- @@test_orders[self] || AVAILABLE_ORDERS.first
207
- end
208
-
209
- # Sets the current test order.
210
- #
211
- # Here are the available _order_:
212
- # [:alphabetic]
213
- # Default. Tests are sorted in alphabetic order.
214
- # [:random]
215
- # Tests are sorted in random order.
216
- # [:defined]
217
- # Tests are sorted in defined order.
218
- def test_order=(order)
219
- @@test_orders[self] = order
220
- end
221
-
222
- # Defines a test in declarative syntax.
223
- #
224
- # The following two test definitions are the same:
225
- #
226
- # description "register user"
227
- # def test_register_user
228
- # ...
229
- # end
230
- #
231
- # test "register user" do
232
- # ...
233
- # end
234
- def test(test_description, &block)
235
- normalized_description = test_description.gsub(/[^a-zA-Z\d_]+/, '_')
236
- method_name = "test_#{normalized_description}".to_sym
237
- define_method(method_name, &block)
238
- description(test_description, method_name)
239
- end
240
-
241
- # Describes a test.
242
- #
243
- # The following example associates "register a
244
- # normal user" description with "test_register"
245
- # test.
246
- #
247
- # description "register a normal user"
248
- # def test_register
249
- # ...
250
- # end
251
- def description(value, target=nil)
252
- attribute(:description, value, {}, target || [])
253
- end
254
-
255
- # :stopdoc:
256
- private
257
- def collect_test_names
258
- method_names = public_instance_methods(true).collect do |name|
259
- name.to_s
260
- end
261
- test_names = method_names.find_all do |method_name|
262
- method_name =~ /^test./
263
- end
264
- send("sort_test_names_in_#{test_order}_order", test_names)
265
- end
266
-
267
- def sort_test_names_in_alphabetic_order(test_names)
268
- test_names.sort
269
- end
270
-
271
- def sort_test_names_in_random_order(test_names)
272
- test_names.sort_by {rand(test_names.size)}
273
- end
274
-
275
- def sort_test_names_in_defined_order(test_names)
276
- added_methods = @@added_methods[self]
277
- test_names.sort do |test1, test2|
278
- test1_defined_order = added_methods.index(test1)
279
- test2_defined_order = added_methods.index(test2)
280
- if test1_defined_order and test2_defined_order
281
- test1_defined_order <=> test2_defined_order
282
- elsif test1_defined_order
283
- 1
284
- elsif test2_defined_order
285
- -1
286
- else
287
- test1 <=> test2
288
- end
289
- end
290
- end
291
- # :startdoc:
292
- end
293
-
294
- attr_reader :method_name
295
-
296
- # Creates a new instance of the fixture for running the
297
- # test represented by test_method_name.
298
- def initialize(test_method_name)
299
- throw :invalid_test unless respond_to?(test_method_name)
300
- test_method = method(test_method_name)
301
- throw :invalid_test if test_method.arity > 0
302
- owner = Util::MethodOwnerFinder.find(self, test_method_name)
303
- if owner.class != Module and self.class != owner
304
- throw :invalid_test
305
- end
306
- @method_name = test_method_name
307
- @test_passed = true
308
- @interrupted = false
309
- end
310
-
311
- # Runs the individual test method represented by this
312
- # instance of the fixture, collecting statistics, failures
313
- # and errors in result.
314
- def run(result)
315
- begin
316
- @_result = result
317
- yield(STARTED, name)
318
- begin
319
- run_setup
320
- run_test
321
- rescue Exception
322
- @interrupted = true
323
- raise unless handle_exception($!)
324
- ensure
325
- begin
326
- run_teardown
327
- rescue Exception
328
- raise unless handle_exception($!)
329
- end
330
- end
331
- result.add_run
332
- yield(FINISHED, name)
333
- ensure
334
- # @_result = nil # For test-spec's after_all :<
335
- end
336
- end
337
-
338
- # Called before every test method runs. Can be used
339
- # to set up fixture information.
340
- #
341
- # You can add additional setup tasks by the following
342
- # code:
343
- # class TestMyClass < Test::Unit::TestCase
344
- # def setup
345
- # ...
346
- # end
347
- #
348
- # setup
349
- # def my_setup1
350
- # ...
351
- # end
352
- #
353
- # setup
354
- # def my_setup2
355
- # ...
356
- # end
357
- #
358
- # def test_my_class
359
- # ...
360
- # end
361
- # end
362
- #
363
- # Here is a call order:
364
- # * setup
365
- # * my_setup1
366
- # * my_setup2
367
- # * test_my_class
368
- def setup
369
- end
370
-
371
- # Called after every test method runs. Can be used to tear
372
- # down fixture information.
373
- #
374
- # You can add additional teardown tasks by the following
375
- # code:
376
- # class TestMyClass < Test::Unit::TestCase
377
- # def teardown
378
- # ...
379
- # end
380
- #
381
- # teardown
382
- # def my_teardown1
383
- # ...
384
- # end
385
- #
386
- # teardown
387
- # def my_teardown2
388
- # ...
389
- # end
390
- #
391
- # def test_my_class
392
- # ...
393
- # end
394
- # end
395
- #
396
- # Here is a call order:
397
- # * test_my_class
398
- # * my_teardown2
399
- # * my_teardown1
400
- # * teardown
401
- def teardown
402
- end
403
-
404
- def default_test
405
- flunk("No tests were specified")
406
- end
407
-
408
- def size
409
- 1
410
- end
411
-
412
- # Returns a human-readable name for the specific test that
413
- # this instance of TestCase represents.
414
- def name
415
- "#{@method_name}(#{self.class.name})"
416
- end
417
-
418
- # Returns a description for the test. A description
419
- # will be associated by Test::Unit::TestCase.test or
420
- # Test::Unit::TestCase.description.
421
- #
422
- # Returns a name for the test for no description test.
423
- def description
424
- self[:description] || name
425
- end
426
-
427
- # Overridden to return #name.
428
- def to_s
429
- name
430
- end
431
-
432
- # It's handy to be able to compare TestCase instances.
433
- def ==(other)
434
- return false unless(other.kind_of?(self.class))
435
- return false unless(@method_name == other.method_name)
436
- self.class == other.class
437
- end
438
-
439
- def interrupted?
440
- @interrupted
441
- end
442
-
443
- private
444
- def current_result
445
- @_result
446
- end
447
-
448
- def run_test
449
- if self.class.get_attribute(@method_name, :redefined)
450
- notify("#{self.class}\##{@method_name} was redefined")
451
- end
452
- __send__(@method_name)
453
- add_pass
454
- end
455
-
456
- def handle_exception(exception)
457
- self.class.exception_handlers.each do |handler|
458
- return true if send(handler, exception)
459
- end
460
- false
461
- end
462
-
463
- # Returns whether this individual test passed or
464
- # not. Primarily for use in teardown so that artifacts
465
- # can be left behind if the test fails.
466
- def passed?
467
- @test_passed
468
- end
469
-
470
- def problem_occurred
471
- @test_passed = false
472
- end
473
-
474
- def add_assertion
475
- current_result.add_assertion
476
- end
477
-
478
- def add_pass
479
- current_result.add_pass
480
- end
481
- end
482
- end
483
- end