activegroonga 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. data/AUTHORS +1 -0
  2. data/NEWS.ja.rdoc +5 -0
  3. data/NEWS.rdoc +5 -0
  4. data/README.ja.rdoc +49 -0
  5. data/README.rdoc +49 -0
  6. data/Rakefile +175 -0
  7. data/lib/active_groonga.rb +75 -0
  8. data/lib/active_groonga/aggregations.rb +30 -0
  9. data/lib/active_groonga/associations.rb +93 -0
  10. data/lib/active_groonga/associations/belongs_to_association.rb +25 -0
  11. data/lib/active_groonga/attribute_methods.rb +36 -0
  12. data/lib/active_groonga/base.rb +1579 -0
  13. data/lib/active_groonga/column.rb +107 -0
  14. data/lib/active_groonga/dirty.rb +30 -0
  15. data/lib/active_groonga/fixtures.rb +92 -0
  16. data/lib/active_groonga/migration.rb +150 -0
  17. data/lib/active_groonga/rails_support.rb +31 -0
  18. data/lib/active_groonga/reflection.rb +30 -0
  19. data/lib/active_groonga/schema.rb +314 -0
  20. data/lib/active_groonga/schema_dumper.rb +147 -0
  21. data/lib/active_groonga/tasks.rb +16 -0
  22. data/lib/active_groonga/tasks/groonga.rake +162 -0
  23. data/lib/active_groonga/test_case.rb +21 -0
  24. data/lib/active_groonga/test_help.rb +21 -0
  25. data/lib/active_groonga/timestamp.rb +30 -0
  26. data/lib/active_groonga/validations.rb +26 -0
  27. data/lib/active_groonga/version.rb +24 -0
  28. data/license/LGPL +504 -0
  29. data/rails/README +28 -0
  30. data/rails/init.rb +70 -0
  31. data/rails_generators/model_groonga/USAGE +28 -0
  32. data/rails_generators/model_groonga/model_groonga_generator.rb +45 -0
  33. data/rails_generators/model_groonga/templates/fixtures.yml +17 -0
  34. data/rails_generators/model_groonga/templates/migration.rb +16 -0
  35. data/rails_generators/model_groonga/templates/model.rb +2 -0
  36. data/rails_generators/model_groonga/templates/unit_test.rb +8 -0
  37. data/test-unit/Rakefile +35 -0
  38. data/test-unit/TODO +5 -0
  39. data/test-unit/bin/testrb +5 -0
  40. data/test-unit/html/classic.html +15 -0
  41. data/test-unit/html/index.html +25 -0
  42. data/test-unit/html/index.html.ja +27 -0
  43. data/test-unit/lib/test/unit.rb +342 -0
  44. data/test-unit/lib/test/unit/assertionfailederror.rb +14 -0
  45. data/test-unit/lib/test/unit/assertions.rb +1149 -0
  46. data/test-unit/lib/test/unit/attribute.rb +125 -0
  47. data/test-unit/lib/test/unit/autorunner.rb +306 -0
  48. data/test-unit/lib/test/unit/collector.rb +43 -0
  49. data/test-unit/lib/test/unit/collector/descendant.rb +23 -0
  50. data/test-unit/lib/test/unit/collector/dir.rb +108 -0
  51. data/test-unit/lib/test/unit/collector/load.rb +135 -0
  52. data/test-unit/lib/test/unit/collector/objectspace.rb +34 -0
  53. data/test-unit/lib/test/unit/color-scheme.rb +86 -0
  54. data/test-unit/lib/test/unit/color.rb +96 -0
  55. data/test-unit/lib/test/unit/diff.rb +538 -0
  56. data/test-unit/lib/test/unit/error.rb +124 -0
  57. data/test-unit/lib/test/unit/exceptionhandler.rb +39 -0
  58. data/test-unit/lib/test/unit/failure.rb +110 -0
  59. data/test-unit/lib/test/unit/fixture.rb +176 -0
  60. data/test-unit/lib/test/unit/notification.rb +125 -0
  61. data/test-unit/lib/test/unit/omission.rb +143 -0
  62. data/test-unit/lib/test/unit/pending.rb +146 -0
  63. data/test-unit/lib/test/unit/priority.rb +161 -0
  64. data/test-unit/lib/test/unit/runner/console.rb +52 -0
  65. data/test-unit/lib/test/unit/runner/emacs.rb +8 -0
  66. data/test-unit/lib/test/unit/testcase.rb +360 -0
  67. data/test-unit/lib/test/unit/testresult.rb +89 -0
  68. data/test-unit/lib/test/unit/testsuite.rb +110 -0
  69. data/test-unit/lib/test/unit/ui/console/outputlevel.rb +14 -0
  70. data/test-unit/lib/test/unit/ui/console/testrunner.rb +220 -0
  71. data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +49 -0
  72. data/test-unit/lib/test/unit/ui/testrunner.rb +20 -0
  73. data/test-unit/lib/test/unit/ui/testrunnermediator.rb +77 -0
  74. data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +41 -0
  75. data/test-unit/lib/test/unit/util/backtracefilter.rb +41 -0
  76. data/test-unit/lib/test/unit/util/method-owner-finder.rb +28 -0
  77. data/test-unit/lib/test/unit/util/observable.rb +90 -0
  78. data/test-unit/lib/test/unit/util/procwrapper.rb +48 -0
  79. data/test-unit/lib/test/unit/version.rb +7 -0
  80. data/test-unit/sample/adder.rb +13 -0
  81. data/test-unit/sample/subtracter.rb +12 -0
  82. data/test-unit/sample/tc_adder.rb +18 -0
  83. data/test-unit/sample/tc_subtracter.rb +18 -0
  84. data/test-unit/sample/test_user.rb +22 -0
  85. data/test-unit/sample/ts_examples.rb +7 -0
  86. data/test-unit/test/collector/test-descendant.rb +135 -0
  87. data/test-unit/test/collector/test-load.rb +333 -0
  88. data/test-unit/test/collector/test_dir.rb +406 -0
  89. data/test-unit/test/collector/test_objectspace.rb +98 -0
  90. data/test-unit/test/run-test.rb +13 -0
  91. data/test-unit/test/test-attribute.rb +86 -0
  92. data/test-unit/test/test-color-scheme.rb +56 -0
  93. data/test-unit/test/test-color.rb +47 -0
  94. data/test-unit/test/test-diff.rb +477 -0
  95. data/test-unit/test/test-emacs-runner.rb +60 -0
  96. data/test-unit/test/test-fixture.rb +287 -0
  97. data/test-unit/test/test-notification.rb +33 -0
  98. data/test-unit/test/test-omission.rb +81 -0
  99. data/test-unit/test/test-pending.rb +70 -0
  100. data/test-unit/test/test-priority.rb +119 -0
  101. data/test-unit/test/test_assertions.rb +1082 -0
  102. data/test-unit/test/test_error.rb +26 -0
  103. data/test-unit/test/test_failure.rb +33 -0
  104. data/test-unit/test/test_testcase.rb +478 -0
  105. data/test-unit/test/test_testresult.rb +113 -0
  106. data/test-unit/test/test_testsuite.rb +129 -0
  107. data/test-unit/test/testunit-test-util.rb +14 -0
  108. data/test-unit/test/ui/test_testrunmediator.rb +20 -0
  109. data/test-unit/test/util/test-method-owner-finder.rb +38 -0
  110. data/test-unit/test/util/test_backtracefilter.rb +41 -0
  111. data/test-unit/test/util/test_observable.rb +102 -0
  112. data/test-unit/test/util/test_procwrapper.rb +36 -0
  113. data/test/active-groonga-test-utils.rb +234 -0
  114. data/test/fixtures/bookmark.rb +2 -0
  115. data/test/fixtures/task.rb +2 -0
  116. data/test/fixtures/user.rb +2 -0
  117. data/test/run-test.rb +51 -0
  118. data/test/test-associations.rb +24 -0
  119. data/test/test-base.rb +194 -0
  120. data/test/test-schema.rb +49 -0
  121. metadata +192 -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,8 @@
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
@@ -0,0 +1,360 @@
1
+ #--
2
+ #
3
+ # Author:: Nathaniel Talbott.
4
+ # Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved.
5
+ # License:: Ruby license.
6
+
7
+ require 'test/unit/attribute'
8
+ require 'test/unit/fixture'
9
+ require 'test/unit/exceptionhandler'
10
+ require 'test/unit/assertions'
11
+ require 'test/unit/failure'
12
+ require 'test/unit/error'
13
+ require 'test/unit/pending'
14
+ require 'test/unit/omission'
15
+ require 'test/unit/notification'
16
+ require 'test/unit/priority'
17
+ require 'test/unit/testsuite'
18
+ require 'test/unit/assertionfailederror'
19
+ require 'test/unit/util/backtracefilter'
20
+ require 'test/unit/util/method-owner-finder'
21
+
22
+ module Test
23
+ module Unit
24
+
25
+ # Ties everything together. If you subclass and add your own
26
+ # test methods, it takes care of making them into tests and
27
+ # wrapping those tests into a suite. It also does the
28
+ # nitty-gritty of actually running an individual test and
29
+ # collecting its results into a Test::Unit::TestResult object.
30
+ #
31
+ # You can run two hooks before/after a TestCase run.
32
+ #
33
+ # Example:
34
+ # class TestMyClass < Test::Unit::TestCase
35
+ # class << self
36
+ # def startup
37
+ # ...
38
+ # end
39
+ #
40
+ # def shutdown
41
+ # ...
42
+ # end
43
+ # end
44
+ #
45
+ # def setup
46
+ # ...
47
+ # end
48
+ #
49
+ # def teardown
50
+ # ...
51
+ # end
52
+ #
53
+ # def test_my_method1
54
+ # ...
55
+ # end
56
+ #
57
+ # def test_my_method2
58
+ # ...
59
+ # end
60
+ # end
61
+ #
62
+ # Here is a call order:
63
+ # * startup
64
+ # * setup
65
+ # * test_my_method1
66
+ # * teardown
67
+ # * setup
68
+ # * test_my_method2
69
+ # * teardown
70
+ # * shutdown
71
+ class TestCase
72
+ include Attribute
73
+ include Fixture
74
+ include ExceptionHandler
75
+ include ErrorHandler
76
+ include FailureHandler
77
+ include TestCasePendingSupport
78
+ include TestCaseOmissionSupport
79
+ include TestCaseNotificationSupport
80
+ include Priority
81
+ include Assertions
82
+ include Util::BacktraceFilter
83
+
84
+ STARTED = name + "::STARTED"
85
+ FINISHED = name + "::FINISHED"
86
+
87
+ DESCENDANTS = []
88
+
89
+ class << self
90
+ def inherited(sub_class)
91
+ DESCENDANTS << sub_class
92
+ end
93
+
94
+ # Rolls up all of the test* methods in the fixture into
95
+ # one suite, creating a new instance of the fixture for
96
+ # each method.
97
+ def suite
98
+ method_names = public_instance_methods(true).collect {|name| name.to_s}
99
+ tests = method_names.delete_if {|method_name| method_name !~ /^test./}
100
+ suite = TestSuite.new(name, self)
101
+ tests.sort.each do |test|
102
+ catch(:invalid_test) do
103
+ suite << new(test)
104
+ end
105
+ end
106
+ if suite.empty?
107
+ catch(:invalid_test) do
108
+ suite << new("default_test")
109
+ end
110
+ end
111
+ suite
112
+ end
113
+
114
+ # Called before every test case runs. Can be used
115
+ # to set up fixture information used in test case
116
+ # scope.
117
+ #
118
+ # Here is an example test case:
119
+ # class TestMyClass < Test::Unit::TestCase
120
+ # class << self
121
+ # def startup
122
+ # ...
123
+ # end
124
+ # end
125
+ #
126
+ # def setup
127
+ # ...
128
+ # end
129
+ #
130
+ # def test_my_class1
131
+ # ...
132
+ # end
133
+ #
134
+ # def test_my_class2
135
+ # ...
136
+ # end
137
+ # end
138
+ #
139
+ # Here is a call order:
140
+ # * startup
141
+ # * setup
142
+ # * test_my_class1 (or test_my_class2)
143
+ # * setup
144
+ # * test_my_class2 (or test_my_class1)
145
+ #
146
+ # Note that you should not assume test order. Tests
147
+ # should be worked in any order.
148
+ def startup
149
+ end
150
+
151
+ # Called after every test case runs. Can be used to tear
152
+ # down fixture information used in test case scope.
153
+ #
154
+ # Here is an example test case:
155
+ # class TestMyClass < Test::Unit::TestCase
156
+ # class << self
157
+ # def shutdown
158
+ # ...
159
+ # end
160
+ # end
161
+ #
162
+ # def teardown
163
+ # ...
164
+ # end
165
+ #
166
+ # def test_my_class1
167
+ # ...
168
+ # end
169
+ #
170
+ # def test_my_class2
171
+ # ...
172
+ # end
173
+ # end
174
+ #
175
+ # Here is a call order:
176
+ # * test_my_class1 (or test_my_class2)
177
+ # * teardown
178
+ # * test_my_class2 (or test_my_class1)
179
+ # * teardown
180
+ # * shutdown
181
+ #
182
+ # Note that you should not assume test order. Tests
183
+ # should be worked in any order.
184
+ def shutdown
185
+ end
186
+ end
187
+
188
+ attr_reader :method_name
189
+
190
+ # Creates a new instance of the fixture for running the
191
+ # test represented by test_method_name.
192
+ def initialize(test_method_name)
193
+ throw :invalid_test unless respond_to?(test_method_name)
194
+ test_method = method(test_method_name)
195
+ throw :invalid_test if test_method.arity > 0
196
+ owner = Util::MethodOwnerFinder.find(self, test_method_name)
197
+ if owner.class != Module and self.class != owner
198
+ throw :invalid_test
199
+ end
200
+ @method_name = test_method_name
201
+ @test_passed = true
202
+ @interrupted = false
203
+ end
204
+
205
+ # Runs the individual test method represented by this
206
+ # instance of the fixture, collecting statistics, failures
207
+ # and errors in result.
208
+ def run(result)
209
+ begin
210
+ @_result = result
211
+ yield(STARTED, name)
212
+ begin
213
+ run_setup
214
+ run_test
215
+ rescue Exception
216
+ @interrupted = true
217
+ raise unless handle_exception($!)
218
+ ensure
219
+ begin
220
+ run_teardown
221
+ rescue Exception
222
+ raise unless handle_exception($!)
223
+ end
224
+ end
225
+ result.add_run
226
+ yield(FINISHED, name)
227
+ ensure
228
+ @_result = nil
229
+ end
230
+ end
231
+
232
+ # Called before every test method runs. Can be used
233
+ # to set up fixture information.
234
+ #
235
+ # You can add additional setup tasks by the following
236
+ # code:
237
+ # class TestMyClass < Test::Unit::TestCase
238
+ # def setup
239
+ # ...
240
+ # end
241
+ #
242
+ # setup
243
+ # def my_setup1
244
+ # ...
245
+ # end
246
+ #
247
+ # setup
248
+ # def my_setup2
249
+ # ...
250
+ # end
251
+ #
252
+ # def test_my_class
253
+ # ...
254
+ # end
255
+ # end
256
+ #
257
+ # Here is a call order:
258
+ # * setup
259
+ # * my_setup1
260
+ # * my_setup2
261
+ # * test_my_class
262
+ def setup
263
+ end
264
+
265
+ # Called after every test method runs. Can be used to tear
266
+ # down fixture information.
267
+ #
268
+ # You can add additional teardown tasks by the following
269
+ # code:
270
+ # class TestMyClass < Test::Unit::TestCase
271
+ # def teardown
272
+ # ...
273
+ # end
274
+ #
275
+ # teardown
276
+ # def my_teardown1
277
+ # ...
278
+ # end
279
+ #
280
+ # teardown
281
+ # def my_teardown2
282
+ # ...
283
+ # end
284
+ #
285
+ # def test_my_class
286
+ # ...
287
+ # end
288
+ # end
289
+ #
290
+ # Here is a call order:
291
+ # * test_my_class
292
+ # * my_teardown2
293
+ # * my_teardown1
294
+ # * teardown
295
+ def teardown
296
+ end
297
+
298
+ def default_test
299
+ flunk("No tests were specified")
300
+ end
301
+
302
+ def size
303
+ 1
304
+ end
305
+
306
+ # Returns a human-readable name for the specific test that
307
+ # this instance of TestCase represents.
308
+ def name
309
+ "#{@method_name}(#{self.class.name})"
310
+ end
311
+
312
+ # Overridden to return #name.
313
+ def to_s
314
+ name
315
+ end
316
+
317
+ # It's handy to be able to compare TestCase instances.
318
+ def ==(other)
319
+ return false unless(other.kind_of?(self.class))
320
+ return false unless(@method_name == other.method_name)
321
+ self.class == other.class
322
+ end
323
+
324
+ def interrupted?
325
+ @interrupted
326
+ end
327
+
328
+ private
329
+ def current_result
330
+ @_result
331
+ end
332
+
333
+ def run_test
334
+ __send__(@method_name)
335
+ end
336
+
337
+ def handle_exception(exception)
338
+ self.class.exception_handlers.each do |handler|
339
+ return true if send(handler, exception)
340
+ end
341
+ false
342
+ end
343
+
344
+ # Returns whether this individual test passed or
345
+ # not. Primarily for use in teardown so that artifacts
346
+ # can be left behind if the test fails.
347
+ def passed?
348
+ @test_passed
349
+ end
350
+
351
+ def problem_occurred
352
+ @test_passed = false
353
+ end
354
+
355
+ def add_assertion
356
+ current_result.add_assertion
357
+ end
358
+ end
359
+ end
360
+ end
@@ -0,0 +1,89 @@
1
+ #--
2
+ # Author:: Nathaniel Talbott.
3
+ # Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
4
+ # License:: Ruby license.
5
+
6
+ require 'test/unit/util/observable'
7
+ require 'test/unit/failure'
8
+ require 'test/unit/error'
9
+ require 'test/unit/omission'
10
+ require 'test/unit/pending'
11
+ require 'test/unit/notification'
12
+
13
+ module Test
14
+ module Unit
15
+ module NullResultContainerInitializer
16
+ private
17
+ def initialize_containers
18
+ end
19
+ end
20
+
21
+ # Collects Test::Unit::Failure and Test::Unit::Error so that
22
+ # they can be displayed to the user. To this end, observers
23
+ # can be added to it, allowing the dynamic updating of, say, a
24
+ # UI.
25
+ class TestResult
26
+ include Util::Observable
27
+ include NullResultContainerInitializer
28
+ include TestResultFailureSupport
29
+ include TestResultErrorSupport
30
+ include TestResultPendingSupport
31
+ include TestResultOmissionSupport
32
+ include TestResultNotificationSupport
33
+
34
+ CHANGED = "CHANGED"
35
+ FAULT = "FAULT"
36
+
37
+ attr_reader :run_count, :assertion_count, :faults
38
+
39
+ # Constructs a new, empty TestResult.
40
+ def initialize
41
+ @run_count, @assertion_count = 0, 0
42
+ @summary_generators = []
43
+ @problem_checkers = []
44
+ @faults = []
45
+ initialize_containers
46
+ end
47
+
48
+ # Records a test run.
49
+ def add_run
50
+ @run_count += 1
51
+ notify_changed
52
+ end
53
+
54
+ # Records an individual assertion.
55
+ def add_assertion
56
+ @assertion_count += 1
57
+ notify_changed
58
+ end
59
+
60
+ # Returns a string contain the recorded runs, assertions,
61
+ # failures and errors in this TestResult.
62
+ def summary
63
+ ["#{run_count} tests",
64
+ "#{assertion_count} assertions",
65
+ *@summary_generators.collect {|generator| send(generator)}].join(", ")
66
+ end
67
+
68
+ def to_s
69
+ summary
70
+ end
71
+
72
+ # Returns whether or not this TestResult represents
73
+ # successful completion.
74
+ def passed?
75
+ @problem_checkers.all? {|checker| not send(checker)}
76
+ end
77
+
78
+ private
79
+ def notify_changed
80
+ notify_listeners(CHANGED, self)
81
+ end
82
+
83
+ def notify_fault(fault)
84
+ @faults << fault
85
+ notify_listeners(FAULT, fault)
86
+ end
87
+ end
88
+ end
89
+ end