ActiveSambaLdap 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. data/NEWS.en +40 -0
  2. data/NEWS.ja +44 -0
  3. data/README.en +366 -0
  4. data/README.ja +361 -0
  5. data/Rakefile +168 -0
  6. data/bin/asl-groupadd +73 -0
  7. data/bin/asl-groupadd.help +1 -0
  8. data/bin/asl-groupdel +61 -0
  9. data/bin/asl-groupdel.help +1 -0
  10. data/bin/asl-groupmod +137 -0
  11. data/bin/asl-groupmod.help +1 -0
  12. data/bin/asl-groupshow +33 -0
  13. data/bin/asl-groupshow.help +1 -0
  14. data/bin/asl-passwd +90 -0
  15. data/bin/asl-passwd.help +1 -0
  16. data/bin/asl-populate +101 -0
  17. data/bin/asl-populate.help +1 -0
  18. data/bin/asl-purge +26 -0
  19. data/bin/asl-purge.help +1 -0
  20. data/bin/asl-samba-computeradd +96 -0
  21. data/bin/asl-samba-computeradd.help +1 -0
  22. data/bin/asl-samba-groupadd +57 -0
  23. data/bin/asl-samba-groupadd.help +1 -0
  24. data/bin/asl-samba-groupdel +55 -0
  25. data/bin/asl-samba-groupdel.help +1 -0
  26. data/bin/asl-samba-groupmod +99 -0
  27. data/bin/asl-samba-groupmod.help +1 -0
  28. data/bin/asl-samba-useradd +100 -0
  29. data/bin/asl-samba-useradd.help +1 -0
  30. data/bin/asl-samba-userdel +49 -0
  31. data/bin/asl-samba-userdel.help +1 -0
  32. data/bin/asl-samba-usermod +94 -0
  33. data/bin/asl-samba-usermod.help +1 -0
  34. data/bin/asl-useradd +264 -0
  35. data/bin/asl-useradd.help +1 -0
  36. data/bin/asl-userdel +84 -0
  37. data/bin/asl-userdel.help +1 -0
  38. data/bin/asl-usermod +335 -0
  39. data/bin/asl-usermod.help +1 -0
  40. data/bin/asl-usershow +33 -0
  41. data/bin/asl-usershow.help +1 -0
  42. data/lib/active_samba_ldap.rb +42 -0
  43. data/lib/active_samba_ldap/account_entry.rb +208 -0
  44. data/lib/active_samba_ldap/base.rb +137 -0
  45. data/lib/active_samba_ldap/command.rb +100 -0
  46. data/lib/active_samba_ldap/computer.rb +24 -0
  47. data/lib/active_samba_ldap/computer_account_entry.rb +34 -0
  48. data/lib/active_samba_ldap/configuration.rb +333 -0
  49. data/lib/active_samba_ldap/dc.rb +19 -0
  50. data/lib/active_samba_ldap/entry.rb +81 -0
  51. data/lib/active_samba_ldap/get_text_support.rb +12 -0
  52. data/lib/active_samba_ldap/group.rb +17 -0
  53. data/lib/active_samba_ldap/group_entry.rb +187 -0
  54. data/lib/active_samba_ldap/idmap.rb +19 -0
  55. data/lib/active_samba_ldap/ou.rb +20 -0
  56. data/lib/active_samba_ldap/populate.rb +257 -0
  57. data/lib/active_samba_ldap/reloadable.rb +15 -0
  58. data/lib/active_samba_ldap/samba_account_entry.rb +225 -0
  59. data/lib/active_samba_ldap/samba_entry.rb +26 -0
  60. data/lib/active_samba_ldap/samba_group_entry.rb +143 -0
  61. data/lib/active_samba_ldap/unix_id_pool.rb +43 -0
  62. data/lib/active_samba_ldap/user.rb +44 -0
  63. data/lib/active_samba_ldap/user_account_entry.rb +30 -0
  64. data/lib/active_samba_ldap/version.rb +3 -0
  65. data/lib/samba/encrypt.rb +86 -0
  66. data/misc/rd2html.rb +42 -0
  67. data/po/ja/active-samba-ldap.po +465 -0
  68. data/rails/README +30 -0
  69. data/rails/init.rb +33 -0
  70. data/rails_generators/scaffold_active_samba_ldap/scaffold_active_samba_ldap_generator.rb +27 -0
  71. data/rails_generators/scaffold_active_samba_ldap/templates/computer.rb +3 -0
  72. data/rails_generators/scaffold_active_samba_ldap/templates/dc.rb +3 -0
  73. data/rails_generators/scaffold_active_samba_ldap/templates/group.rb +3 -0
  74. data/rails_generators/scaffold_active_samba_ldap/templates/idmap.rb +3 -0
  75. data/rails_generators/scaffold_active_samba_ldap/templates/ldap.yml +24 -0
  76. data/rails_generators/scaffold_active_samba_ldap/templates/ou.rb +3 -0
  77. data/rails_generators/scaffold_active_samba_ldap/templates/samba_controller.rb +12 -0
  78. data/rails_generators/scaffold_active_samba_ldap/templates/samba_helper.rb +2 -0
  79. data/rails_generators/scaffold_active_samba_ldap/templates/samba_index.rhtml +17 -0
  80. data/rails_generators/scaffold_active_samba_ldap/templates/samba_populate.rhtml +15 -0
  81. data/rails_generators/scaffold_active_samba_ldap/templates/samba_purge.rhtml +10 -0
  82. data/rails_generators/scaffold_active_samba_ldap/templates/unix_id_pool.rb +3 -0
  83. data/rails_generators/scaffold_active_samba_ldap/templates/user.rb +3 -0
  84. data/setup.rb +1585 -0
  85. data/test-unit/History.txt +107 -0
  86. data/test-unit/README.txt +52 -0
  87. data/test-unit/Rakefile +40 -0
  88. data/test-unit/TODO +5 -0
  89. data/test-unit/bin/testrb +5 -0
  90. data/test-unit/lib/test/unit.rb +342 -0
  91. data/test-unit/lib/test/unit/assertionfailederror.rb +14 -0
  92. data/test-unit/lib/test/unit/assertions.rb +1149 -0
  93. data/test-unit/lib/test/unit/attribute.rb +125 -0
  94. data/test-unit/lib/test/unit/autorunner.rb +329 -0
  95. data/test-unit/lib/test/unit/collector.rb +43 -0
  96. data/test-unit/lib/test/unit/collector/descendant.rb +23 -0
  97. data/test-unit/lib/test/unit/collector/dir.rb +108 -0
  98. data/test-unit/lib/test/unit/collector/load.rb +135 -0
  99. data/test-unit/lib/test/unit/collector/objectspace.rb +34 -0
  100. data/test-unit/lib/test/unit/color-scheme.rb +86 -0
  101. data/test-unit/lib/test/unit/color.rb +96 -0
  102. data/test-unit/lib/test/unit/diff.rb +538 -0
  103. data/test-unit/lib/test/unit/error.rb +124 -0
  104. data/test-unit/lib/test/unit/exceptionhandler.rb +39 -0
  105. data/test-unit/lib/test/unit/failure.rb +110 -0
  106. data/test-unit/lib/test/unit/fixture.rb +176 -0
  107. data/test-unit/lib/test/unit/notification.rb +125 -0
  108. data/test-unit/lib/test/unit/omission.rb +143 -0
  109. data/test-unit/lib/test/unit/pending.rb +146 -0
  110. data/test-unit/lib/test/unit/priority.rb +181 -0
  111. data/test-unit/lib/test/unit/runner/console.rb +52 -0
  112. data/test-unit/lib/test/unit/runner/emacs.rb +8 -0
  113. data/test-unit/lib/test/unit/testcase.rb +425 -0
  114. data/test-unit/lib/test/unit/testresult.rb +89 -0
  115. data/test-unit/lib/test/unit/testsuite.rb +110 -0
  116. data/test-unit/lib/test/unit/ui/console/outputlevel.rb +14 -0
  117. data/test-unit/lib/test/unit/ui/console/testrunner.rb +223 -0
  118. data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +49 -0
  119. data/test-unit/lib/test/unit/ui/testrunner.rb +20 -0
  120. data/test-unit/lib/test/unit/ui/testrunnermediator.rb +77 -0
  121. data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +41 -0
  122. data/test-unit/lib/test/unit/util/backtracefilter.rb +41 -0
  123. data/test-unit/lib/test/unit/util/method-owner-finder.rb +28 -0
  124. data/test-unit/lib/test/unit/util/observable.rb +90 -0
  125. data/test-unit/lib/test/unit/util/procwrapper.rb +48 -0
  126. data/test-unit/lib/test/unit/version.rb +7 -0
  127. data/test-unit/sample/adder.rb +13 -0
  128. data/test-unit/sample/subtracter.rb +12 -0
  129. data/test-unit/sample/tc_adder.rb +18 -0
  130. data/test-unit/sample/tc_subtracter.rb +18 -0
  131. data/test-unit/sample/test_user.rb +22 -0
  132. data/test-unit/sample/ts_examples.rb +7 -0
  133. data/test-unit/test/collector/test-descendant.rb +135 -0
  134. data/test-unit/test/collector/test-load.rb +333 -0
  135. data/test-unit/test/collector/test_dir.rb +406 -0
  136. data/test-unit/test/collector/test_objectspace.rb +98 -0
  137. data/test-unit/test/run-test.rb +13 -0
  138. data/test-unit/test/test-attribute.rb +86 -0
  139. data/test-unit/test/test-color-scheme.rb +56 -0
  140. data/test-unit/test/test-color.rb +47 -0
  141. data/test-unit/test/test-diff.rb +477 -0
  142. data/test-unit/test/test-emacs-runner.rb +60 -0
  143. data/test-unit/test/test-fixture.rb +287 -0
  144. data/test-unit/test/test-notification.rb +33 -0
  145. data/test-unit/test/test-omission.rb +81 -0
  146. data/test-unit/test/test-pending.rb +70 -0
  147. data/test-unit/test/test-priority.rb +119 -0
  148. data/test-unit/test/test-testcase.rb +507 -0
  149. data/test-unit/test/test_assertions.rb +1082 -0
  150. data/test-unit/test/test_error.rb +26 -0
  151. data/test-unit/test/test_failure.rb +33 -0
  152. data/test-unit/test/test_testresult.rb +113 -0
  153. data/test-unit/test/test_testsuite.rb +129 -0
  154. data/test-unit/test/testunit-test-util.rb +14 -0
  155. data/test-unit/test/ui/test_testrunmediator.rb +20 -0
  156. data/test-unit/test/util/test-method-owner-finder.rb +38 -0
  157. data/test-unit/test/util/test_backtracefilter.rb +41 -0
  158. data/test-unit/test/util/test_observable.rb +102 -0
  159. data/test-unit/test/util/test_procwrapper.rb +36 -0
  160. data/test/asl-test-utils.rb +276 -0
  161. data/test/command.rb +67 -0
  162. data/test/config.yaml.sample +17 -0
  163. data/test/run-test.rb +20 -0
  164. data/test/test_asl_groupadd.rb +69 -0
  165. data/test/test_asl_groupdel.rb +88 -0
  166. data/test/test_asl_groupmod.rb +259 -0
  167. data/test/test_asl_groupshow.rb +21 -0
  168. data/test/test_asl_passwd.rb +126 -0
  169. data/test/test_asl_populate.rb +92 -0
  170. data/test/test_asl_purge.rb +21 -0
  171. data/test/test_asl_useradd.rb +712 -0
  172. data/test/test_asl_userdel.rb +75 -0
  173. data/test/test_asl_usermod.rb +549 -0
  174. data/test/test_asl_usershow.rb +27 -0
  175. data/test/test_entry.rb +21 -0
  176. data/test/test_group.rb +21 -0
  177. data/test/test_password.rb +51 -0
  178. data/test/test_samba_encrypt.rb +35 -0
  179. data/test/test_user_home_directory.rb +43 -0
  180. metadata +314 -0
@@ -0,0 +1,107 @@
1
+ === 2.0.3 / 2009-07-17
2
+
3
+ * 6 major enhancements
4
+ * add assert_predicate.
5
+ * add assert_not_predicate.
6
+ * [#24210] assert_kind_of supports an array of classes or modules.
7
+ [Daniel Berger]
8
+ * assert_instance_of supports an array of classes or modules.
9
+ * add --default-priority option.
10
+ * [#26627] add --order option. [Daniel Berger]
11
+
12
+ * 4 minor enhancements
13
+ * use yellow foreground + black background for error.
14
+ * don't show diff for long string.
15
+ * accept "*term-color" TERM environment as colorizable terminal.
16
+ (e.g. Apple's Terminal)
17
+ * [#26268] add a workaround for test-spec's after_all. [Angelo Lakra]
18
+
19
+ * 1 bug fix
20
+ * [#23586] re-support ruby 1.9.1. [Diego Pettenò]
21
+
22
+ * Thanks
23
+ * Diego Pettenò
24
+ * Daniel Berger
25
+ * Angelo Lakra
26
+
27
+ === 2.0.2 / 2008-12-21
28
+
29
+ * 2 major enhancements
30
+
31
+ * re-support ruby 1.8.5.
32
+ * improve exception object comparison.
33
+
34
+ * 3 bug fixes
35
+
36
+ * [#22723]: collector fails on anonymous classes
37
+ * [#22986]: Test names with '?' blow up on Windows
38
+ * [#22988]: don't create .test-result on non-priority mode.
39
+
40
+ * Thanks
41
+
42
+ * Erik Hollensbe
43
+ * Daniel Berger
44
+ * Bill Lear
45
+
46
+ === 2.0.1 / 2008-11-09
47
+
48
+ * 19 major enhancements
49
+
50
+ * support ruby 1.9.1.
51
+ * add run_test method to be extensible.
52
+ * improve priority-mode auto off.
53
+ * improve startup/shutdown RDoc. [Daniel Berger]
54
+ * add assert_compare. [#20851] [Designing Patterns]
55
+ * add assert_fail_assertion. [#20851] [Designing Patterns]
56
+ * add assert_raise_message. [#20851] [Designing Patterns]
57
+ * support folded diff.
58
+ * add assert_raise_kind_of. [Daniel Berger]
59
+ * ingore inherited test for nested test case.
60
+ * add assert_const_defined.
61
+ * add assert_not_const_defined.
62
+ * support assert_raise with an exception object.
63
+ * support assert_raise with no arguments that asserts any
64
+ exception is raised. [#22602] [Daniel Berger]
65
+ * support folded dot progress.
66
+ * add --progress-row-max option.
67
+ * support color scheme customize.
68
+ * support configuration file. (YAML)
69
+ * recognize test-XXX.rb files as test files not only test_XXX.rb
70
+
71
+ * Thanks
72
+
73
+ * Daniel Berger
74
+ * Designing Patterns
75
+
76
+ === 2.0.0 / 2008-06-18
77
+
78
+ * 15 major enhancements
79
+
80
+ * support startup/shutdown. (test case level setup/teardown)
81
+ * support multiple setup/teardown.
82
+ * support pending.
83
+ * support omission.
84
+ * support notification.
85
+ * support colorize.
86
+ * support diff.
87
+ * support test attribute.
88
+ * add assert_boolean.
89
+ * add assert_true.
90
+ * add assert_false.
91
+ * add --priority-mode option.
92
+ * don't use ObjectSpace to collect test cases.
93
+ * make more customizable. (additional options, exception handling and so on)
94
+ * improve Emacs integration.
95
+
96
+ * 4 major changes
97
+
98
+ * remove GTK+1 support.
99
+ * split GTK+ runner as another gem.
100
+ * split FOX runner as another gem.
101
+ * split Tk runner as another gem.
102
+
103
+ === 1.2.3 / 2008-02-25
104
+
105
+ * 1 major enhancement
106
+
107
+ * Birthday (as a gem)!
@@ -0,0 +1,52 @@
1
+ = Test::Unit 2.x
2
+
3
+ * http://rubyforge.org/projects/test-unit/
4
+
5
+ == DESCRIPTION
6
+
7
+ Test::Unit 2.x - Improved version of Test::Unit bundled in
8
+ Ruby 1.8.x.
9
+
10
+ Ruby 1.9.x bundles miniunit not Test::Unit. Test::Unit
11
+ bundled in Ruby 1.8.x had not been improved but unbundled
12
+ Test::Unit (Test::Unit 2.x) will be improved actively.
13
+
14
+ == FEATURES
15
+
16
+ * Test::Unit 1.2.3 is the original Test::Unit, taken
17
+ straight from the ruby distribution. It is being
18
+ distributed as a gem to allow tool builders to use it as a
19
+ stand-alone package. (The test framework in ruby is going
20
+ to radically change very soon).
21
+
22
+ * Test::Unit 2.x will be improved actively and may break
23
+ compatiblity with Test::Unit 1.2.3. (We will not hope it
24
+ if it isn't needed.)
25
+
26
+ * Some features exist as separated gems like GUI test
27
+ runner. (Tk, GTK+ and Fox) test-unit-full gem package
28
+ provides for installing all Test::Unit related gems
29
+ easily.
30
+
31
+ == INSTALL
32
+
33
+ % sudo gem install test-unit
34
+
35
+ If you want to use full Test::Unit features:
36
+
37
+ % sudo gem install test-unit-full
38
+
39
+ == LICENSE
40
+
41
+ (The Ruby License)
42
+
43
+ This software is distributed under the same terms as ruby.
44
+
45
+ == Thanks
46
+
47
+ * Daniel Berger: Suggestions and bug reports.
48
+ * Designing Patterns: Suggestions.
49
+ * Erik Hollensbe: Suggestions.
50
+ * Bill Lear: A suggestion.
51
+ * Diego Pettenò: A bug report.
52
+ * Angelo Lakra: A bug report.
@@ -0,0 +1,40 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ gem 'rdoc'
5
+ require 'hoe'
6
+ require './lib/test/unit/version.rb'
7
+
8
+ ENV["NODOT"] = "yes"
9
+
10
+ version = Test::Unit::VERSION
11
+ ENV["VERSION"] = version
12
+ Hoe.spec('test-unit') do |p|
13
+ Hoe::Test::SUPPORTED_TEST_FRAMEWORKS[:testunit2] = "test/run-test.rb"
14
+ p.version = version
15
+ p.developer('Kouhei Sutou', 'kou@cozmixng.org')
16
+ p.developer('Ryan Davis', 'ryand-ruby@zenspider.com')
17
+
18
+ # Ex-Parrot:
19
+ # p.developer('Nathaniel Talbott', 'nathaniel@talbott.ws')
20
+ end
21
+
22
+ task :check_manifest => :clean_test_result
23
+ task :check_manifest => :clean_coverage
24
+
25
+ task :clean_test_result do
26
+ test_results = Dir.glob("**/.test-result")
27
+ sh("rm", "-rf", *test_results) unless test_results.empty?
28
+ end
29
+
30
+ task :clean_coverage do
31
+ sh("rm", "-rf", "coverage")
32
+ end
33
+
34
+ task :tag do
35
+ message = "Released Test::Unit #{version}!"
36
+ base = "svn+ssh://#{ENV['USER']}@rubyforge.org/var/svn/test-unit/"
37
+ sh 'svn', 'copy', '-m', message, "#{base}trunk", "#{base}tags/#{version}"
38
+ end
39
+
40
+ # vim: syntax=Ruby
@@ -0,0 +1,5 @@
1
+ * mock.
2
+ * data-driven test.
3
+ * port ruby trunk's assert_equal's intelligent inspection
4
+ when inspected expected and actual are same content
5
+ string.
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require 'test/unit'
3
+ (r = Test::Unit::AutoRunner.new(true)).process_args(ARGV) or
4
+ abort r.options.banner + " tests..."
5
+ exit r.run
@@ -0,0 +1,342 @@
1
+ require 'test/unit/testcase'
2
+ require 'test/unit/autorunner'
3
+
4
+ module Test # :nodoc:
5
+ #
6
+ # = Test::Unit - Ruby Unit Testing Framework
7
+ #
8
+ # == Introduction
9
+ #
10
+ # Unit testing is making waves all over the place, largely due to the
11
+ # fact that it is a core practice of XP. While XP is great, unit testing
12
+ # has been around for a long time and has always been a good idea. One
13
+ # of the keys to good unit testing, though, is not just writing tests,
14
+ # but having tests. What's the difference? Well, if you just _write_ a
15
+ # test and throw it away, you have no guarantee that something won't
16
+ # change later which breaks your code. If, on the other hand, you _have_
17
+ # tests (obviously you have to write them first), and run them as often
18
+ # as possible, you slowly build up a wall of things that cannot break
19
+ # without you immediately knowing about it. This is when unit testing
20
+ # hits its peak usefulness.
21
+ #
22
+ # Enter Test::Unit, a framework for unit testing in Ruby, helping you to
23
+ # design, debug and evaluate your code by making it easy to write and
24
+ # have tests for it.
25
+ #
26
+ #
27
+ # == Notes
28
+ #
29
+ # Test::Unit has grown out of and superceded Lapidary.
30
+ #
31
+ #
32
+ # == Feedback
33
+ #
34
+ # I like (and do my best to practice) XP, so I value early releases,
35
+ # user feedback, and clean, simple, expressive code. There is always
36
+ # room for improvement in everything I do, and Test::Unit is no
37
+ # exception. Please, let me know what you think of Test::Unit as it
38
+ # stands, and what you'd like to see expanded/changed/improved/etc. If
39
+ # you find a bug, let me know ASAP; one good way to let me know what the
40
+ # bug is is to submit a new test that catches it :-) Also, I'd love to
41
+ # hear about any successes you have with Test::Unit, and any
42
+ # documentation you might add will be greatly appreciated. My contact
43
+ # info is below.
44
+ #
45
+ #
46
+ # == Contact Information
47
+ #
48
+ # A lot of discussion happens about Ruby in general on the ruby-talk
49
+ # mailing list (http://www.ruby-lang.org/en/ml.html), and you can ask
50
+ # any questions you might have there. I monitor the list, as do many
51
+ # other helpful Rubyists, and you're sure to get a quick answer. Of
52
+ # course, you're also welcome to email me (Nathaniel Talbott) directly
53
+ # at mailto:testunit@talbott.ws, and I'll do my best to help you out.
54
+ #
55
+ #
56
+ # == Credits
57
+ #
58
+ # I'd like to thank...
59
+ #
60
+ # Matz, for a great language!
61
+ #
62
+ # Masaki Suketa, for his work on RubyUnit, which filled a vital need in
63
+ # the Ruby world for a very long time. I'm also grateful for his help in
64
+ # polishing Test::Unit and getting the RubyUnit compatibility layer
65
+ # right. His graciousness in allowing Test::Unit to supercede RubyUnit
66
+ # continues to be a challenge to me to be more willing to defer my own
67
+ # rights.
68
+ #
69
+ # Ken McKinlay, for his interest and work on unit testing, and for his
70
+ # willingness to dialog about it. He was also a great help in pointing
71
+ # out some of the holes in the RubyUnit compatibility layer.
72
+ #
73
+ # Dave Thomas, for the original idea that led to the extremely simple
74
+ # "require 'test/unit'", plus his code to improve it even more by
75
+ # allowing the selection of tests from the command-line. Also, without
76
+ # RDoc, the documentation for Test::Unit would stink a lot more than it
77
+ # does now.
78
+ #
79
+ # Everyone who's helped out with bug reports, feature ideas,
80
+ # encouragement to continue, etc. It's a real privilege to be a part of
81
+ # the Ruby community.
82
+ #
83
+ # The guys at RoleModel Software, for putting up with me repeating, "But
84
+ # this would be so much easier in Ruby!" whenever we're coding in Java.
85
+ #
86
+ # My Creator, for giving me life, and giving it more abundantly.
87
+ #
88
+ #
89
+ # == License
90
+ #
91
+ # Test::Unit is copyright (c) 2000-2003 Nathaniel Talbott. It is free
92
+ # software, and is distributed under the Ruby license. See the COPYING
93
+ # file in the standard Ruby distribution for details.
94
+ #
95
+ #
96
+ # == Warranty
97
+ #
98
+ # This software is provided "as is" and without any express or
99
+ # implied warranties, including, without limitation, the implied
100
+ # warranties of merchantibility and fitness for a particular
101
+ # purpose.
102
+ #
103
+ #
104
+ # == Author
105
+ #
106
+ # Nathaniel Talbott.
107
+ # Copyright (c) 2000-2003, Nathaniel Talbott
108
+ #
109
+ # ----
110
+ #
111
+ # = Usage
112
+ #
113
+ # The general idea behind unit testing is that you write a _test_
114
+ # _method_ that makes certain _assertions_ about your code, working
115
+ # against a _test_ _fixture_. A bunch of these _test_ _methods_ are
116
+ # bundled up into a _test_ _suite_ and can be run any time the
117
+ # developer wants. The results of a run are gathered in a _test_
118
+ # _result_ and displayed to the user through some UI. So, lets break
119
+ # this down and see how Test::Unit provides each of these necessary
120
+ # pieces.
121
+ #
122
+ #
123
+ # == Assertions
124
+ #
125
+ # These are the heart of the framework. Think of an assertion as a
126
+ # statement of expected outcome, i.e. "I assert that x should be equal
127
+ # to y". If, when the assertion is executed, it turns out to be
128
+ # correct, nothing happens, and life is good. If, on the other hand,
129
+ # your assertion turns out to be false, an error is propagated with
130
+ # pertinent information so that you can go back and make your
131
+ # assertion succeed, and, once again, life is good. For an explanation
132
+ # of the current assertions, see Test::Unit::Assertions.
133
+ #
134
+ #
135
+ # == Test Method & Test Fixture
136
+ #
137
+ # Obviously, these assertions have to be called within a context that
138
+ # knows about them and can do something meaningful with their
139
+ # pass/fail value. Also, it's handy to collect a bunch of related
140
+ # tests, each test represented by a method, into a common test class
141
+ # that knows how to run them. The tests will be in a separate class
142
+ # from the code they're testing for a couple of reasons. First of all,
143
+ # it allows your code to stay uncluttered with test code, making it
144
+ # easier to maintain. Second, it allows the tests to be stripped out
145
+ # for deployment, since they're really there for you, the developer,
146
+ # and your users don't need them. Third, and most importantly, it
147
+ # allows you to set up a common test fixture for your tests to run
148
+ # against.
149
+ #
150
+ # What's a test fixture? Well, tests do not live in a vacuum; rather,
151
+ # they're run against the code they are testing. Often, a collection
152
+ # of tests will run against a common set of data, also called a
153
+ # fixture. If they're all bundled into the same test class, they can
154
+ # all share the setting up and tearing down of that data, eliminating
155
+ # unnecessary duplication and making it much easier to add related
156
+ # tests.
157
+ #
158
+ # Test::Unit::TestCase wraps up a collection of test methods together
159
+ # and allows you to easily set up and tear down the same test fixture
160
+ # for each test. This is done by overriding #setup and/or #teardown,
161
+ # which will be called before and after each test method that is
162
+ # run. The TestCase also knows how to collect the results of your
163
+ # assertions into a Test::Unit::TestResult, which can then be reported
164
+ # back to you... but I'm getting ahead of myself. To write a test,
165
+ # follow these steps:
166
+ #
167
+ # * Make sure Test::Unit is in your library path.
168
+ # * require 'test/unit' in your test script.
169
+ # * Create a class that subclasses Test::Unit::TestCase.
170
+ # * Add a method that begins with "test" to your class.
171
+ # * Make assertions in your test method.
172
+ # * Optionally define #setup and/or #teardown to set up and/or tear
173
+ # down your common test fixture.
174
+ # * You can now run your test as you would any other Ruby
175
+ # script... try it and see!
176
+ #
177
+ # A really simple test might look like this (#setup and #teardown are
178
+ # commented out to indicate that they are completely optional):
179
+ #
180
+ # require 'test/unit'
181
+ #
182
+ # class TC_MyTest < Test::Unit::TestCase
183
+ # # def setup
184
+ # # end
185
+ #
186
+ # # def teardown
187
+ # # end
188
+ #
189
+ # def test_fail
190
+ # assert(false, 'Assertion was false.')
191
+ # end
192
+ # end
193
+ #
194
+ #
195
+ # == Test Runners
196
+ #
197
+ # So, now you have this great test class, but you still need a way to
198
+ # run it and view any failures that occur during the run. This is
199
+ # where Test::Unit::UI::Console::TestRunner (and others, such as
200
+ # Test::Unit::UI::GTK::TestRunner) comes into play. The console test
201
+ # runner is automatically invoked for you if you require 'test/unit'
202
+ # and simply run the file. To use another runner, or to manually
203
+ # invoke a runner, simply call its run class method and pass in an
204
+ # object that responds to the suite message with a
205
+ # Test::Unit::TestSuite. This can be as simple as passing in your
206
+ # TestCase class (which has a class suite method). It might look
207
+ # something like this:
208
+ #
209
+ # require 'test/unit/ui/console/testrunner'
210
+ # Test::Unit::UI::Console::TestRunner.run(TC_MyTest)
211
+ #
212
+ #
213
+ # == Test Suite
214
+ #
215
+ # As more and more unit tests accumulate for a given project, it
216
+ # becomes a real drag running them one at a time, and it also
217
+ # introduces the potential to overlook a failing test because you
218
+ # forget to run it. Suddenly it becomes very handy that the
219
+ # TestRunners can take any object that returns a Test::Unit::TestSuite
220
+ # in response to a suite method. The TestSuite can, in turn, contain
221
+ # other TestSuites or individual tests (typically created by a
222
+ # TestCase). In other words, you can easily wrap up a group of
223
+ # TestCases and TestSuites like this:
224
+ #
225
+ # require 'test/unit/testsuite'
226
+ # require 'tc_myfirsttests'
227
+ # require 'tc_moretestsbyme'
228
+ # require 'ts_anothersetoftests'
229
+ #
230
+ # class TS_MyTests
231
+ # def self.suite
232
+ # suite = Test::Unit::TestSuite.new
233
+ # suite << TC_MyFirstTests.suite
234
+ # suite << TC_MoreTestsByMe.suite
235
+ # suite << TS_AnotherSetOfTests.suite
236
+ # return suite
237
+ # end
238
+ # end
239
+ # Test::Unit::UI::Console::TestRunner.run(TS_MyTests)
240
+ #
241
+ # Now, this is a bit cumbersome, so Test::Unit does a little bit more
242
+ # for you, by wrapping these up automatically when you require
243
+ # 'test/unit'. What does this mean? It means you could write the above
244
+ # test case like this instead:
245
+ #
246
+ # require 'test/unit'
247
+ # require 'tc_myfirsttests'
248
+ # require 'tc_moretestsbyme'
249
+ # require 'ts_anothersetoftests'
250
+ #
251
+ # Test::Unit is smart enough to find all the test cases existing in
252
+ # the ObjectSpace and wrap them up into a suite for you. It then runs
253
+ # the dynamic suite using the console TestRunner.
254
+ #
255
+ #
256
+ # == Configuration file
257
+ #
258
+ # Test::Unit reads 'test-unit.yml' in the current working
259
+ # directory as Test::Unit's configuration file. It can
260
+ # contain the following configurations:
261
+ #
262
+ # * color scheme definitions
263
+ # * test runner to be used
264
+ # * test runner options
265
+ # * test collector to be used
266
+ #
267
+ # Except color scheme definitions, all of them are
268
+ # specified by command line option.
269
+ #
270
+ # Here are sample color scheme definitions:
271
+ #
272
+ # color_schemes:
273
+ # inverted:
274
+ # success:
275
+ # name: red
276
+ # bold: true
277
+ # failure:
278
+ # name: green
279
+ # bold: true
280
+ # other_scheme:
281
+ # ...
282
+ #
283
+ # Here are the syntax of color scheme definitions:
284
+ #
285
+ # color_schemes:
286
+ # SCHEME_NAME:
287
+ # EVENT_NAME:
288
+ # name: COLOR_NAME
289
+ # intensity: BOOLEAN
290
+ # bold: BOOLEAN
291
+ # italic: BOOLEAN
292
+ # underline: BOOLEAN
293
+ # ...
294
+ # ...
295
+ #
296
+ # SCHEME_NAME:: the name of the color scheme
297
+ # EVENT_NAME:: one of [success, failure, pending,
298
+ # omission, notification, error]
299
+ # COLOR_NAME:: one of [black, red, green, yellow, blue,
300
+ # magenta, cyan, white]
301
+ # BOOLEAN:: true or false
302
+ #
303
+ # You can use the above 'inverted' color scheme with the
304
+ # following configuration:
305
+ #
306
+ # runner: console
307
+ # console_options:
308
+ # color_scheme: inverted
309
+ # color_schemes:
310
+ # inverted:
311
+ # success:
312
+ # name: red
313
+ # bold: true
314
+ # failure:
315
+ # name: green
316
+ # bold: true
317
+ #
318
+ # == Questions?
319
+ #
320
+ # I'd really like to get feedback from all levels of Ruby
321
+ # practitioners about typos, grammatical errors, unclear statements,
322
+ # missing points, etc., in this document (or any other).
323
+ #
324
+
325
+ module Unit
326
+ # If set to false Test::Unit will not automatically run at exit.
327
+ def self.run=(flag)
328
+ @run = flag
329
+ end
330
+
331
+ # Automatically run tests at exit?
332
+ def self.run?
333
+ @run ||= false
334
+ end
335
+ end
336
+ end
337
+
338
+ at_exit do
339
+ unless $! || Test::Unit.run?
340
+ exit Test::Unit::AutoRunner.run
341
+ end
342
+ end