Permalink
Browse files

Froze dust and mocha

  • Loading branch information...
1 parent 3ebbc0b commit b7ad1f7fc10ba41515ed00976fe15986a3e807fc @ph7 committed Oct 28, 2008
Showing with 10,735 additions and 2 deletions.
  1. +2 −2 test/system_timer_test.rb
  2. +35 −0 vendor/gems/dust-0.1.6/README
  3. +5 −0 vendor/gems/dust-0.1.6/lib/array_extension.rb
  4. +20 −0 vendor/gems/dust-0.1.6/lib/definition_error.rb
  5. +8 −0 vendor/gems/dust-0.1.6/lib/dust.rb
  6. +5 −0 vendor/gems/dust-0.1.6/lib/nil_extension.rb
  7. +62 −0 vendor/gems/dust-0.1.6/lib/object_extension.rb
  8. +5 −0 vendor/gems/dust-0.1.6/lib/string_extension.rb
  9. +5 −0 vendor/gems/dust-0.1.6/lib/symbol_extension.rb
  10. +76 −0 vendor/gems/dust-0.1.6/lib/test_case_extension.rb
  11. +50 −0 vendor/gems/dust-0.1.6/rakefile.rb
  12. +1 −0 vendor/gems/dust-0.1.6/test/all_tests.rb
  13. +16 −0 vendor/gems/dust-0.1.6/test/failing_with_helper_unit_test.rb
  14. +16 −0 vendor/gems/dust-0.1.6/test/failing_with_setup_unit_test.rb
  15. +12 −0 vendor/gems/dust-0.1.6/test/functional_test.rb
  16. +11 −0 vendor/gems/dust-0.1.6/test/passing_unit_test.rb
  17. +10 −0 vendor/gems/dust-0.1.6/test/passing_with_helper_unit_test.rb
  18. +13 −0 vendor/gems/dust-0.1.6/test/passing_with_helpers_unit_test.rb
  19. +10 −0 vendor/gems/dust-0.1.6/test/passing_with_setup_unit_test.rb
  20. +1 −0 vendor/gems/dust-0.1.6/test/test_helper.rb
  21. +3 −0 vendor/gems/mocha-0.9.1/COPYING
  22. +7 −0 vendor/gems/mocha-0.9.1/MIT-LICENSE
  23. +35 −0 vendor/gems/mocha-0.9.1/README
  24. +246 −0 vendor/gems/mocha-0.9.1/RELEASE
  25. +188 −0 vendor/gems/mocha-0.9.1/Rakefile
  26. +44 −0 vendor/gems/mocha-0.9.1/examples/misc.rb
  27. +26 −0 vendor/gems/mocha-0.9.1/examples/mocha.rb
  28. +65 −0 vendor/gems/mocha-0.9.1/examples/stubba.rb
  29. +20 −0 vendor/gems/mocha-0.9.1/lib/mocha.rb
  30. +54 −0 vendor/gems/mocha-0.9.1/lib/mocha/any_instance_method.rb
  31. +17 −0 vendor/gems/mocha-0.9.1/lib/mocha/backtrace_filter.rb
  32. +95 −0 vendor/gems/mocha-0.9.1/lib/mocha/cardinality.rb
  33. +27 −0 vendor/gems/mocha-0.9.1/lib/mocha/central.rb
  34. +19 −0 vendor/gems/mocha-0.9.1/lib/mocha/change_state_side_effect.rb
  35. +86 −0 vendor/gems/mocha-0.9.1/lib/mocha/class_method.rb
  36. +60 −0 vendor/gems/mocha-0.9.1/lib/mocha/configuration.rb
  37. +22 −0 vendor/gems/mocha-0.9.1/lib/mocha/deprecation.rb
  38. +17 −0 vendor/gems/mocha-0.9.1/lib/mocha/exception_raiser.rb
  39. +445 −0 vendor/gems/mocha-0.9.1/lib/mocha/expectation.rb
  40. +15 −0 vendor/gems/mocha-0.9.1/lib/mocha/expectation_error.rb
  41. +50 −0 vendor/gems/mocha-0.9.1/lib/mocha/expectation_list.rb
  42. +19 −0 vendor/gems/mocha-0.9.1/lib/mocha/in_state_ordering_constraint.rb
  43. +39 −0 vendor/gems/mocha-0.9.1/lib/mocha/inspect.rb
  44. +16 −0 vendor/gems/mocha-0.9.1/lib/mocha/instance_method.rb
  45. +9 −0 vendor/gems/mocha-0.9.1/lib/mocha/is_a.rb
  46. +15 −0 vendor/gems/mocha-0.9.1/lib/mocha/logger.rb
  47. +7 −0 vendor/gems/mocha-0.9.1/lib/mocha/metaclass.rb
  48. +21 −0 vendor/gems/mocha-0.9.1/lib/mocha/method_matcher.rb
  49. +196 −0 vendor/gems/mocha-0.9.1/lib/mocha/mock.rb
  50. +181 −0 vendor/gems/mocha-0.9.1/lib/mocha/mockery.rb
  51. +16 −0 vendor/gems/mocha-0.9.1/lib/mocha/module_method.rb
  52. +20 −0 vendor/gems/mocha-0.9.1/lib/mocha/multiple_yields.rb
  53. +53 −0 vendor/gems/mocha-0.9.1/lib/mocha/names.rb
  54. +11 −0 vendor/gems/mocha-0.9.1/lib/mocha/no_yields.rb
  55. +134 −0 vendor/gems/mocha-0.9.1/lib/mocha/object.rb
  56. +26 −0 vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers.rb
  57. +42 −0 vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/all_of.rb
  58. +47 −0 vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/any_of.rb
  59. +40 −0 vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/any_parameters.rb
  60. +33 −0 vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/anything.rb
  61. +15 −0 vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/base.rb
  62. +42 −0 vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/equals.rb
  63. +45 −0 vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/has_entries.rb
  64. +56 −0 vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/has_entry.rb
  65. +42 −0 vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/has_key.rb
  66. +42 −0 vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/has_value.rb
  67. +40 −0 vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/includes.rb
  68. +42 −0 vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/instance_of.rb
  69. +42 −0 vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/is_a.rb
  70. +42 −0 vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/kind_of.rb
  71. +42 −0 vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/not.rb
  72. +9 −0 vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/object.rb
  73. +55 −0 vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/optionally.rb
  74. +43 −0 vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/regexp_matches.rb
  75. +43 −0 vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/responds_with.rb
  76. +43 −0 vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/yaml_equivalent.rb
  77. +37 −0 vendor/gems/mocha-0.9.1/lib/mocha/parameters_matcher.rb
  78. +28 −0 vendor/gems/mocha-0.9.1/lib/mocha/pretty_parameters.rb
  79. +31 −0 vendor/gems/mocha-0.9.1/lib/mocha/return_values.rb
  80. +42 −0 vendor/gems/mocha-0.9.1/lib/mocha/sequence.rb
  81. +17 −0 vendor/gems/mocha-0.9.1/lib/mocha/single_return_value.rb
  82. +18 −0 vendor/gems/mocha-0.9.1/lib/mocha/single_yield.rb
  83. +166 −0 vendor/gems/mocha-0.9.1/lib/mocha/standalone.rb
  84. +91 −0 vendor/gems/mocha-0.9.1/lib/mocha/state_machine.rb
  85. +16 −0 vendor/gems/mocha-0.9.1/lib/mocha/stubbing_error.rb
  86. +103 −0 vendor/gems/mocha-0.9.1/lib/mocha/test_case_adapter.rb
  87. +18 −0 vendor/gems/mocha-0.9.1/lib/mocha/unexpected_invocation.rb
  88. +31 −0 vendor/gems/mocha-0.9.1/lib/mocha/yield_parameters.rb
  89. +2 −0 vendor/gems/mocha-0.9.1/lib/mocha_standalone.rb
  90. +4 −0 vendor/gems/mocha-0.9.1/lib/stubba.rb
  91. +38 −0 vendor/gems/mocha-0.9.1/test/acceptance/acceptance_test_helper.rb
  92. +43 −0 vendor/gems/mocha-0.9.1/test/acceptance/bug_18914_test.rb
  93. +34 −0 vendor/gems/mocha-0.9.1/test/acceptance/bug_21465_test.rb
  94. +25 −0 vendor/gems/mocha-0.9.1/test/acceptance/bug_21563_test.rb
  95. +196 −0 vendor/gems/mocha-0.9.1/test/acceptance/expected_invocation_count_test.rb
  96. +64 −0 vendor/gems/mocha-0.9.1/test/acceptance/failure_messages_test.rb
  97. +98 −0 vendor/gems/mocha-0.9.1/test/acceptance/mocha_example_test.rb
  98. +84 −0 vendor/gems/mocha-0.9.1/test/acceptance/mocha_test_result_test.rb
  99. +100 −0 vendor/gems/mocha-0.9.1/test/acceptance/mock_test.rb
  100. +51 −0 vendor/gems/mocha-0.9.1/test/acceptance/mock_with_initializer_block_test.rb
  101. +78 −0 vendor/gems/mocha-0.9.1/test/acceptance/mocked_methods_dispatch_test.rb
  102. +70 −0 vendor/gems/mocha-0.9.1/test/acceptance/optional_parameters_test.rb
  103. +179 −0 vendor/gems/mocha-0.9.1/test/acceptance/parameter_matcher_test.rb
  104. +47 −0 vendor/gems/mocha-0.9.1/test/acceptance/partial_mocks_test.rb
  105. +52 −0 vendor/gems/mocha-0.9.1/test/acceptance/return_value_test.rb
  106. +186 −0 vendor/gems/mocha-0.9.1/test/acceptance/sequence_test.rb
  107. +139 −0 vendor/gems/mocha-0.9.1/test/acceptance/standalone_test.rb
  108. +70 −0 vendor/gems/mocha-0.9.1/test/acceptance/states_test.rb
  109. +195 −0 vendor/gems/mocha-0.9.1/test/acceptance/stub_any_instance_method_test.rb
  110. +203 −0 vendor/gems/mocha-0.9.1/test/acceptance/stub_class_method_test.rb
  111. +56 −0 vendor/gems/mocha-0.9.1/test/acceptance/stub_everything_test.rb
  112. +165 −0 vendor/gems/mocha-0.9.1/test/acceptance/stub_instance_method_test.rb
  113. +163 −0 vendor/gems/mocha-0.9.1/test/acceptance/stub_module_method_test.rb
  114. +52 −0 vendor/gems/mocha-0.9.1/test/acceptance/stub_test.rb
  115. +102 −0 vendor/gems/mocha-0.9.1/test/acceptance/stubba_example_test.rb
  116. +15 −0 vendor/gems/mocha-0.9.1/test/acceptance/stubba_test.rb
  117. +66 −0 vendor/gems/mocha-0.9.1/test/acceptance/stubba_test_result_test.rb
  118. +64 −0 vendor/gems/mocha-0.9.1/test/acceptance/stubbing_error_backtrace_test.rb
  119. +65 −0 vendor/gems/mocha-0.9.1/test/acceptance/stubbing_method_unnecessarily_test.rb
  120. +130 −0 vendor/gems/mocha-0.9.1/test/acceptance/stubbing_non_existent_any_instance_method_test.rb
  121. +155 −0 vendor/gems/mocha-0.9.1/test/acceptance/stubbing_non_existent_class_method_test.rb
  122. +145 −0 vendor/gems/mocha-0.9.1/test/acceptance/stubbing_non_existent_instance_method_test.rb
  123. +130 −0 vendor/gems/mocha-0.9.1/test/acceptance/stubbing_non_public_any_instance_method_test.rb
  124. +161 −0 vendor/gems/mocha-0.9.1/test/acceptance/stubbing_non_public_class_method_test.rb
  125. +141 −0 vendor/gems/mocha-0.9.1/test/acceptance/stubbing_non_public_instance_method_test.rb
  126. +64 −0 vendor/gems/mocha-0.9.1/test/acceptance/stubbing_on_non_mock_object_test.rb
  127. +36 −0 vendor/gems/mocha-0.9.1/test/active_record_test_case.rb
  128. +15 −0 vendor/gems/mocha-0.9.1/test/deprecation_disabler.rb
  129. +36 −0 vendor/gems/mocha-0.9.1/test/execution_point.rb
  130. +18 −0 vendor/gems/mocha-0.9.1/test/method_definer.rb
  131. +13 −0 vendor/gems/mocha-0.9.1/test/simple_counter.rb
  132. +11 −0 vendor/gems/mocha-0.9.1/test/test_helper.rb
  133. +33 −0 vendor/gems/mocha-0.9.1/test/test_runner.rb
  134. +126 −0 vendor/gems/mocha-0.9.1/test/unit/any_instance_method_test.rb
  135. +16 −0 vendor/gems/mocha-0.9.1/test/unit/array_inspect_test.rb
  136. +19 −0 vendor/gems/mocha-0.9.1/test/unit/backtrace_filter_test.rb
  137. +56 −0 vendor/gems/mocha-0.9.1/test/unit/cardinality_test.rb
  138. +65 −0 vendor/gems/mocha-0.9.1/test/unit/central_test.rb
  139. +41 −0 vendor/gems/mocha-0.9.1/test/unit/change_state_side_effect_test.rb
  140. +237 −0 vendor/gems/mocha-0.9.1/test/unit/class_method_test.rb
  141. +21 −0 vendor/gems/mocha-0.9.1/test/unit/date_time_inspect_test.rb
  142. +42 −0 vendor/gems/mocha-0.9.1/test/unit/exception_raiser_test.rb
  143. +57 −0 vendor/gems/mocha-0.9.1/test/unit/expectation_list_test.rb
  144. +459 −0 vendor/gems/mocha-0.9.1/test/unit/expectation_test.rb
  145. +16 −0 vendor/gems/mocha-0.9.1/test/unit/hash_inspect_test.rb
  146. +43 −0 vendor/gems/mocha-0.9.1/test/unit/in_state_ordering_constraint_test.rb
  147. +22 −0 vendor/gems/mocha-0.9.1/test/unit/metaclass_test.rb
  148. +23 −0 vendor/gems/mocha-0.9.1/test/unit/method_matcher_test.rb
  149. +290 −0 vendor/gems/mocha-0.9.1/test/unit/mock_test.rb
  150. +149 −0 vendor/gems/mocha-0.9.1/test/unit/mockery_test.rb
  151. +18 −0 vendor/gems/mocha-0.9.1/test/unit/multiple_yields_test.rb
  152. +18 −0 vendor/gems/mocha-0.9.1/test/unit/no_yields_test.rb
  153. +37 −0 vendor/gems/mocha-0.9.1/test/unit/object_inspect_test.rb
  154. +82 −0 vendor/gems/mocha-0.9.1/test/unit/object_test.rb
  155. +26 −0 vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/all_of_test.rb
  156. +26 −0 vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/any_of_test.rb
  157. +21 −0 vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/anything_test.rb
  158. +25 −0 vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/equals_test.rb
  159. +51 −0 vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/has_entries_test.rb
  160. +62 −0 vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/has_entry_test.rb
  161. +36 −0 vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/has_key_test.rb
  162. +37 −0 vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/has_value_test.rb
  163. +25 −0 vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/includes_test.rb
  164. +25 −0 vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/instance_of_test.rb
  165. +25 −0 vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/is_a_test.rb
  166. +25 −0 vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/kind_of_test.rb
  167. +26 −0 vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/not_test.rb
  168. +25 −0 vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/regexp_matches_test.rb
  169. +25 −0 vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/responds_with_test.rb
  170. +27 −0 vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/stub_matcher.rb
  171. +25 −0 vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/yaml_equivalent_test.rb
  172. +121 −0 vendor/gems/mocha-0.9.1/test/unit/parameters_matcher_test.rb
  173. +63 −0 vendor/gems/mocha-0.9.1/test/unit/return_values_test.rb
  174. +104 −0 vendor/gems/mocha-0.9.1/test/unit/sequence_test.rb
  175. +14 −0 vendor/gems/mocha-0.9.1/test/unit/single_return_value_test.rb
  176. +18 −0 vendor/gems/mocha-0.9.1/test/unit/single_yield_test.rb
  177. +98 −0 vendor/gems/mocha-0.9.1/test/unit/state_machine_test.rb
  178. +11 −0 vendor/gems/mocha-0.9.1/test/unit/string_inspect_test.rb
  179. +93 −0 vendor/gems/mocha-0.9.1/test/unit/yield_parameters_test.rb
@@ -1,7 +1,7 @@
$: << File.dirname(__FILE__) + '/../lib'
$: << File.dirname(__FILE__) + '/../ext/system_timer'
- $: << File.dirname(__FILE__) + "/../../../vendor/gems/dust-0.1.4/lib"
- $: << File.dirname(__FILE__) + "/../../../vendor/gems/mocha-0.5.3/lib"
+ $: << File.dirname(__FILE__) + "/../vendor/gems/dust-0.1.6/lib"
+ $: << File.dirname(__FILE__) + "/../vendor/gems/mocha-0.9.1/lib"
require 'test/unit'
require 'system_timer'
require 'dust'
@@ -0,0 +1,35 @@
+= Dust
+
+Dust adds descriptive block syntax test definition.
+
+by Jay[http://blog.jayfields.com] Fields[http://blog.jayfields.com]
+
+== Download and Installation
+
+You can download Dust from here[http://rubyforge.org/projects/dust] or install it with the following command.
+
+ $ gem install dust
+
+== License
+
+You may use, copy and redistribute this library under the same terms as Ruby itself (see http://www.ruby-lang.org/en/LICENSE.txt).
+
+== Examples
+
+ unit_tests do
+
+ test "assert true" do
+ assert_equal true, true
+ end
+
+ end
+
+See the tests for more examples
+
+== IDE specific files
+
+You can download TextMate and JEdit Run Focused Test Commands from http://rubyforge.org/projects/dust/ (in Files)
+
+== Contributors
+
+Dan Manges, David Vollbracht, Shane Harvie
@@ -0,0 +1,5 @@
+class Array #:nodoc:
+ def arrayize
+ self
+ end
+end
@@ -0,0 +1,20 @@
+module Dust #:nodoc:
+ # Dust::DefinitionError is raised when you attempt to define a disallowed method within a test file.
+ #
+ # Test::Unit::TestCase.disallow_setup!
+ #
+ # unit_tests do
+ # def setup
+ # ...
+ # end
+ #
+ # test "name" do
+ # ...
+ # end
+ # end
+ #
+ # The above code will generate the following error
+ # Dust::DefinitionError: setup is not allowed on class Units::[TestClassName]
+ class DefinitionError < StandardError
+ end
+end
@@ -0,0 +1,8 @@
+require 'test/unit'
+require File.expand_path(File.dirname(__FILE__) + '/object_extension')
+require File.expand_path(File.dirname(__FILE__) + '/array_extension')
+require File.expand_path(File.dirname(__FILE__) + '/nil_extension')
+require File.expand_path(File.dirname(__FILE__) + '/string_extension')
+require File.expand_path(File.dirname(__FILE__) + '/symbol_extension')
+require File.expand_path(File.dirname(__FILE__) + '/test_case_extension')
+require File.expand_path(File.dirname(__FILE__) + '/definition_error')
@@ -0,0 +1,5 @@
+class NilClass #:nodoc:
+ def arrayize
+ []
+ end
+end
@@ -0,0 +1,62 @@
+class Object
+ # call-seq: unit_tests(options={}, &block)
+ #
+ # Used to define a block of unit tests.
+ #
+ # unit_tests do
+ # test "verify something" do
+ # ...
+ # end
+ # end
+ #
+ # Configuration Options:
+ # * allow - Allows you to specify the methods that are allowed despite being disallowed.
+ # See Test::Unit::TestCase.disallow_helpers! or Test::Unit::TestCase.disallow_setup! for more info
+ def unit_tests(options={}, &block)
+ do_tests("Units", options, &block)
+ end
+
+ # call-seq: functional_tests(options={}, &block)
+ #
+ # Used to define a block of functional tests.
+ #
+ # functional_tests do
+ # test "verify something" do
+ # ...
+ # end
+ # end
+ #
+ # Configuration Options:
+ # * allow - Allows you to specify the methods that are allowed despite being disallowed.
+ # See Test::Unit::TestCase.disallow_helpers! or Test::Unit::TestCase.disallow_setup! for more info
+ def functional_tests(options={}, &block)
+ do_tests("Functionals", options, &block)
+ end
+
+ protected
+ def do_tests(type, options, &block) #:nodoc:
+ options[:allow] = options[:allow].arrayize
+ full_path_file_name = eval "__FILE__", block.binding
+ test_name = File.basename(full_path_file_name, ".rb")
+ test_class = eval "module #{type}; class #{test_name.to_class_name} < Test::Unit::TestCase; self; end; end"
+ test_class.class_eval &block
+ check_for_setup(test_class, options)
+ check_for_helpers(test_class, options)
+ end
+
+ def check_for_setup(test_class, options) #:nodoc:
+ if test_class.instance_methods(false).include?("setup") && Test::Unit::TestCase.disallow_setup? &&
+ !options[:allow].include?(:setup)
+ raise Dust::DefinitionError.new("setup is not allowed on class #{test_class.name}")
+ end
+ end
+
+ def check_for_helpers(test_class, options) #:nodoc:
+ test_class.instance_methods(false).each do |method_name|
+ if method_name !~ /^test_/ && Test::Unit::TestCase.disallow_helpers? && !options[:allow].include?(method_name.to_sym)
+ p method_name.to_sym
+ raise Dust::DefinitionError.new("helper methods are not allowed on class #{test_class.name}")
+ end
+ end
+ end
+end
@@ -0,0 +1,5 @@
+class String #:nodoc:
+ def to_class_name
+ gsub(/(^|_)(.)/) { $2.upcase }
+ end
+end
@@ -0,0 +1,5 @@
+class Symbol #:nodoc:
+ def arrayize
+ [self]
+ end
+end
@@ -0,0 +1,76 @@
+module Test #:nodoc:
+ module Unit #:nodoc:
+ class TestCase
+ # call-seq: disallow_setup!
+ #
+ # Used to disallow setup methods in test specifications.
+ #
+ # Test::Unit::TestCase.disallow_setup!
+ #
+ # A test specification can override this behavior by passing :setup in the :allow options.
+ #
+ # unit_tests :allow => :setup do
+ # def setup
+ # ...
+ # end
+ #
+ # test "verify something" do
+ # ...
+ # end
+ # end
+ def self.disallow_setup!
+ @disallow_setup = true
+ end
+
+ def self.disallow_setup? #:nodoc:
+ @disallow_setup
+ end
+
+ # call-seq: disallow_helpers!
+ #
+ # Used to disallow helper methods in test specifications.
+ #
+ # Test::Unit::TestCase.disallow_helper!
+ #
+ # A test specification can override this behavior by passing the helper name (as a symbol) in the :allow options.
+ #
+ # unit_tests :allow => [:create_something, :destroy_something] do
+ # test "verify something" do
+ # ...
+ # end
+ #
+ # def create_something
+ # ...
+ # end
+ #
+ # def destroy_something
+ # ...
+ # end
+ # end
+ def self.disallow_helpers!
+ @disallow_helpers = true
+ end
+
+ def self.disallow_helpers? #:nodoc:
+ @disallow_helpers
+ end
+
+ # call-seq: test(name, &block)
+ #
+ # Used to define a test and assign it a descriptive name.
+ #
+ # unit_tests do
+ # test "verify something" do
+ # ...
+ # end
+ # end
+ def self.test(name, &block)
+ test_name = "test_#{name.gsub(/[\s]/,'_')}".to_sym
+ raise "#{test_name} is already defined in #{self}" if self.instance_methods.include? test_name.to_s
+ define_method test_name do
+ instance_eval &block
+ end
+ end
+ end
+ end
+end
@@ -0,0 +1,50 @@
+require 'rubygems'
+require 'rake/gempackagetask'
+require 'rake/rdoctask'
+require 'rake/contrib/sshpublisher'
+
+task :default => :test
+
+task :test do
+ require File.dirname(__FILE__) + '/test/all_tests.rb'
+end
+
+desc 'Generate RDoc'
+Rake::RDocTask.new do |task|
+ task.main = 'README'
+ task.title = 'Dust'
+ task.rdoc_dir = 'doc'
+ task.options << "--line-numbers" << "--inline-source"
+ task.rdoc_files.include('README', 'lib/**/*.rb')
+end
+
+desc "Upload RDoc to RubyForge"
+task :publish_rdoc => [:rdoc] do
+ Rake::SshDirPublisher.new("jaycfields@rubyforge.org", "/var/www/gforge-projects/dust", "doc").upload
+end
+
+Gem::manage_gems
+
+specification = Gem::Specification.new do |s|
+ s.name = "dust"
+ s.summary = "Dust is an add on for Test::Unit that allows an alternative test definintion syntax."
+ s.version = "0.1.6"
+ s.author = 'Jay Fields'
+ s.description = "Dust is an add on for Test::Unit that allows an alternative test definintion syntax."
+ s.email = 'dust-developer@rubyforge.org'
+ s.homepage = 'http://dust.rubyforge.org'
+ s.rubyforge_project = 'dust'
+
+ s.has_rdoc = true
+ s.extra_rdoc_files = ['README']
+ s.rdoc_options << '--title' << 'Dust' << '--main' << 'README' << '--line-numbers'
+
+ s.autorequire = 'dust'
+ s.files = FileList['{lib,test}/**/*.rb', '[A-Z]*$', 'rakefile.rb'].to_a
+ s.test_file = "test/all_tests.rb"
+end
+
+Rake::GemPackageTask.new(specification) do |package|
+ package.need_zip = false
+ package.need_tar = false
+end
@@ -0,0 +1 @@
+Dir['**/*_test.rb'].each { |test_case| require test_case }
@@ -0,0 +1,16 @@
+require File.expand_path(File.dirname(__FILE__) + "/test_helper")
+
+begin
+ unit_tests do
+ Test::Unit::TestCase.disallow_helpers!
+ def helper_method
+ end
+
+ test("true"){}
+ end
+ raise "shouldn't be here"
+rescue Dust::DefinitionError => ex
+ raise unless ex.message == "helper methods are not allowed on class Units::FailingWithHelperUnitTest"
+ensure
+ Test::Unit::TestCase.class_eval { @disallow_helpers = nil }
+end
@@ -0,0 +1,16 @@
+require File.expand_path(File.dirname(__FILE__) + "/test_helper")
+
+begin
+ unit_tests do
+ Test::Unit::TestCase.disallow_setup!
+ def setup
+ end
+
+ test("true"){}
+ end
+ raise "shouldn't be here"
+rescue Dust::DefinitionError => ex
+ raise unless ex.message == "setup is not allowed on class Units::FailingWithSetupUnitTest"
+ensure
+ Test::Unit::TestCase.class_eval { @disallow_setup = nil }
+end
@@ -0,0 +1,12 @@
+require File.expand_path(File.dirname(__FILE__) + "/test_helper")
+
+functional_tests do
+ test "assert true" do
+ assert_equal true, true
+ end
+
+ test "class name is Functionals::FunctionalTest" do
+ assert_equal "Functionals::FunctionalTest", self.class.name
+ end
+
+end
@@ -0,0 +1,11 @@
+require File.expand_path(File.dirname(__FILE__) + "/test_helper")
+
+unit_tests do
+ test "assert true" do
+ assert_equal true, true
+ end
+
+ test "class name is Units::PassingUnitTest" do
+ assert_equal "Units::PassingUnitTest", self.class.name
+ end
+end
@@ -0,0 +1,10 @@
+require File.expand_path(File.dirname(__FILE__) + "/test_helper")
+
+Test::Unit::TestCase.disallow_helpers!
+unit_tests :allow => :helper do
+ def helper
+ end
+
+ test("true"){}
+end
+Test::Unit::TestCase.class_eval { @disallow_helpers = nil }
@@ -0,0 +1,13 @@
+require File.expand_path(File.dirname(__FILE__) + "/test_helper")
+
+Test::Unit::TestCase.disallow_helpers!
+unit_tests :allow => [:helper, :helper2] do
+ def helper
+ end
+
+ def helper2
+ end
+
+ test("true"){}
+end
+Test::Unit::TestCase.class_eval { @disallow_helpers = nil }
Oops, something went wrong.

0 comments on commit b7ad1f7

Please sign in to comment.