activeldap 1.2.2 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. data/CHANGES +24 -0
  2. data/README +9 -3
  3. data/Rakefile +24 -50
  4. data/examples/al-admin/Rakefile +6 -0
  5. data/examples/al-admin/app/controllers/application_controller.rb +9 -2
  6. data/examples/al-admin/config/environment.rb +9 -3
  7. data/examples/al-admin/config/initializers/fast_gettext.rb +3 -0
  8. data/examples/al-admin/config/session_secret.txt +1 -1
  9. data/lib/active_ldap.rb +6 -19
  10. data/lib/active_ldap/adapter/base.rb +22 -20
  11. data/lib/active_ldap/adapter/jndi.rb +2 -3
  12. data/lib/active_ldap/adapter/jndi_connection.rb +2 -2
  13. data/lib/active_ldap/adapter/ldap.rb +9 -4
  14. data/lib/active_ldap/adapter/net_ldap.rb +5 -4
  15. data/lib/active_ldap/base.rb +1 -1
  16. data/lib/active_ldap/get_text.rb +2 -2
  17. data/lib/active_ldap/get_text_fallback.rb +39 -32
  18. data/lib/active_ldap/get_text_support.rb +4 -2
  19. data/lib/active_ldap/operations.rb +3 -2
  20. data/lib/active_ldap/validations.rb +11 -21
  21. data/po/en/active-ldap.po +9 -9
  22. data/po/ja/active-ldap.po +18 -18
  23. data/test/run-test.rb +7 -1
  24. data/test/test_adapter.rb +1 -0
  25. data/test/test_base.rb +8 -1
  26. data/test/test_load.rb +2 -1
  27. data/test/test_user.rb +3 -4
  28. data/test/test_validation.rb +20 -23
  29. metadata +34 -228
  30. data/data/locale/en/LC_MESSAGES/active-ldap.mo +0 -0
  31. data/data/locale/ja/LC_MESSAGES/active-ldap.mo +0 -0
  32. data/examples/al-admin/config/initializers/gettext.rb +0 -1
  33. data/examples/al-admin/lib/tasks/gettext.rake +0 -36
  34. data/examples/al-admin/locale/en/LC_MESSAGES/al-admin.mo +0 -0
  35. data/examples/al-admin/locale/ja/LC_MESSAGES/al-admin.mo +0 -0
  36. data/examples/al-admin/locale/nl/LC_MESSAGES/al-admin.mo +0 -0
  37. data/examples/al-admin/po/al-admin.pot +0 -344
  38. data/examples/al-admin/public/images/active-ldap.png +0 -0
  39. data/examples/al-admin/vendor/locale_rails/.gitignore +0 -6
  40. data/examples/al-admin/vendor/locale_rails/COPYING +0 -56
  41. data/examples/al-admin/vendor/locale_rails/ChangeLog +0 -35
  42. data/examples/al-admin/vendor/locale_rails/README.rdoc +0 -62
  43. data/examples/al-admin/vendor/locale_rails/Rakefile +0 -73
  44. data/examples/al-admin/vendor/locale_rails/lib/locale_rails.rb +0 -18
  45. data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_controller.rb +0 -15
  46. data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_controller/base.rb +0 -82
  47. data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_controller/caching.rb +0 -51
  48. data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_controller/test_process.rb +0 -44
  49. data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_view.rb +0 -53
  50. data/examples/al-admin/vendor/locale_rails/lib/locale_rails/i18n.rb +0 -67
  51. data/examples/al-admin/vendor/locale_rails/lib/locale_rails/version.rb +0 -4
  52. data/examples/al-admin/vendor/locale_rails/sample/README +0 -22
  53. data/examples/al-admin/vendor/locale_rails/sample/Rakefile +0 -10
  54. data/examples/al-admin/vendor/locale_rails/sample/app/controllers/application.rb +0 -42
  55. data/examples/al-admin/vendor/locale_rails/sample/app/controllers/samples_controller.rb +0 -30
  56. data/examples/al-admin/vendor/locale_rails/sample/app/helpers/application_helper.rb +0 -3
  57. data/examples/al-admin/vendor/locale_rails/sample/app/views/layouts/samples.html.erb +0 -20
  58. data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/_part.html.erb +0 -68
  59. data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/_part_nl.html.erb +0 -2
  60. data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/cached_action.html.erb +0 -6
  61. data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/index.html.erb +0 -33
  62. data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/index.pt.html.erb +0 -16
  63. data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/index_uz_UZ.html.erb +0 -16
  64. data/examples/al-admin/vendor/locale_rails/sample/config/boot.rb +0 -109
  65. data/examples/al-admin/vendor/locale_rails/sample/config/environment.rb +0 -25
  66. data/examples/al-admin/vendor/locale_rails/sample/config/environments/development.rb +0 -17
  67. data/examples/al-admin/vendor/locale_rails/sample/config/environments/production.rb +0 -24
  68. data/examples/al-admin/vendor/locale_rails/sample/config/environments/test.rb +0 -22
  69. data/examples/al-admin/vendor/locale_rails/sample/config/initializers/inflections.rb +0 -10
  70. data/examples/al-admin/vendor/locale_rails/sample/config/initializers/mime_types.rb +0 -5
  71. data/examples/al-admin/vendor/locale_rails/sample/config/initializers/new_rails_defaults.rb +0 -17
  72. data/examples/al-admin/vendor/locale_rails/sample/config/locales/en.yml +0 -2
  73. data/examples/al-admin/vendor/locale_rails/sample/config/locales/ja.yml +0 -2
  74. data/examples/al-admin/vendor/locale_rails/sample/config/routes.rb +0 -13
  75. data/examples/al-admin/vendor/locale_rails/sample/db/schema.rb +0 -10
  76. data/examples/al-admin/vendor/locale_rails/sample/public/404.html +0 -30
  77. data/examples/al-admin/vendor/locale_rails/sample/public/422.html +0 -30
  78. data/examples/al-admin/vendor/locale_rails/sample/public/500.html +0 -33
  79. data/examples/al-admin/vendor/locale_rails/sample/public/dispatch.cgi +0 -10
  80. data/examples/al-admin/vendor/locale_rails/sample/public/dispatch.fcgi +0 -24
  81. data/examples/al-admin/vendor/locale_rails/sample/public/dispatch.rb +0 -10
  82. data/examples/al-admin/vendor/locale_rails/sample/public/favicon.ico +0 -0
  83. data/examples/al-admin/vendor/locale_rails/sample/public/images/rails.png +0 -0
  84. data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/application.js +0 -2
  85. data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/controls.js +0 -963
  86. data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/dragdrop.js +0 -972
  87. data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/effects.js +0 -1120
  88. data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/prototype.js +0 -4221
  89. data/examples/al-admin/vendor/locale_rails/sample/public/robots.txt +0 -5
  90. data/examples/al-admin/vendor/locale_rails/sample/public/stylesheets/locale.css +0 -81
  91. data/examples/al-admin/vendor/locale_rails/sample/public/stylesheets/scaffold.css +0 -74
  92. data/examples/al-admin/vendor/locale_rails/sample/script/about +0 -4
  93. data/examples/al-admin/vendor/locale_rails/sample/script/console +0 -3
  94. data/examples/al-admin/vendor/locale_rails/sample/script/dbconsole +0 -3
  95. data/examples/al-admin/vendor/locale_rails/sample/script/destroy +0 -3
  96. data/examples/al-admin/vendor/locale_rails/sample/script/generate +0 -3
  97. data/examples/al-admin/vendor/locale_rails/sample/script/performance/benchmarker +0 -3
  98. data/examples/al-admin/vendor/locale_rails/sample/script/performance/profiler +0 -3
  99. data/examples/al-admin/vendor/locale_rails/sample/script/performance/request +0 -3
  100. data/examples/al-admin/vendor/locale_rails/sample/script/plugin +0 -3
  101. data/examples/al-admin/vendor/locale_rails/sample/script/process/inspector +0 -3
  102. data/examples/al-admin/vendor/locale_rails/sample/script/process/reaper +0 -3
  103. data/examples/al-admin/vendor/locale_rails/sample/script/process/spawner +0 -3
  104. data/examples/al-admin/vendor/locale_rails/sample/script/runner +0 -3
  105. data/examples/al-admin/vendor/locale_rails/sample/script/server +0 -3
  106. data/examples/al-admin/vendor/locale_rails/sample/test/performance/browsing_test.rb +0 -9
  107. data/examples/al-admin/vendor/locale_rails/sample/test/test_helper.rb +0 -38
  108. data/examples/al-admin/vendor/locale_rails/test/README +0 -243
  109. data/examples/al-admin/vendor/locale_rails/test/Rakefile +0 -10
  110. data/examples/al-admin/vendor/locale_rails/test/app/controllers/application_controller.rb +0 -10
  111. data/examples/al-admin/vendor/locale_rails/test/app/controllers/articles_controller.rb +0 -17
  112. data/examples/al-admin/vendor/locale_rails/test/app/helpers/application_helper.rb +0 -3
  113. data/examples/al-admin/vendor/locale_rails/test/app/views/articles/index.html.erb +0 -1
  114. data/examples/al-admin/vendor/locale_rails/test/app/views/articles/index_de.html.erb +0 -1
  115. data/examples/al-admin/vendor/locale_rails/test/app/views/articles/index_fr_FR.html.erb +0 -1
  116. data/examples/al-admin/vendor/locale_rails/test/app/views/articles/index_ja.html.erb +0 -1
  117. data/examples/al-admin/vendor/locale_rails/test/app/views/articles/list.html.erb +0 -1
  118. data/examples/al-admin/vendor/locale_rails/test/app/views/articles/show.html.erb +0 -0
  119. data/examples/al-admin/vendor/locale_rails/test/app/views/articles/show.js.rjs +0 -0
  120. data/examples/al-admin/vendor/locale_rails/test/config/boot.rb +0 -110
  121. data/examples/al-admin/vendor/locale_rails/test/config/environment.rb +0 -42
  122. data/examples/al-admin/vendor/locale_rails/test/config/environments/development.rb +0 -17
  123. data/examples/al-admin/vendor/locale_rails/test/config/environments/production.rb +0 -28
  124. data/examples/al-admin/vendor/locale_rails/test/config/environments/test.rb +0 -35
  125. data/examples/al-admin/vendor/locale_rails/test/config/initializers/backtrace_silencers.rb +0 -7
  126. data/examples/al-admin/vendor/locale_rails/test/config/initializers/inflections.rb +0 -10
  127. data/examples/al-admin/vendor/locale_rails/test/config/initializers/mime_types.rb +0 -5
  128. data/examples/al-admin/vendor/locale_rails/test/config/initializers/new_rails_defaults.rb +0 -19
  129. data/examples/al-admin/vendor/locale_rails/test/config/initializers/session_store.rb +0 -15
  130. data/examples/al-admin/vendor/locale_rails/test/config/locales/en.yml +0 -5
  131. data/examples/al-admin/vendor/locale_rails/test/config/routes.rb +0 -46
  132. data/examples/al-admin/vendor/locale_rails/test/db/schema.rb +0 -0
  133. data/examples/al-admin/vendor/locale_rails/test/public/404.html +0 -30
  134. data/examples/al-admin/vendor/locale_rails/test/public/422.html +0 -30
  135. data/examples/al-admin/vendor/locale_rails/test/public/500.html +0 -30
  136. data/examples/al-admin/vendor/locale_rails/test/public/favicon.ico +0 -0
  137. data/examples/al-admin/vendor/locale_rails/test/public/images/rails.png +0 -0
  138. data/examples/al-admin/vendor/locale_rails/test/public/index.html +0 -275
  139. data/examples/al-admin/vendor/locale_rails/test/public/javascripts/application.js +0 -2
  140. data/examples/al-admin/vendor/locale_rails/test/public/javascripts/controls.js +0 -963
  141. data/examples/al-admin/vendor/locale_rails/test/public/javascripts/dragdrop.js +0 -973
  142. data/examples/al-admin/vendor/locale_rails/test/public/javascripts/effects.js +0 -1128
  143. data/examples/al-admin/vendor/locale_rails/test/public/javascripts/prototype.js +0 -4320
  144. data/examples/al-admin/vendor/locale_rails/test/public/robots.txt +0 -5
  145. data/examples/al-admin/vendor/locale_rails/test/script/about +0 -4
  146. data/examples/al-admin/vendor/locale_rails/test/script/console +0 -3
  147. data/examples/al-admin/vendor/locale_rails/test/script/dbconsole +0 -3
  148. data/examples/al-admin/vendor/locale_rails/test/script/destroy +0 -3
  149. data/examples/al-admin/vendor/locale_rails/test/script/generate +0 -3
  150. data/examples/al-admin/vendor/locale_rails/test/script/performance/benchmarker +0 -3
  151. data/examples/al-admin/vendor/locale_rails/test/script/performance/profiler +0 -3
  152. data/examples/al-admin/vendor/locale_rails/test/script/plugin +0 -3
  153. data/examples/al-admin/vendor/locale_rails/test/script/runner +0 -3
  154. data/examples/al-admin/vendor/locale_rails/test/script/server +0 -3
  155. data/examples/al-admin/vendor/locale_rails/test/test/functional/articles_controller_test.rb +0 -161
  156. data/examples/al-admin/vendor/locale_rails/test/test/performance/browsing_test.rb +0 -9
  157. data/examples/al-admin/vendor/locale_rails/test/test/test_helper.rb +0 -38
  158. data/po/active-ldap.pot +0 -4010
  159. data/test-unit/COPYING +0 -56
  160. data/test-unit/GPL +0 -340
  161. data/test-unit/History.txt +0 -223
  162. data/test-unit/Manifest.txt +0 -87
  163. data/test-unit/PSFL +0 -271
  164. data/test-unit/README.txt +0 -60
  165. data/test-unit/Rakefile +0 -40
  166. data/test-unit/TODO +0 -5
  167. data/test-unit/bin/testrb +0 -5
  168. data/test-unit/images/color-diff.png +0 -0
  169. data/test-unit/lib/test/unit.rb +0 -328
  170. data/test-unit/lib/test/unit/assertionfailederror.rb +0 -25
  171. data/test-unit/lib/test/unit/assertions.rb +0 -1334
  172. data/test-unit/lib/test/unit/attribute.rb +0 -125
  173. data/test-unit/lib/test/unit/autorunner.rb +0 -360
  174. data/test-unit/lib/test/unit/collector.rb +0 -36
  175. data/test-unit/lib/test/unit/collector/descendant.rb +0 -23
  176. data/test-unit/lib/test/unit/collector/dir.rb +0 -108
  177. data/test-unit/lib/test/unit/collector/load.rb +0 -144
  178. data/test-unit/lib/test/unit/collector/objectspace.rb +0 -34
  179. data/test-unit/lib/test/unit/color-scheme.rb +0 -106
  180. data/test-unit/lib/test/unit/color.rb +0 -96
  181. data/test-unit/lib/test/unit/diff.rb +0 -740
  182. data/test-unit/lib/test/unit/error.rb +0 -130
  183. data/test-unit/lib/test/unit/exceptionhandler.rb +0 -39
  184. data/test-unit/lib/test/unit/failure.rb +0 -136
  185. data/test-unit/lib/test/unit/fixture.rb +0 -176
  186. data/test-unit/lib/test/unit/notification.rb +0 -129
  187. data/test-unit/lib/test/unit/omission.rb +0 -191
  188. data/test-unit/lib/test/unit/pending.rb +0 -150
  189. data/test-unit/lib/test/unit/priority.rb +0 -180
  190. data/test-unit/lib/test/unit/runner/console.rb +0 -52
  191. data/test-unit/lib/test/unit/runner/emacs.rb +0 -8
  192. data/test-unit/lib/test/unit/runner/tap.rb +0 -8
  193. data/test-unit/lib/test/unit/testcase.rb +0 -478
  194. data/test-unit/lib/test/unit/testresult.rb +0 -89
  195. data/test-unit/lib/test/unit/testsuite.rb +0 -110
  196. data/test-unit/lib/test/unit/ui/console/outputlevel.rb +0 -14
  197. data/test-unit/lib/test/unit/ui/console/testrunner.rb +0 -466
  198. data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +0 -63
  199. data/test-unit/lib/test/unit/ui/tap/testrunner.rb +0 -92
  200. data/test-unit/lib/test/unit/ui/testrunner.rb +0 -28
  201. data/test-unit/lib/test/unit/ui/testrunnermediator.rb +0 -77
  202. data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +0 -41
  203. data/test-unit/lib/test/unit/util/backtracefilter.rb +0 -42
  204. data/test-unit/lib/test/unit/util/method-owner-finder.rb +0 -28
  205. data/test-unit/lib/test/unit/util/observable.rb +0 -90
  206. data/test-unit/lib/test/unit/util/output.rb +0 -31
  207. data/test-unit/lib/test/unit/util/procwrapper.rb +0 -48
  208. data/test-unit/lib/test/unit/version.rb +0 -7
  209. data/test-unit/sample/adder.rb +0 -13
  210. data/test-unit/sample/subtracter.rb +0 -12
  211. data/test-unit/sample/test_adder.rb +0 -20
  212. data/test-unit/sample/test_subtracter.rb +0 -20
  213. data/test-unit/sample/test_user.rb +0 -23
  214. data/test-unit/test/collector/test-descendant.rb +0 -133
  215. data/test-unit/test/collector/test-load.rb +0 -442
  216. data/test-unit/test/collector/test_dir.rb +0 -406
  217. data/test-unit/test/collector/test_objectspace.rb +0 -100
  218. data/test-unit/test/run-test.rb +0 -15
  219. data/test-unit/test/test-attribute.rb +0 -86
  220. data/test-unit/test/test-color-scheme.rb +0 -69
  221. data/test-unit/test/test-color.rb +0 -47
  222. data/test-unit/test/test-diff.rb +0 -518
  223. data/test-unit/test/test-emacs-runner.rb +0 -60
  224. data/test-unit/test/test-fixture.rb +0 -287
  225. data/test-unit/test/test-notification.rb +0 -33
  226. data/test-unit/test/test-omission.rb +0 -81
  227. data/test-unit/test/test-pending.rb +0 -70
  228. data/test-unit/test/test-priority.rb +0 -119
  229. data/test-unit/test/test-testcase.rb +0 -544
  230. data/test-unit/test/test_assertions.rb +0 -1197
  231. data/test-unit/test/test_error.rb +0 -26
  232. data/test-unit/test/test_failure.rb +0 -33
  233. data/test-unit/test/test_testresult.rb +0 -113
  234. data/test-unit/test/test_testsuite.rb +0 -129
  235. data/test-unit/test/testunit-test-util.rb +0 -14
  236. data/test-unit/test/ui/test_testrunmediator.rb +0 -20
  237. data/test-unit/test/util/test-method-owner-finder.rb +0 -38
  238. data/test-unit/test/util/test-output.rb +0 -11
  239. data/test-unit/test/util/test_backtracefilter.rb +0 -41
  240. data/test-unit/test/util/test_observable.rb +0 -102
  241. 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,478 +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
- end
454
-
455
- def handle_exception(exception)
456
- self.class.exception_handlers.each do |handler|
457
- return true if send(handler, exception)
458
- end
459
- false
460
- end
461
-
462
- # Returns whether this individual test passed or
463
- # not. Primarily for use in teardown so that artifacts
464
- # can be left behind if the test fails.
465
- def passed?
466
- @test_passed
467
- end
468
-
469
- def problem_occurred
470
- @test_passed = false
471
- end
472
-
473
- def add_assertion
474
- current_result.add_assertion
475
- end
476
- end
477
- end
478
- end