mocha 0.10.5 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (229) hide show
  1. data/COPYING.rdoc +1 -1
  2. data/README.rdoc +6 -4
  3. data/RELEASE.rdoc +12 -0
  4. data/Rakefile +29 -60
  5. data/doc/Mocha.html +112 -0
  6. data/doc/Mocha/API.html +898 -0
  7. data/doc/Mocha/ClassMethods.html +246 -0
  8. data/doc/Mocha/Configuration.html +471 -0
  9. data/doc/Mocha/Expectation.html +2570 -0
  10. data/doc/Mocha/Mock.html +830 -0
  11. data/doc/Mocha/ObjectMethods.html +668 -0
  12. data/doc/Mocha/ParameterMatchers.html +2715 -0
  13. data/doc/Mocha/ParameterMatchers/AllOf.html +137 -0
  14. data/doc/Mocha/ParameterMatchers/AnyOf.html +137 -0
  15. data/doc/Mocha/ParameterMatchers/AnyParameters.html +136 -0
  16. data/doc/Mocha/ParameterMatchers/Anything.html +136 -0
  17. data/doc/Mocha/ParameterMatchers/Base.html +419 -0
  18. data/doc/Mocha/ParameterMatchers/Equals.html +137 -0
  19. data/doc/Mocha/ParameterMatchers/HasEntries.html +137 -0
  20. data/doc/Mocha/ParameterMatchers/HasEntry.html +137 -0
  21. data/doc/Mocha/ParameterMatchers/HasKey.html +137 -0
  22. data/doc/Mocha/ParameterMatchers/HasValue.html +137 -0
  23. data/doc/Mocha/ParameterMatchers/Includes.html +137 -0
  24. data/doc/Mocha/ParameterMatchers/InstanceOf.html +137 -0
  25. data/doc/Mocha/ParameterMatchers/IsA.html +136 -0
  26. data/doc/Mocha/ParameterMatchers/KindOf.html +137 -0
  27. data/doc/Mocha/ParameterMatchers/Not.html +137 -0
  28. data/doc/Mocha/ParameterMatchers/Optionally.html +136 -0
  29. data/doc/Mocha/ParameterMatchers/QueryStringMatches.html +136 -0
  30. data/doc/Mocha/ParameterMatchers/RegexpMatches.html +137 -0
  31. data/doc/Mocha/ParameterMatchers/RespondsWith.html +137 -0
  32. data/doc/Mocha/ParameterMatchers/YamlEquivalent.html +137 -0
  33. data/doc/Mocha/Sequence.html +133 -0
  34. data/doc/Mocha/StateMachine.html +510 -0
  35. data/doc/Mocha/StateMachine/State.html +125 -0
  36. data/doc/Mocha/StateMachine/StatePredicate.html +125 -0
  37. data/doc/Mocha/StubbingError.html +134 -0
  38. data/doc/Mocha/UnexpectedInvocation.html +124 -0
  39. data/doc/_index.html +481 -0
  40. data/doc/class_list.html +47 -0
  41. data/doc/css/common.css +1 -0
  42. data/doc/css/full_list.css +55 -0
  43. data/doc/css/style.css +322 -0
  44. data/doc/file.COPYING.html +72 -0
  45. data/doc/file.MIT-LICENSE.html +86 -0
  46. data/doc/file.README.html +153 -0
  47. data/doc/file.RELEASE.html +933 -0
  48. data/doc/file.misc.html +108 -0
  49. data/doc/file.mocha.html +90 -0
  50. data/doc/file.stubba.html +129 -0
  51. data/doc/file_list.html +67 -0
  52. data/doc/frames.html +13 -0
  53. data/doc/index.html +153 -0
  54. data/doc/js/app.js +205 -0
  55. data/doc/js/full_list.js +173 -0
  56. data/doc/js/jquery.js +16 -0
  57. data/doc/method_list.html +510 -0
  58. data/doc/top-level-namespace.html +105 -0
  59. data/lib/mocha/any_instance_method.rb +16 -11
  60. data/lib/mocha/api.rb +120 -106
  61. data/lib/mocha/argument_iterator.rb +6 -6
  62. data/lib/mocha/backtrace_filter.rb +1 -1
  63. data/lib/mocha/cardinality.rb +21 -21
  64. data/lib/mocha/central.rb +8 -8
  65. data/lib/mocha/change_state_side_effect.rb +5 -5
  66. data/lib/mocha/class_method.rb +14 -19
  67. data/lib/mocha/configuration.rb +47 -37
  68. data/lib/mocha/deprecation.rb +8 -8
  69. data/lib/mocha/exception_raiser.rb +7 -7
  70. data/lib/mocha/expectation.rb +173 -77
  71. data/lib/mocha/expectation_error.rb +2 -2
  72. data/lib/mocha/expectation_list.rb +11 -11
  73. data/lib/mocha/in_state_ordering_constraint.rb +5 -5
  74. data/lib/mocha/inspect.rb +8 -8
  75. data/lib/mocha/instance_method.rb +1 -17
  76. data/lib/mocha/integration.rb +9 -9
  77. data/lib/mocha/integration/mini_test/assertion_counter.rb +9 -9
  78. data/lib/mocha/integration/mini_test/exception_translation.rb +6 -6
  79. data/lib/mocha/integration/mini_test/version_13.rb +6 -6
  80. data/lib/mocha/integration/mini_test/version_140.rb +6 -6
  81. data/lib/mocha/integration/mini_test/version_141.rb +6 -6
  82. data/lib/mocha/integration/mini_test/version_142_to_172.rb +7 -7
  83. data/lib/mocha/integration/mini_test/version_200.rb +7 -7
  84. data/lib/mocha/integration/test_unit/assertion_counter.rb +10 -10
  85. data/lib/mocha/integration/test_unit/gem_version_200.rb +6 -6
  86. data/lib/mocha/integration/test_unit/gem_version_201_to_202.rb +6 -6
  87. data/lib/mocha/integration/test_unit/ruby_version_185_and_below.rb +6 -6
  88. data/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb +6 -6
  89. data/lib/mocha/is_a.rb +1 -1
  90. data/lib/mocha/logger.rb +6 -6
  91. data/lib/mocha/method_matcher.rb +7 -7
  92. data/lib/mocha/mock.rb +85 -48
  93. data/lib/mocha/mockery.rb +47 -33
  94. data/lib/mocha/module_method.rb +2 -2
  95. data/lib/mocha/multiple_yields.rb +9 -9
  96. data/lib/mocha/names.rb +18 -18
  97. data/lib/mocha/no_yields.rb +7 -7
  98. data/lib/mocha/object.rb +104 -75
  99. data/lib/mocha/parameter_matchers.rb +3 -3
  100. data/lib/mocha/parameter_matchers/all_of.rb +22 -12
  101. data/lib/mocha/parameter_matchers/any_of.rb +23 -12
  102. data/lib/mocha/parameter_matchers/any_parameters.rb +15 -8
  103. data/lib/mocha/parameter_matchers/anything.rb +20 -11
  104. data/lib/mocha/parameter_matchers/base.rb +35 -27
  105. data/lib/mocha/parameter_matchers/equals.rb +23 -12
  106. data/lib/mocha/parameter_matchers/has_entries.rb +22 -12
  107. data/lib/mocha/parameter_matchers/has_entry.rb +31 -13
  108. data/lib/mocha/parameter_matchers/has_key.rb +21 -11
  109. data/lib/mocha/parameter_matchers/has_value.rb +21 -11
  110. data/lib/mocha/parameter_matchers/includes.rb +15 -5
  111. data/lib/mocha/parameter_matchers/instance_of.rb +23 -12
  112. data/lib/mocha/parameter_matchers/is_a.rb +23 -12
  113. data/lib/mocha/parameter_matchers/kind_of.rb +23 -12
  114. data/lib/mocha/parameter_matchers/not.rb +22 -12
  115. data/lib/mocha/parameter_matchers/object.rb +5 -3
  116. data/lib/mocha/parameter_matchers/optionally.rb +24 -12
  117. data/lib/mocha/parameter_matchers/query_string.rb +14 -3
  118. data/lib/mocha/parameter_matchers/regexp_matches.rb +21 -11
  119. data/lib/mocha/parameter_matchers/responds_with.rb +17 -6
  120. data/lib/mocha/parameter_matchers/yaml_equivalent.rb +16 -6
  121. data/lib/mocha/parameters_matcher.rb +8 -8
  122. data/lib/mocha/pretty_parameters.rb +7 -7
  123. data/lib/mocha/return_values.rb +11 -11
  124. data/lib/mocha/sequence.rb +23 -14
  125. data/lib/mocha/single_return_value.rb +7 -7
  126. data/lib/mocha/single_yield.rb +9 -9
  127. data/lib/mocha/standalone.rb +1 -1
  128. data/lib/mocha/state_machine.rb +61 -46
  129. data/lib/mocha/stubbing_error.rb +8 -5
  130. data/lib/mocha/thrower.rb +2 -2
  131. data/lib/mocha/unexpected_invocation.rb +9 -6
  132. data/lib/mocha/version.rb +1 -1
  133. data/lib/mocha/yield_parameters.rb +10 -10
  134. data/lib/mocha_standalone.rb +1 -1
  135. data/mocha.gemspec +4 -7
  136. data/test/acceptance/acceptance_test_helper.rb +10 -10
  137. data/test/acceptance/api_test.rb +20 -20
  138. data/test/acceptance/bug_18914_test.rb +12 -12
  139. data/test/acceptance/bug_21465_test.rb +6 -6
  140. data/test/acceptance/bug_21563_test.rb +5 -5
  141. data/test/acceptance/exception_rescue_test.rb +1 -1
  142. data/test/acceptance/expected_invocation_count_test.rb +17 -17
  143. data/test/acceptance/failure_messages_test.rb +13 -13
  144. data/test/acceptance/minitest_test.rb +39 -39
  145. data/test/acceptance/mocha_example_test.rb +26 -26
  146. data/test/acceptance/mocha_test_result_test.rb +13 -13
  147. data/test/acceptance/mock_test.rb +5 -5
  148. data/test/acceptance/mock_with_initializer_block_test.rb +5 -5
  149. data/test/acceptance/mocked_methods_dispatch_test.rb +4 -4
  150. data/test/acceptance/multiple_expectations_failure_message_test.rb +2 -2
  151. data/test/acceptance/optional_parameters_test.rb +5 -5
  152. data/test/acceptance/parameter_matcher_test.rb +18 -18
  153. data/test/acceptance/partial_mocks_test.rb +9 -9
  154. data/test/acceptance/raise_exception_test.rb +1 -1
  155. data/test/acceptance/return_value_test.rb +5 -5
  156. data/test/acceptance/sequence_test.rb +29 -29
  157. data/test/acceptance/states_test.rb +17 -17
  158. data/test/acceptance/stub_any_instance_method_test.rb +13 -13
  159. data/test/acceptance/stub_class_method_defined_on_active_record_association_proxy_test.rb +7 -7
  160. data/test/acceptance/stub_everything_test.rb +5 -5
  161. data/test/acceptance/stub_instance_method_defined_on_singleton_class_test.rb +1 -1
  162. data/test/acceptance/stub_module_method_test.rb +17 -17
  163. data/test/acceptance/stub_test.rb +5 -5
  164. data/test/acceptance/stubba_example_test.rb +24 -24
  165. data/test/acceptance/stubba_test_result_test.rb +11 -11
  166. data/test/acceptance/stubbing_error_backtrace_test.rb +6 -6
  167. data/test/acceptance/stubbing_frozen_object_test.rb +88 -0
  168. data/test/acceptance/stubbing_method_unnecessarily_test.rb +9 -9
  169. data/test/acceptance/stubbing_nil_test.rb +59 -0
  170. data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +13 -13
  171. data/test/acceptance/stubbing_non_existent_class_method_test.rb +15 -15
  172. data/test/acceptance/stubbing_non_existent_instance_method_test.rb +14 -14
  173. data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +13 -13
  174. data/test/acceptance/stubbing_non_public_class_method_test.rb +12 -12
  175. data/test/acceptance/stubbing_non_public_instance_method_test.rb +12 -12
  176. data/test/acceptance/stubbing_on_non_mock_object_test.rb +9 -9
  177. data/test/acceptance/stubbing_same_class_method_on_parent_and_child_classes_test.rb +35 -0
  178. data/test/acceptance/throw_test.rb +1 -1
  179. data/test/deprecation_disabler.rb +1 -1
  180. data/test/execution_point.rb +7 -7
  181. data/test/method_definer.rb +1 -1
  182. data/test/mini_test_result.rb +21 -21
  183. data/test/simple_counter.rb +5 -5
  184. data/test/test_helper.rb +1 -1
  185. data/test/test_runner.rb +22 -24
  186. data/test/test_unit_result.rb +20 -0
  187. data/test/unit/any_instance_method_test.rb +28 -32
  188. data/test/unit/array_inspect_test.rb +3 -3
  189. data/test/unit/backtrace_filter_test.rb +3 -3
  190. data/test/unit/cardinality_test.rb +12 -12
  191. data/test/unit/central_test.rb +18 -18
  192. data/test/unit/change_state_side_effect_test.rb +12 -12
  193. data/test/unit/class_method_test.rb +33 -91
  194. data/test/unit/date_time_inspect_test.rb +4 -4
  195. data/test/unit/exception_raiser_test.rb +5 -5
  196. data/test/unit/expectation_list_test.rb +7 -7
  197. data/test/unit/expectation_test.rb +66 -66
  198. data/test/unit/hash_inspect_test.rb +4 -4
  199. data/test/unit/in_state_ordering_constraint_test.rb +13 -13
  200. data/test/unit/method_matcher_test.rb +3 -3
  201. data/test/unit/mock_test.rb +40 -40
  202. data/test/unit/mockery_test.rb +25 -25
  203. data/test/unit/multiple_yields_test.rb +2 -2
  204. data/test/unit/no_yields_test.rb +2 -2
  205. data/test/unit/object_inspect_test.rb +4 -4
  206. data/test/unit/object_test.rb +15 -15
  207. data/test/unit/parameter_matchers/all_of_test.rb +6 -6
  208. data/test/unit/parameter_matchers/any_of_test.rb +6 -6
  209. data/test/unit/parameter_matchers/anything_test.rb +5 -5
  210. data/test/unit/parameter_matchers/has_entries_test.rb +10 -10
  211. data/test/unit/parameter_matchers/has_entry_test.rb +13 -13
  212. data/test/unit/parameter_matchers/has_key_test.rb +11 -11
  213. data/test/unit/parameter_matchers/has_value_test.rb +12 -12
  214. data/test/unit/parameter_matchers/includes_test.rb +4 -4
  215. data/test/unit/parameter_matchers/not_test.rb +6 -6
  216. data/test/unit/parameter_matchers/regexp_matches_test.rb +9 -9
  217. data/test/unit/parameter_matchers/responds_with_test.rb +6 -6
  218. data/test/unit/parameter_matchers/stub_matcher.rb +4 -4
  219. data/test/unit/parameter_matchers/yaml_equivalent_test.rb +6 -6
  220. data/test/unit/parameters_matcher_test.rb +16 -16
  221. data/test/unit/return_values_test.rb +5 -5
  222. data/test/unit/sequence_test.rb +10 -10
  223. data/test/unit/single_return_value_test.rb +3 -3
  224. data/test/unit/single_yield_test.rb +2 -2
  225. data/test/unit/state_machine_test.rb +19 -19
  226. data/test/unit/string_inspect_test.rb +2 -2
  227. data/test/unit/thrower_test.rb +1 -1
  228. data/test/unit/yield_parameters_test.rb +11 -11
  229. metadata +113 -101
@@ -2,17 +2,17 @@ require File.expand_path('../acceptance_test_helper', __FILE__)
2
2
  require 'mocha'
3
3
 
4
4
  class StubbingNonExistentInstanceMethodTest < Test::Unit::TestCase
5
-
5
+
6
6
  include AcceptanceTest
7
-
7
+
8
8
  def setup
9
9
  setup_acceptance_test
10
10
  end
11
-
11
+
12
12
  def teardown
13
13
  teardown_acceptance_test
14
14
  end
15
-
15
+
16
16
  def test_should_allow_stubbing_non_existent_instance_method
17
17
  Mocha::Configuration.allow(:stubbing_non_existent_method)
18
18
  instance = Class.new.new
@@ -22,7 +22,7 @@ class StubbingNonExistentInstanceMethodTest < Test::Unit::TestCase
22
22
  assert !@logger.warnings.include?("stubbing non-existent method: #{instance.mocha_inspect}.non_existent_method")
23
23
  assert_passed(test_result)
24
24
  end
25
-
25
+
26
26
  def test_should_warn_when_stubbing_non_existent_instance_method
27
27
  Mocha::Configuration.warn_when(:stubbing_non_existent_method)
28
28
  instance = Class.new.new
@@ -32,7 +32,7 @@ class StubbingNonExistentInstanceMethodTest < Test::Unit::TestCase
32
32
  assert_passed(test_result)
33
33
  assert @logger.warnings.include?("stubbing non-existent method: #{instance.mocha_inspect}.non_existent_method")
34
34
  end
35
-
35
+
36
36
  def test_should_prevent_stubbing_non_existent_instance_method
37
37
  Mocha::Configuration.prevent(:stubbing_non_existent_method)
38
38
  instance = Class.new.new
@@ -42,7 +42,7 @@ class StubbingNonExistentInstanceMethodTest < Test::Unit::TestCase
42
42
  assert_failed(test_result)
43
43
  assert test_result.error_messages.include?("Mocha::StubbingError: stubbing non-existent method: #{instance.mocha_inspect}.non_existent_method")
44
44
  end
45
-
45
+
46
46
  def test_should_default_to_allow_stubbing_non_existent_instance_method
47
47
  instance = Class.new.new
48
48
  test_result = run_as_test do
@@ -51,7 +51,7 @@ class StubbingNonExistentInstanceMethodTest < Test::Unit::TestCase
51
51
  assert !@logger.warnings.include?("stubbing non-existent method: #{instance.mocha_inspect}.non_existent_method")
52
52
  assert_passed(test_result)
53
53
  end
54
-
54
+
55
55
  def test_should_allow_stubbing_existing_public_instance_method
56
56
  Mocha::Configuration.prevent(:stubbing_non_existent_method)
57
57
  klass = Class.new do
@@ -78,7 +78,7 @@ class StubbingNonExistentInstanceMethodTest < Test::Unit::TestCase
78
78
  end
79
79
  assert_passed(test_result)
80
80
  end
81
-
81
+
82
82
  def test_should_allow_stubbing_existing_protected_instance_method
83
83
  Mocha::Configuration.prevent(:stubbing_non_existent_method)
84
84
  klass = Class.new do
@@ -91,7 +91,7 @@ class StubbingNonExistentInstanceMethodTest < Test::Unit::TestCase
91
91
  end
92
92
  assert_passed(test_result)
93
93
  end
94
-
94
+
95
95
  def test_should_allow_stubbing_existing_private_instance_method
96
96
  Mocha::Configuration.prevent(:stubbing_non_existent_method)
97
97
  klass = Class.new do
@@ -104,7 +104,7 @@ class StubbingNonExistentInstanceMethodTest < Test::Unit::TestCase
104
104
  end
105
105
  assert_passed(test_result)
106
106
  end
107
-
107
+
108
108
  def test_should_allow_stubbing_existing_public_instance_superclass_method
109
109
  Mocha::Configuration.prevent(:stubbing_non_existent_method)
110
110
  superklass = Class.new do
@@ -117,7 +117,7 @@ class StubbingNonExistentInstanceMethodTest < Test::Unit::TestCase
117
117
  end
118
118
  assert_passed(test_result)
119
119
  end
120
-
120
+
121
121
  def test_should_allow_stubbing_existing_protected_instance_superclass_method
122
122
  Mocha::Configuration.prevent(:stubbing_non_existent_method)
123
123
  superklass = Class.new do
@@ -130,7 +130,7 @@ class StubbingNonExistentInstanceMethodTest < Test::Unit::TestCase
130
130
  end
131
131
  assert_passed(test_result)
132
132
  end
133
-
133
+
134
134
  def test_should_allow_stubbing_existing_private_instance_superclass_method
135
135
  Mocha::Configuration.prevent(:stubbing_non_existent_method)
136
136
  superklass = Class.new do
@@ -143,5 +143,5 @@ class StubbingNonExistentInstanceMethodTest < Test::Unit::TestCase
143
143
  end
144
144
  assert_passed(test_result)
145
145
  end
146
-
146
+
147
147
  end
@@ -2,17 +2,17 @@ require File.expand_path('../acceptance_test_helper', __FILE__)
2
2
  require 'mocha'
3
3
 
4
4
  class StubbingNonPublicAnyInstanceMethodTest < Test::Unit::TestCase
5
-
5
+
6
6
  include AcceptanceTest
7
-
7
+
8
8
  def setup
9
9
  setup_acceptance_test
10
10
  end
11
-
11
+
12
12
  def teardown
13
13
  teardown_acceptance_test
14
14
  end
15
-
15
+
16
16
  def test_should_allow_stubbing_private_any_instance_method
17
17
  Mocha::Configuration.allow(:stubbing_non_public_method)
18
18
  klass = Class.new do
@@ -25,7 +25,7 @@ class StubbingNonPublicAnyInstanceMethodTest < Test::Unit::TestCase
25
25
  assert_passed(test_result)
26
26
  assert !@logger.warnings.include?("stubbing non-public method: #{klass.any_instance.mocha_inspect}.private_method")
27
27
  end
28
-
28
+
29
29
  def test_should_allow_stubbing_protected_any_instance_method
30
30
  Mocha::Configuration.allow(:stubbing_non_public_method)
31
31
  klass = Class.new do
@@ -38,7 +38,7 @@ class StubbingNonPublicAnyInstanceMethodTest < Test::Unit::TestCase
38
38
  assert_passed(test_result)
39
39
  assert !@logger.warnings.include?("stubbing non-public method: #{klass.any_instance.mocha_inspect}.protected_method")
40
40
  end
41
-
41
+
42
42
  def test_should_warn_when_stubbing_private_any_instance_method
43
43
  Mocha::Configuration.warn_when(:stubbing_non_public_method)
44
44
  klass = Class.new do
@@ -51,7 +51,7 @@ class StubbingNonPublicAnyInstanceMethodTest < Test::Unit::TestCase
51
51
  assert_passed(test_result)
52
52
  assert @logger.warnings.include?("stubbing non-public method: #{klass.any_instance.mocha_inspect}.private_method")
53
53
  end
54
-
54
+
55
55
  def test_should_warn_when_stubbing_protected_any_instance_method
56
56
  Mocha::Configuration.warn_when(:stubbing_non_public_method)
57
57
  klass = Class.new do
@@ -64,7 +64,7 @@ class StubbingNonPublicAnyInstanceMethodTest < Test::Unit::TestCase
64
64
  assert_passed(test_result)
65
65
  assert @logger.warnings.include?("stubbing non-public method: #{klass.any_instance.mocha_inspect}.protected_method")
66
66
  end
67
-
67
+
68
68
  def test_should_prevent_stubbing_private_any_instance_method
69
69
  Mocha::Configuration.prevent(:stubbing_non_public_method)
70
70
  klass = Class.new do
@@ -77,7 +77,7 @@ class StubbingNonPublicAnyInstanceMethodTest < Test::Unit::TestCase
77
77
  assert_failed(test_result)
78
78
  assert test_result.error_messages.include?("Mocha::StubbingError: stubbing non-public method: #{klass.any_instance.mocha_inspect}.private_method")
79
79
  end
80
-
80
+
81
81
  def test_should_prevent_stubbing_protected_any_instance_method
82
82
  Mocha::Configuration.prevent(:stubbing_non_public_method)
83
83
  klass = Class.new do
@@ -90,7 +90,7 @@ class StubbingNonPublicAnyInstanceMethodTest < Test::Unit::TestCase
90
90
  assert_failed(test_result)
91
91
  assert test_result.error_messages.include?("Mocha::StubbingError: stubbing non-public method: #{klass.any_instance.mocha_inspect}.protected_method")
92
92
  end
93
-
93
+
94
94
  def test_should_default_to_allow_stubbing_private_any_instance_method
95
95
  klass = Class.new do
96
96
  def private_method; end
@@ -102,7 +102,7 @@ class StubbingNonPublicAnyInstanceMethodTest < Test::Unit::TestCase
102
102
  assert_passed(test_result)
103
103
  assert !@logger.warnings.include?("stubbing non-public method: #{klass.any_instance.mocha_inspect}.private_method")
104
104
  end
105
-
105
+
106
106
  def test_should_default_to_allow_stubbing_protected_any_instance_method
107
107
  klass = Class.new do
108
108
  def protected_method; end
@@ -114,7 +114,7 @@ class StubbingNonPublicAnyInstanceMethodTest < Test::Unit::TestCase
114
114
  assert_passed(test_result)
115
115
  assert !@logger.warnings.include?("stubbing non-public method: #{klass.any_instance.mocha_inspect}.protected_method")
116
116
  end
117
-
117
+
118
118
  def test_should_allow_stubbing_public_any_instance_method
119
119
  Mocha::Configuration.prevent(:stubbing_non_public_method)
120
120
  klass = Class.new do
@@ -127,4 +127,4 @@ class StubbingNonPublicAnyInstanceMethodTest < Test::Unit::TestCase
127
127
  assert_passed(test_result)
128
128
  end
129
129
 
130
- end
130
+ end
@@ -2,17 +2,17 @@ require File.expand_path('../acceptance_test_helper', __FILE__)
2
2
  require 'mocha'
3
3
 
4
4
  class StubbingNonPublicClassMethodTest < Test::Unit::TestCase
5
-
5
+
6
6
  include AcceptanceTest
7
-
7
+
8
8
  def setup
9
9
  setup_acceptance_test
10
10
  end
11
-
11
+
12
12
  def teardown
13
13
  teardown_acceptance_test
14
14
  end
15
-
15
+
16
16
  def test_should_allow_stubbing_private_class_method
17
17
  Mocha::Configuration.allow(:stubbing_non_public_method)
18
18
  klass = Class.new do
@@ -27,7 +27,7 @@ class StubbingNonPublicClassMethodTest < Test::Unit::TestCase
27
27
  assert_passed(test_result)
28
28
  assert !@logger.warnings.include?("stubbing non-public method: #{klass.mocha_inspect}.private_method")
29
29
  end
30
-
30
+
31
31
  def test_should_allow_stubbing_protected_class_method
32
32
  Mocha::Configuration.allow(:stubbing_non_public_method)
33
33
  klass = Class.new do
@@ -42,7 +42,7 @@ class StubbingNonPublicClassMethodTest < Test::Unit::TestCase
42
42
  assert_passed(test_result)
43
43
  assert !@logger.warnings.include?("stubbing non-public method: #{klass.mocha_inspect}.protected_method")
44
44
  end
45
-
45
+
46
46
  def test_should_warn_when_stubbing_private_class_method
47
47
  Mocha::Configuration.warn_when(:stubbing_non_public_method)
48
48
  klass = Class.new do
@@ -57,7 +57,7 @@ class StubbingNonPublicClassMethodTest < Test::Unit::TestCase
57
57
  assert_passed(test_result)
58
58
  assert @logger.warnings.include?("stubbing non-public method: #{klass.mocha_inspect}.private_method")
59
59
  end
60
-
60
+
61
61
  def test_should_warn_when_stubbing_protected_class_method
62
62
  Mocha::Configuration.warn_when(:stubbing_non_public_method)
63
63
  klass = Class.new do
@@ -72,7 +72,7 @@ class StubbingNonPublicClassMethodTest < Test::Unit::TestCase
72
72
  assert_passed(test_result)
73
73
  assert @logger.warnings.include?("stubbing non-public method: #{klass.mocha_inspect}.protected_method")
74
74
  end
75
-
75
+
76
76
  def test_should_prevent_stubbing_private_class_method
77
77
  Mocha::Configuration.prevent(:stubbing_non_public_method)
78
78
  klass = Class.new do
@@ -87,7 +87,7 @@ class StubbingNonPublicClassMethodTest < Test::Unit::TestCase
87
87
  assert_failed(test_result)
88
88
  assert test_result.error_messages.include?("Mocha::StubbingError: stubbing non-public method: #{klass.mocha_inspect}.private_method")
89
89
  end
90
-
90
+
91
91
  def test_should_prevent_stubbing_protected_class_method
92
92
  Mocha::Configuration.prevent(:stubbing_non_public_method)
93
93
  klass = Class.new do
@@ -102,7 +102,7 @@ class StubbingNonPublicClassMethodTest < Test::Unit::TestCase
102
102
  assert_failed(test_result)
103
103
  assert test_result.error_messages.include?("Mocha::StubbingError: stubbing non-public method: #{klass.mocha_inspect}.protected_method")
104
104
  end
105
-
105
+
106
106
  def test_should_default_to_allow_stubbing_private_class_method
107
107
  klass = Class.new do
108
108
  class << self
@@ -116,7 +116,7 @@ class StubbingNonPublicClassMethodTest < Test::Unit::TestCase
116
116
  assert_passed(test_result)
117
117
  assert !@logger.warnings.include?("stubbing non-public method: #{klass.mocha_inspect}.private_method")
118
118
  end
119
-
119
+
120
120
  def test_should_default_to_allow_stubbing_protected_class_method
121
121
  klass = Class.new do
122
122
  class << self
@@ -130,7 +130,7 @@ class StubbingNonPublicClassMethodTest < Test::Unit::TestCase
130
130
  assert_passed(test_result)
131
131
  assert !@logger.warnings.include?("stubbing non-public method: #{klass.mocha_inspect}.protected_method")
132
132
  end
133
-
133
+
134
134
  def test_should_allow_stubbing_public_class_method
135
135
  Mocha::Configuration.prevent(:stubbing_non_public_method)
136
136
  klass = Class.new do
@@ -2,17 +2,17 @@ require File.expand_path('../acceptance_test_helper', __FILE__)
2
2
  require 'mocha'
3
3
 
4
4
  class StubbingNonPublicInstanceMethodTest < Test::Unit::TestCase
5
-
5
+
6
6
  include AcceptanceTest
7
-
7
+
8
8
  def setup
9
9
  setup_acceptance_test
10
10
  end
11
-
11
+
12
12
  def teardown
13
13
  teardown_acceptance_test
14
14
  end
15
-
15
+
16
16
  def test_should_allow_stubbing_private_instance_method
17
17
  Mocha::Configuration.allow(:stubbing_non_public_method)
18
18
  instance = Class.new do
@@ -25,7 +25,7 @@ class StubbingNonPublicInstanceMethodTest < Test::Unit::TestCase
25
25
  assert_passed(test_result)
26
26
  assert !@logger.warnings.include?("stubbing non-public method: #{instance.mocha_inspect}.private_method")
27
27
  end
28
-
28
+
29
29
  def test_should_allow_stubbing_protected_instance_method
30
30
  Mocha::Configuration.allow(:stubbing_non_public_method)
31
31
  instance = Class.new do
@@ -38,7 +38,7 @@ class StubbingNonPublicInstanceMethodTest < Test::Unit::TestCase
38
38
  assert_passed(test_result)
39
39
  assert !@logger.warnings.include?("stubbing non-public method: #{instance.mocha_inspect}.protected_method")
40
40
  end
41
-
41
+
42
42
  def test_should_warn_when_stubbing_private_instance_method
43
43
  Mocha::Configuration.warn_when(:stubbing_non_public_method)
44
44
  instance = Class.new do
@@ -51,7 +51,7 @@ class StubbingNonPublicInstanceMethodTest < Test::Unit::TestCase
51
51
  assert_passed(test_result)
52
52
  assert @logger.warnings.include?("stubbing non-public method: #{instance.mocha_inspect}.private_method")
53
53
  end
54
-
54
+
55
55
  def test_should_warn_when_stubbing_protected_instance_method
56
56
  Mocha::Configuration.warn_when(:stubbing_non_public_method)
57
57
  instance = Class.new do
@@ -64,7 +64,7 @@ class StubbingNonPublicInstanceMethodTest < Test::Unit::TestCase
64
64
  assert_passed(test_result)
65
65
  assert @logger.warnings.include?("stubbing non-public method: #{instance.mocha_inspect}.protected_method")
66
66
  end
67
-
67
+
68
68
  def test_should_prevent_stubbing_private_instance_method
69
69
  Mocha::Configuration.prevent(:stubbing_non_public_method)
70
70
  instance = Class.new do
@@ -77,7 +77,7 @@ class StubbingNonPublicInstanceMethodTest < Test::Unit::TestCase
77
77
  assert_failed(test_result)
78
78
  assert test_result.error_messages.include?("Mocha::StubbingError: stubbing non-public method: #{instance.mocha_inspect}.private_method")
79
79
  end
80
-
80
+
81
81
  def test_should_prevent_stubbing_protected_instance_method
82
82
  Mocha::Configuration.prevent(:stubbing_non_public_method)
83
83
  instance = Class.new do
@@ -90,7 +90,7 @@ class StubbingNonPublicInstanceMethodTest < Test::Unit::TestCase
90
90
  assert_failed(test_result)
91
91
  assert test_result.error_messages.include?("Mocha::StubbingError: stubbing non-public method: #{instance.mocha_inspect}.protected_method")
92
92
  end
93
-
93
+
94
94
  def test_should_default_to_allow_stubbing_private_instance_method
95
95
  instance = Class.new do
96
96
  def private_method; end
@@ -102,7 +102,7 @@ class StubbingNonPublicInstanceMethodTest < Test::Unit::TestCase
102
102
  assert_passed(test_result)
103
103
  assert !@logger.warnings.include?("stubbing non-public method: #{instance.mocha_inspect}.private_method")
104
104
  end
105
-
105
+
106
106
  def test_should_default_to_allow_stubbing_protected_instance_method
107
107
  instance = Class.new do
108
108
  def protected_method; end
@@ -114,7 +114,7 @@ class StubbingNonPublicInstanceMethodTest < Test::Unit::TestCase
114
114
  assert_passed(test_result)
115
115
  assert !@logger.warnings.include?("stubbing non-public method: #{instance.mocha_inspect}.protected_method")
116
116
  end
117
-
117
+
118
118
  def test_should_allow_stubbing_public_instance_method
119
119
  Mocha::Configuration.prevent(:stubbing_non_public_method)
120
120
  instance = Class.new do
@@ -2,17 +2,17 @@ require File.expand_path('../acceptance_test_helper', __FILE__)
2
2
  require 'mocha'
3
3
 
4
4
  class StubbingOnNonMockObjectTest < Test::Unit::TestCase
5
-
5
+
6
6
  include AcceptanceTest
7
-
7
+
8
8
  def setup
9
9
  setup_acceptance_test
10
10
  end
11
-
11
+
12
12
  def teardown
13
13
  teardown_acceptance_test
14
14
  end
15
-
15
+
16
16
  def test_should_allow_stubbing_method_on_non_mock_object
17
17
  Mocha::Configuration.allow(:stubbing_method_on_non_mock_object)
18
18
  non_mock_object = Class.new { def existing_method; end }
@@ -22,7 +22,7 @@ class StubbingOnNonMockObjectTest < Test::Unit::TestCase
22
22
  assert_passed(test_result)
23
23
  assert !@logger.warnings.include?("stubbing method on non-mock object: #{non_mock_object.mocha_inspect}.existing_method")
24
24
  end
25
-
25
+
26
26
  def test_should_warn_on_stubbing_method_on_non_mock_object
27
27
  Mocha::Configuration.warn_when(:stubbing_method_on_non_mock_object)
28
28
  non_mock_object = Class.new { def existing_method; end }
@@ -32,7 +32,7 @@ class StubbingOnNonMockObjectTest < Test::Unit::TestCase
32
32
  assert_passed(test_result)
33
33
  assert @logger.warnings.include?("stubbing method on non-mock object: #{non_mock_object.mocha_inspect}.existing_method")
34
34
  end
35
-
35
+
36
36
  def test_should_prevent_stubbing_method_on_non_mock_object
37
37
  Mocha::Configuration.prevent(:stubbing_method_on_non_mock_object)
38
38
  non_mock_object = Class.new { def existing_method; end }
@@ -42,7 +42,7 @@ class StubbingOnNonMockObjectTest < Test::Unit::TestCase
42
42
  assert_failed(test_result)
43
43
  assert test_result.error_messages.include?("Mocha::StubbingError: stubbing method on non-mock object: #{non_mock_object.mocha_inspect}.existing_method")
44
44
  end
45
-
45
+
46
46
  def test_should_default_to_allow_stubbing_method_on_non_mock_object
47
47
  non_mock_object = Class.new { def existing_method; end }
48
48
  test_result = run_as_test do
@@ -51,7 +51,7 @@ class StubbingOnNonMockObjectTest < Test::Unit::TestCase
51
51
  assert_passed(test_result)
52
52
  assert !@logger.warnings.include?("stubbing method on non-mock object: #{non_mock_object.mocha_inspect}.existing_method")
53
53
  end
54
-
54
+
55
55
  def test_should_allow_stubbing_method_on_mock_object
56
56
  Mocha::Configuration.prevent(:stubbing_method_on_non_mock_object)
57
57
  test_result = run_as_test do
@@ -61,4 +61,4 @@ class StubbingOnNonMockObjectTest < Test::Unit::TestCase
61
61
  assert_passed(test_result)
62
62
  end
63
63
 
64
- end
64
+ end
@@ -0,0 +1,35 @@
1
+ require File.expand_path('../acceptance_test_helper', __FILE__)
2
+ require 'mocha'
3
+
4
+ class Issue74Test < Test::Unit::TestCase
5
+
6
+ include AcceptanceTest
7
+
8
+ def setup
9
+ setup_acceptance_test
10
+ end
11
+
12
+ def teardown
13
+ teardown_acceptance_test
14
+ end
15
+
16
+ def test_stubbing_same_method_on_parent_and_child_classes
17
+ parent_class = Class.new do
18
+ def self.foo
19
+ "Parent.foo"
20
+ end
21
+ end
22
+ child_class = Class.new(parent_class)
23
+ test_result = run_as_tests(
24
+ lambda {
25
+ parent_class.stubs(:foo).returns("stubbed Parent.foo")
26
+ child_class.stubs(:foo).returns("stubbed Child.foo")
27
+ },
28
+ lambda {
29
+ parent_class.foo
30
+ child_class.foo
31
+ }
32
+ )
33
+ assert_passed(test_result)
34
+ end
35
+ end