mocha 1.4.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (230) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +58 -0
  3. data/.rubocop_todo.yml +50 -0
  4. data/README.md +12 -71
  5. data/RELEASE.md +19 -0
  6. data/Rakefile +35 -28
  7. data/bin/build-matrix +17 -18
  8. data/lib/mocha/any_instance_method.rb +19 -25
  9. data/lib/mocha/api.rb +1 -5
  10. data/lib/mocha/argument_iterator.rb +4 -8
  11. data/lib/mocha/backtrace_filter.rb +1 -5
  12. data/lib/mocha/cardinality.rb +20 -27
  13. data/lib/mocha/central.rb +21 -12
  14. data/lib/mocha/change_state_side_effect.rb +0 -4
  15. data/lib/mocha/class_method.rb +31 -37
  16. data/lib/mocha/class_methods.rb +11 -15
  17. data/lib/mocha/configuration.rb +69 -10
  18. data/lib/mocha/debug.rb +3 -2
  19. data/lib/mocha/deprecation.rb +4 -11
  20. data/lib/mocha/detection/mini_test.rb +0 -2
  21. data/lib/mocha/detection/test_unit.rb +4 -4
  22. data/lib/mocha/error_with_filtered_backtrace.rb +13 -0
  23. data/lib/mocha/exception_raiser.rb +2 -5
  24. data/lib/mocha/expectation.rb +15 -18
  25. data/lib/mocha/expectation_error.rb +2 -0
  26. data/lib/mocha/expectation_error_factory.rb +0 -1
  27. data/lib/mocha/expectation_list.rb +2 -6
  28. data/lib/mocha/hooks.rb +1 -3
  29. data/lib/mocha/in_state_ordering_constraint.rb +0 -4
  30. data/lib/mocha/inspect.rb +3 -5
  31. data/lib/mocha/instance_method.rb +0 -2
  32. data/lib/mocha/integration/mini_test/adapter.rb +2 -4
  33. data/lib/mocha/integration/mini_test/exception_translation.rb +1 -1
  34. data/lib/mocha/integration/mini_test/nothing.rb +4 -4
  35. data/lib/mocha/integration/mini_test/version_13.rb +4 -1
  36. data/lib/mocha/integration/mini_test/version_140.rb +4 -1
  37. data/lib/mocha/integration/mini_test/version_141.rb +4 -1
  38. data/lib/mocha/integration/mini_test/version_142_to_172.rb +4 -1
  39. data/lib/mocha/integration/mini_test/version_200.rb +4 -1
  40. data/lib/mocha/integration/mini_test/version_201_to_222.rb +4 -1
  41. data/lib/mocha/integration/mini_test/version_2110_to_2111.rb +4 -1
  42. data/lib/mocha/integration/mini_test/version_2112_to_320.rb +4 -1
  43. data/lib/mocha/integration/mini_test/version_230_to_2101.rb +4 -1
  44. data/lib/mocha/integration/monkey_patcher.rb +5 -7
  45. data/lib/mocha/integration/test_unit/adapter.rb +5 -6
  46. data/lib/mocha/integration/test_unit/gem_version_200.rb +5 -2
  47. data/lib/mocha/integration/test_unit/gem_version_201_to_202.rb +5 -2
  48. data/lib/mocha/integration/test_unit/gem_version_203_to_220.rb +5 -2
  49. data/lib/mocha/integration/test_unit/gem_version_230_to_250.rb +5 -2
  50. data/lib/mocha/integration/test_unit/nothing.rb +4 -4
  51. data/lib/mocha/integration/test_unit/ruby_version_185_and_below.rb +4 -1
  52. data/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb +4 -1
  53. data/lib/mocha/integration.rb +3 -4
  54. data/lib/mocha/is_a.rb +0 -2
  55. data/lib/mocha/logger.rb +0 -4
  56. data/lib/mocha/method_matcher.rb +1 -5
  57. data/lib/mocha/minitest.rb +1 -1
  58. data/lib/mocha/mock.rb +25 -30
  59. data/lib/mocha/mockery.rb +62 -43
  60. data/lib/mocha/module_method.rb +0 -10
  61. data/lib/mocha/module_methods.rb +0 -4
  62. data/lib/mocha/multiple_yields.rb +0 -5
  63. data/lib/mocha/names.rb +1 -11
  64. data/lib/mocha/no_yields.rb +1 -7
  65. data/lib/mocha/not_initialized_error.rb +7 -0
  66. data/lib/mocha/object_methods.rb +16 -16
  67. data/lib/mocha/parameter_matchers/all_of.rb +1 -7
  68. data/lib/mocha/parameter_matchers/any_of.rb +1 -7
  69. data/lib/mocha/parameter_matchers/any_parameters.rb +3 -9
  70. data/lib/mocha/parameter_matchers/anything.rb +2 -8
  71. data/lib/mocha/parameter_matchers/base.rb +6 -12
  72. data/lib/mocha/parameter_matchers/equals.rb +0 -6
  73. data/lib/mocha/parameter_matchers/equivalent_uri.rb +6 -6
  74. data/lib/mocha/parameter_matchers/has_entries.rb +2 -6
  75. data/lib/mocha/parameter_matchers/has_entry.rb +8 -11
  76. data/lib/mocha/parameter_matchers/has_key.rb +2 -6
  77. data/lib/mocha/parameter_matchers/has_value.rb +2 -6
  78. data/lib/mocha/parameter_matchers/includes.rb +2 -6
  79. data/lib/mocha/parameter_matchers/instance_of.rb +0 -6
  80. data/lib/mocha/parameter_matchers/is_a.rb +2 -6
  81. data/lib/mocha/parameter_matchers/kind_of.rb +2 -6
  82. data/lib/mocha/parameter_matchers/not.rb +2 -6
  83. data/lib/mocha/parameter_matchers/object.rb +0 -2
  84. data/lib/mocha/parameter_matchers/optionally.rb +4 -10
  85. data/lib/mocha/parameter_matchers/regexp_matches.rb +0 -6
  86. data/lib/mocha/parameter_matchers/responds_with.rb +3 -8
  87. data/lib/mocha/parameter_matchers/yaml_equivalent.rb +2 -6
  88. data/lib/mocha/parameter_matchers.rb +0 -2
  89. data/lib/mocha/parameters_matcher.rb +6 -9
  90. data/lib/mocha/pretty_parameters.rb +0 -4
  91. data/lib/mocha/receivers.rb +10 -14
  92. data/lib/mocha/return_values.rb +3 -7
  93. data/lib/mocha/sequence.rb +4 -9
  94. data/lib/mocha/single_return_value.rb +0 -4
  95. data/lib/mocha/single_yield.rb +0 -5
  96. data/lib/mocha/state_machine.rb +6 -10
  97. data/lib/mocha/stubbing_error.rb +2 -13
  98. data/lib/mocha/test_unit.rb +1 -1
  99. data/lib/mocha/thrower.rb +2 -5
  100. data/lib/mocha/unexpected_invocation.rb +3 -5
  101. data/lib/mocha/version.rb +1 -1
  102. data/lib/mocha/yield_parameters.rb +3 -7
  103. data/mocha.gemspec +34 -58
  104. data/test/acceptance/acceptance_test_helper.rb +0 -6
  105. data/test/acceptance/bug_18914_test.rb +7 -12
  106. data/test/acceptance/bug_21465_test.rb +0 -2
  107. data/test/acceptance/bug_21563_test.rb +0 -2
  108. data/test/acceptance/exception_rescue_test.rb +7 -8
  109. data/test/acceptance/expectations_on_multiple_methods_test.rb +2 -1
  110. data/test/acceptance/expected_invocation_count_test.rb +27 -29
  111. data/test/acceptance/failure_messages_test.rb +3 -5
  112. data/test/acceptance/issue_272_test.rb +0 -1
  113. data/test/acceptance/issue_65_test.rb +15 -13
  114. data/test/acceptance/issue_70_test.rb +0 -1
  115. data/test/acceptance/mocha_example_test.rb +5 -6
  116. data/test/acceptance/mocha_test_result_test.rb +7 -7
  117. data/test/acceptance/mock_test.rb +2 -4
  118. data/test/acceptance/mock_with_initializer_block_test.rb +0 -2
  119. data/test/acceptance/mocked_methods_dispatch_test.rb +0 -2
  120. data/test/acceptance/multiple_expectations_failure_message_test.rb +16 -17
  121. data/test/acceptance/optional_parameters_test.rb +0 -2
  122. data/test/acceptance/parameter_matcher_test.rb +2 -3
  123. data/test/acceptance/partial_mocks_test.rb +4 -6
  124. data/test/acceptance/prepend_test.rb +14 -16
  125. data/test/acceptance/prevent_use_of_mocha_outside_test_test.rb +77 -0
  126. data/test/acceptance/raise_exception_test.rb +2 -4
  127. data/test/acceptance/return_value_test.rb +0 -2
  128. data/test/acceptance/sequence_test.rb +9 -11
  129. data/test/acceptance/states_test.rb +6 -4
  130. data/test/acceptance/stub_any_instance_method_defined_on_superclass_test.rb +33 -2
  131. data/test/acceptance/stub_any_instance_method_test.rb +19 -17
  132. data/test/acceptance/stub_class_method_defined_on_active_record_association_proxy_test.rb +8 -8
  133. data/test/acceptance/stub_class_method_defined_on_class_test.rb +2 -1
  134. data/test/acceptance/stub_class_method_defined_on_module_test.rb +0 -1
  135. data/test/acceptance/stub_class_method_defined_on_superclass_test.rb +34 -1
  136. data/test/acceptance/stub_everything_test.rb +1 -3
  137. data/test/acceptance/stub_instance_method_defined_on_active_record_association_proxy_test.rb +6 -7
  138. data/test/acceptance/stub_instance_method_defined_on_class_and_aliased_test.rb +0 -1
  139. data/test/acceptance/stub_instance_method_defined_on_class_test.rb +0 -1
  140. data/test/acceptance/stub_instance_method_defined_on_kernel_module_test.rb +63 -1
  141. data/test/acceptance/stub_instance_method_defined_on_module_test.rb +0 -1
  142. data/test/acceptance/stub_instance_method_defined_on_object_class_test.rb +2 -1
  143. data/test/acceptance/stub_instance_method_defined_on_singleton_class_test.rb +0 -2
  144. data/test/acceptance/stub_instance_method_defined_on_superclass_test.rb +0 -1
  145. data/test/acceptance/stub_module_method_test.rb +13 -13
  146. data/test/acceptance/stub_test.rb +1 -3
  147. data/test/acceptance/stubba_example_test.rb +6 -14
  148. data/test/acceptance/stubba_test_result_test.rb +5 -8
  149. data/test/acceptance/stubbing_error_backtrace_test.rb +2 -2
  150. data/test/acceptance/stubbing_frozen_object_test.rb +2 -1
  151. data/test/acceptance/stubbing_method_accepting_block_parameter_test.rb +12 -7
  152. data/test/acceptance/stubbing_method_unnecessarily_test.rb +0 -2
  153. data/test/acceptance/stubbing_nil_test.rb +4 -5
  154. data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +1 -3
  155. data/test/acceptance/stubbing_non_existent_class_method_test.rb +3 -3
  156. data/test/acceptance/stubbing_non_existent_instance_method_test.rb +1 -3
  157. data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +0 -2
  158. data/test/acceptance/stubbing_non_public_class_method_test.rb +3 -3
  159. data/test/acceptance/stubbing_non_public_instance_method_test.rb +1 -3
  160. data/test/acceptance/stubbing_on_non_mock_object_test.rb +4 -10
  161. data/test/acceptance/stubbing_same_class_method_on_parent_and_child_classes_test.rb +3 -4
  162. data/test/acceptance/throw_test.rb +0 -2
  163. data/test/acceptance/unexpected_invocation_test.rb +2 -3
  164. data/test/acceptance/unstubbing_test.rb +41 -14
  165. data/test/deprecation_disabler.rb +0 -1
  166. data/test/execution_point.rb +2 -4
  167. data/test/integration/mini_test_test.rb +2 -2
  168. data/test/integration/shared_tests.rb +24 -22
  169. data/test/integration/test_unit_test.rb +2 -2
  170. data/test/method_definer.rb +1 -3
  171. data/test/mini_test_result.rb +17 -11
  172. data/test/minitest_result.rb +0 -1
  173. data/test/simple_counter.rb +0 -2
  174. data/test/test_helper.rb +13 -5
  175. data/test/test_runner.rb +2 -4
  176. data/test/test_unit_result.rb +4 -2
  177. data/test/unit/any_instance_method_test.rb +31 -17
  178. data/test/unit/array_inspect_test.rb +2 -4
  179. data/test/unit/backtrace_filter_test.rb +3 -5
  180. data/test/unit/cardinality_test.rb +0 -2
  181. data/test/unit/central_test.rb +26 -27
  182. data/test/unit/change_state_side_effect_test.rb +0 -4
  183. data/test/unit/class_method_test.rb +59 -34
  184. data/test/unit/class_methods_test.rb +34 -5
  185. data/test/unit/configuration_test.rb +1 -2
  186. data/test/unit/date_time_inspect_test.rb +1 -3
  187. data/test/unit/exception_raiser_test.rb +0 -2
  188. data/test/unit/expectation_list_test.rb +0 -2
  189. data/test/unit/expectation_test.rb +41 -46
  190. data/test/unit/hash_inspect_test.rb +3 -5
  191. data/test/unit/hooks_test.rb +14 -8
  192. data/test/unit/in_state_ordering_constraint_test.rb +0 -4
  193. data/test/unit/method_matcher_test.rb +1 -3
  194. data/test/unit/mock_test.rb +35 -22
  195. data/test/unit/mockery_test.rb +45 -28
  196. data/test/unit/module_methods_test.rb +0 -2
  197. data/test/unit/multiple_yields_test.rb +0 -2
  198. data/test/unit/no_yields_test.rb +0 -2
  199. data/test/unit/object_inspect_test.rb +16 -7
  200. data/test/unit/object_methods_test.rb +22 -6
  201. data/test/unit/parameter_matchers/all_of_test.rb +0 -2
  202. data/test/unit/parameter_matchers/any_of_test.rb +0 -2
  203. data/test/unit/parameter_matchers/anything_test.rb +2 -4
  204. data/test/unit/parameter_matchers/equals_test.rb +1 -3
  205. data/test/unit/parameter_matchers/equivalent_uri_test.rb +0 -1
  206. data/test/unit/parameter_matchers/has_entries_test.rb +2 -2
  207. data/test/unit/parameter_matchers/has_entry_test.rb +13 -14
  208. data/test/unit/parameter_matchers/has_key_test.rb +0 -1
  209. data/test/unit/parameter_matchers/has_value_test.rb +0 -2
  210. data/test/unit/parameter_matchers/includes_test.rb +8 -9
  211. data/test/unit/parameter_matchers/instance_of_test.rb +1 -3
  212. data/test/unit/parameter_matchers/is_a_test.rb +1 -3
  213. data/test/unit/parameter_matchers/kind_of_test.rb +1 -3
  214. data/test/unit/parameter_matchers/not_test.rb +0 -2
  215. data/test/unit/parameter_matchers/regexp_matches_test.rb +1 -2
  216. data/test/unit/parameter_matchers/responds_with_test.rb +9 -3
  217. data/test/unit/parameter_matchers/stub_matcher.rb +0 -4
  218. data/test/unit/parameter_matchers/yaml_equivalent_test.rb +1 -3
  219. data/test/unit/parameters_matcher_test.rb +2 -4
  220. data/test/unit/receivers_test.rb +35 -5
  221. data/test/unit/return_values_test.rb +3 -5
  222. data/test/unit/sequence_test.rb +1 -5
  223. data/test/unit/single_return_value_test.rb +0 -2
  224. data/test/unit/single_yield_test.rb +0 -2
  225. data/test/unit/state_machine_test.rb +1 -3
  226. data/test/unit/string_inspect_test.rb +2 -4
  227. data/test/unit/thrower_test.rb +0 -2
  228. data/test/unit/yield_parameters_test.rb +0 -2
  229. data/yard-templates/default/layout/html/setup.rb +2 -3
  230. metadata +25 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b1a4df2eb13604de6b309bc453307d375c055620
4
- data.tar.gz: 9144ebfe812beea562fc8c9ebdfb87326cb5ffa6
2
+ SHA256:
3
+ metadata.gz: 6a4829127b1767afd658a5e520e345b8ec4fcef1dd34c3ca5fb719aea017d1a4
4
+ data.tar.gz: 2d37035d149af5d3bc3cfed12879ec4656cec21dd7145041be83df95ca86e694
5
5
  SHA512:
6
- metadata.gz: 1cf5b923bb4a91c6b3a1dac90aca3084229955743ae64c41cbecf561e8fd572f419d09d155ff3c9b6d0616258ca526d70677d79f9861e8987f99ee5b312bbb90
7
- data.tar.gz: 9e635e0f0897d0437acffe0cfe4755ecae028da76513445a5b4b56ee48be878ae0070fa24d3fc8bddad02a69d790223909b936fdcdb6f53114feeec8c69cd3c4
6
+ metadata.gz: 01b91e4eae791aea7ad59d9170ad532ce610f2abd038594347e125f29e8e25614f0036a90690b15a3ffbf7ef603ca379f07507238f3820e315b9cec72bd3a730
7
+ data.tar.gz: 7cc96b39e8d553c69afcf4fc9186b2c2fbe38006f4bd0cee621e00eae81ed8621a3aac2f2e2b977ab36d8fd328b7297957d861bba2ad2a02f27113a2539c5472
data/.rubocop.yml ADDED
@@ -0,0 +1,58 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 2.2 # closest to required_ruby_version of '>= 1.8.6'
5
+
6
+ # Even the reference in the documentation suggests that you should prefer
7
+ # `alias_method` vs `alias`, so I don't understand why that isn't the default.
8
+ Style/Alias:
9
+ EnforcedStyle: prefer_alias_method
10
+
11
+ # Enumerable#each_with_object only available since Ruby v1.9
12
+ Style/EachWithObject:
13
+ Enabled: false
14
+
15
+ # Kernel#__dir__ has only been available since Ruby v2.0
16
+ Style/ExpandPathArguments:
17
+ Enabled: false
18
+
19
+ # Kernel#format has only supported named references since Ruby v1.9
20
+ Style/FormatStringToken:
21
+ EnforcedStyle: unannotated
22
+
23
+ # ruby19 style has only been supported since Ruby v1.9
24
+ Style/HashSyntax:
25
+ EnforcedStyle: hash_rockets
26
+
27
+ # I'm not keen on this cop, because it's easy to miss the conditional
28
+ # I think the results are particularly unhelpful when Metrics/LineLength is big
29
+ Style/IfUnlessModifier:
30
+ Enabled: false
31
+
32
+ # Lambda literal syntax has only been supported since Ruby v2.0
33
+ Style/Lambda:
34
+ EnforcedStyle: lambda
35
+
36
+ # Symbol array literal syntax has only been supported since Ruby v2.0
37
+ Style/SymbolArray:
38
+ Enabled: false
39
+
40
+ # I'm not keen on this cop, because it's easy to miss the while/until
41
+ Style/WhileUntilModifier:
42
+ Enabled: false
43
+
44
+ # This recently introduced cop seems to have stirred up some controversy
45
+ Style/AccessModifierDeclarations:
46
+ Enabled: false
47
+
48
+ # Enabling this cop results in an "Infinite loop detected" exception
49
+ Layout/AccessModifierIndentation:
50
+ Enabled: false
51
+
52
+ # Allow long comment lines, e.g. YARD documentation
53
+ Metrics/LineLength:
54
+ IgnoredPatterns: ['\A\s*#']
55
+
56
+ # It's not possible to set TargetRubyVersion to Ruby < v2.2
57
+ Gemspec/RequiredRubyVersion:
58
+ Enabled: false
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,50 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2018-07-26 12:42:35 +0100 using RuboCop version 0.58.2.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 53
10
+ Metrics/AbcSize:
11
+ Max: 39
12
+
13
+ # Offense count: 2
14
+ # Configuration parameters: CountComments, ExcludedMethods.
15
+ # ExcludedMethods: refine
16
+ Metrics/BlockLength:
17
+ Max: 48
18
+
19
+ # Offense count: 22
20
+ # Configuration parameters: CountComments.
21
+ Metrics/ClassLength:
22
+ Max: 368
23
+
24
+ # Offense count: 4
25
+ Metrics/CyclomaticComplexity:
26
+ Max: 9
27
+
28
+ # Offense count: 173
29
+ # Configuration parameters: CountComments.
30
+ Metrics/MethodLength:
31
+ Max: 31
32
+
33
+ # Offense count: 1
34
+ # Configuration parameters: CountComments.
35
+ Metrics/ModuleLength:
36
+ Max: 158
37
+
38
+ # Offense count: 5
39
+ Metrics/PerceivedComplexity:
40
+ Max: 11
41
+
42
+ # Offense count: 105
43
+ Style/Documentation:
44
+ Enabled: false
45
+
46
+ # Offense count: 501
47
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
48
+ # URISchemes: http, https
49
+ Metrics/LineLength:
50
+ Max: 180
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ## Mocha [![Build Status](https://travis-ci.org/freerange/mocha.svg?branch=master)](https://travis-ci.org/freerange/mocha) [![Gem Version](https://badge.fury.io/rb/mocha.png)](http://badge.fury.io/rb/mocha) [![OpenCollective](https://opencollective.com/mocha/backers/badge.svg)](#backers) [![OpenCollective](https://opencollective.com/mocha/sponsors/badge.svg)](#sponsors)
1
+ ## Mocha [![Build Status](https://travis-ci.org/freerange/mocha.svg?branch=master)](https://travis-ci.org/freerange/mocha) [![Gem Version](https://badge.fury.io/rb/mocha.svg)](http://badge.fury.io/rb/mocha) [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=mocha&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=mocha&package-manager=bundler&version-scheme=semver)
2
2
 
3
3
 
4
4
  ### Description
@@ -266,6 +266,17 @@ When a method is invoked on a mock object, the mock object searches through its
266
266
 
267
267
  See the [documentation](http://gofreerange.com/mocha/docs/Mocha/Mock.html) for `Mocha::Mock` for further details.
268
268
 
269
+ ### Configuration
270
+
271
+ If you want, Mocha can generate a warning or raise an exception when:
272
+
273
+ * stubbing a method unnecessarily
274
+ * stubbing method on a non-mock object
275
+ * stubbing a non-existent method
276
+ * stubbing a non-public method
277
+
278
+ See the [documentation](http://gofreerange.com/mocha/docs/Mocha/Configuration.html) for `Mocha::Configuration` for further details.
279
+
269
280
  ### Useful Links
270
281
 
271
282
  * [Official Documentation](http://gofreerange.com/mocha/docs/)
@@ -282,76 +293,6 @@ See the [documentation](http://gofreerange.com/mocha/docs/Mocha/Mock.html) for `
282
293
 
283
294
  See this [list of contributors](https://github.com/freerange/mocha/graphs/contributors).
284
295
 
285
- ### Backers
286
-
287
- Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/mocha#backer)]
288
-
289
- <a href="https://opencollective.com/mocha/backer/0/website" target="_blank"><img src="https://opencollective.com/mocha/backer/0/avatar.svg"></a>
290
- <a href="https://opencollective.com/mocha/backer/1/website" target="_blank"><img src="https://opencollective.com/mocha/backer/1/avatar.svg"></a>
291
- <a href="https://opencollective.com/mocha/backer/2/website" target="_blank"><img src="https://opencollective.com/mocha/backer/2/avatar.svg"></a>
292
- <a href="https://opencollective.com/mocha/backer/3/website" target="_blank"><img src="https://opencollective.com/mocha/backer/3/avatar.svg"></a>
293
- <a href="https://opencollective.com/mocha/backer/4/website" target="_blank"><img src="https://opencollective.com/mocha/backer/4/avatar.svg"></a>
294
- <a href="https://opencollective.com/mocha/backer/5/website" target="_blank"><img src="https://opencollective.com/mocha/backer/5/avatar.svg"></a>
295
- <a href="https://opencollective.com/mocha/backer/6/website" target="_blank"><img src="https://opencollective.com/mocha/backer/6/avatar.svg"></a>
296
- <a href="https://opencollective.com/mocha/backer/7/website" target="_blank"><img src="https://opencollective.com/mocha/backer/7/avatar.svg"></a>
297
- <a href="https://opencollective.com/mocha/backer/8/website" target="_blank"><img src="https://opencollective.com/mocha/backer/8/avatar.svg"></a>
298
- <a href="https://opencollective.com/mocha/backer/9/website" target="_blank"><img src="https://opencollective.com/mocha/backer/9/avatar.svg"></a>
299
- <a href="https://opencollective.com/mocha/backer/10/website" target="_blank"><img src="https://opencollective.com/mocha/backer/10/avatar.svg"></a>
300
- <a href="https://opencollective.com/mocha/backer/11/website" target="_blank"><img src="https://opencollective.com/mocha/backer/11/avatar.svg"></a>
301
- <a href="https://opencollective.com/mocha/backer/12/website" target="_blank"><img src="https://opencollective.com/mocha/backer/12/avatar.svg"></a>
302
- <a href="https://opencollective.com/mocha/backer/13/website" target="_blank"><img src="https://opencollective.com/mocha/backer/13/avatar.svg"></a>
303
- <a href="https://opencollective.com/mocha/backer/14/website" target="_blank"><img src="https://opencollective.com/mocha/backer/14/avatar.svg"></a>
304
- <a href="https://opencollective.com/mocha/backer/15/website" target="_blank"><img src="https://opencollective.com/mocha/backer/15/avatar.svg"></a>
305
- <a href="https://opencollective.com/mocha/backer/16/website" target="_blank"><img src="https://opencollective.com/mocha/backer/16/avatar.svg"></a>
306
- <a href="https://opencollective.com/mocha/backer/17/website" target="_blank"><img src="https://opencollective.com/mocha/backer/17/avatar.svg"></a>
307
- <a href="https://opencollective.com/mocha/backer/18/website" target="_blank"><img src="https://opencollective.com/mocha/backer/18/avatar.svg"></a>
308
- <a href="https://opencollective.com/mocha/backer/19/website" target="_blank"><img src="https://opencollective.com/mocha/backer/19/avatar.svg"></a>
309
- <a href="https://opencollective.com/mocha/backer/20/website" target="_blank"><img src="https://opencollective.com/mocha/backer/20/avatar.svg"></a>
310
- <a href="https://opencollective.com/mocha/backer/21/website" target="_blank"><img src="https://opencollective.com/mocha/backer/21/avatar.svg"></a>
311
- <a href="https://opencollective.com/mocha/backer/22/website" target="_blank"><img src="https://opencollective.com/mocha/backer/22/avatar.svg"></a>
312
- <a href="https://opencollective.com/mocha/backer/23/website" target="_blank"><img src="https://opencollective.com/mocha/backer/23/avatar.svg"></a>
313
- <a href="https://opencollective.com/mocha/backer/24/website" target="_blank"><img src="https://opencollective.com/mocha/backer/24/avatar.svg"></a>
314
- <a href="https://opencollective.com/mocha/backer/25/website" target="_blank"><img src="https://opencollective.com/mocha/backer/25/avatar.svg"></a>
315
- <a href="https://opencollective.com/mocha/backer/26/website" target="_blank"><img src="https://opencollective.com/mocha/backer/26/avatar.svg"></a>
316
- <a href="https://opencollective.com/mocha/backer/27/website" target="_blank"><img src="https://opencollective.com/mocha/backer/27/avatar.svg"></a>
317
- <a href="https://opencollective.com/mocha/backer/28/website" target="_blank"><img src="https://opencollective.com/mocha/backer/28/avatar.svg"></a>
318
- <a href="https://opencollective.com/mocha/backer/29/website" target="_blank"><img src="https://opencollective.com/mocha/backer/29/avatar.svg"></a>
319
-
320
- ### Sponsors
321
-
322
- Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/mocha#sponsor)]
323
-
324
- <a href="https://opencollective.com/mocha/sponsor/0/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/0/avatar.svg"></a>
325
- <a href="https://opencollective.com/mocha/sponsor/1/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/1/avatar.svg"></a>
326
- <a href="https://opencollective.com/mocha/sponsor/2/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/2/avatar.svg"></a>
327
- <a href="https://opencollective.com/mocha/sponsor/3/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/3/avatar.svg"></a>
328
- <a href="https://opencollective.com/mocha/sponsor/4/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/4/avatar.svg"></a>
329
- <a href="https://opencollective.com/mocha/sponsor/5/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/5/avatar.svg"></a>
330
- <a href="https://opencollective.com/mocha/sponsor/6/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/6/avatar.svg"></a>
331
- <a href="https://opencollective.com/mocha/sponsor/7/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/7/avatar.svg"></a>
332
- <a href="https://opencollective.com/mocha/sponsor/8/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/8/avatar.svg"></a>
333
- <a href="https://opencollective.com/mocha/sponsor/9/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/9/avatar.svg"></a>
334
- <a href="https://opencollective.com/mocha/sponsor/10/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/10/avatar.svg"></a>
335
- <a href="https://opencollective.com/mocha/sponsor/11/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/11/avatar.svg"></a>
336
- <a href="https://opencollective.com/mocha/sponsor/12/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/12/avatar.svg"></a>
337
- <a href="https://opencollective.com/mocha/sponsor/13/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/13/avatar.svg"></a>
338
- <a href="https://opencollective.com/mocha/sponsor/14/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/14/avatar.svg"></a>
339
- <a href="https://opencollective.com/mocha/sponsor/15/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/15/avatar.svg"></a>
340
- <a href="https://opencollective.com/mocha/sponsor/16/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/16/avatar.svg"></a>
341
- <a href="https://opencollective.com/mocha/sponsor/17/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/17/avatar.svg"></a>
342
- <a href="https://opencollective.com/mocha/sponsor/18/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/18/avatar.svg"></a>
343
- <a href="https://opencollective.com/mocha/sponsor/19/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/19/avatar.svg"></a>
344
- <a href="https://opencollective.com/mocha/sponsor/20/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/20/avatar.svg"></a>
345
- <a href="https://opencollective.com/mocha/sponsor/21/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/21/avatar.svg"></a>
346
- <a href="https://opencollective.com/mocha/sponsor/22/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/22/avatar.svg"></a>
347
- <a href="https://opencollective.com/mocha/sponsor/23/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/23/avatar.svg"></a>
348
- <a href="https://opencollective.com/mocha/sponsor/24/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/24/avatar.svg"></a>
349
- <a href="https://opencollective.com/mocha/sponsor/25/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/25/avatar.svg"></a>
350
- <a href="https://opencollective.com/mocha/sponsor/26/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/26/avatar.svg"></a>
351
- <a href="https://opencollective.com/mocha/sponsor/27/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/27/avatar.svg"></a>
352
- <a href="https://opencollective.com/mocha/sponsor/28/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/28/avatar.svg"></a>
353
- <a href="https://opencollective.com/mocha/sponsor/29/website" target="_blank"><img src="https://opencollective.com/mocha/sponsor/29/avatar.svg"></a>
354
-
355
296
  ### Translations
356
297
 
357
298
  * [Serbo-Croatian](http://science.webhostinggeeks.com/mocha) by [WHG Team](http://webhostinggeeks.com/). (may be out-of-date)
data/RELEASE.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Release Notes
2
2
 
3
+ ## 1.7.0
4
+
5
+ * Update Ruby & JRuby versions in Travis CI config (9bf55631 & 3883af7e)
6
+ * Simplify gemspec (63744f86)
7
+ * Add rubocop and fix most cop violations (#341)
8
+ * Use Kernel#warn for deprecations - thanks to @etiennebarrie (#333, 196970a)
9
+
10
+ ## 1.6.0
11
+
12
+ * Fix subtle bug in setting correct visibility of stubbed module methods on `Kernel` or `Object` - thanks to @chrisroos (#295)
13
+ * Avoid mocks for partial mocking leaking into subsequent tests - thanks to @skliew for reporting (#331)
14
+ * Remove OpenCollective badge, backers & sponsors (a283a079)
15
+ * Change gem version badge to SVG format and add SemVer stability badge - thanks to @greysteil (#335)
16
+ * Improve documentation for Configuration (#236)
17
+
18
+ ## 1.5.0
19
+
20
+ * Prevent use of Mocha outside the context of a test/example - thanks to @andyw8 & @lzap (#327)
21
+
3
22
  ## 1.4.0
4
23
 
5
24
  * Fix deprecation warning for `assert_nil` in `ClassMethodTest` (#308 & #309)
data/Rakefile CHANGED
@@ -1,17 +1,17 @@
1
- require "bundler"
1
+ require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
- require "bundler/setup"
3
+ require 'bundler/setup'
4
4
 
5
5
  MOCHA_DOCS_HOST = ENV['MOCHA_DOCS_HOST'] || 'gofreerange.com'
6
6
 
7
7
  require 'rake/testtask'
8
8
 
9
- desc "Run all tests"
9
+ desc 'Run all tests'
10
10
  task 'default' => ['test', 'test:performance']
11
11
 
12
- desc "Run tests"
12
+ desc 'Run tests'
13
13
  task 'test' do
14
- if test_library = ENV['MOCHA_RUN_INTEGRATION_TESTS']
14
+ if (test_library = ENV['MOCHA_RUN_INTEGRATION_TESTS'])
15
15
  Rake::Task["test:integration:#{test_library}"].invoke
16
16
  else
17
17
  Rake::Task['test:units'].invoke
@@ -20,13 +20,12 @@ task 'test' do
20
20
  end
21
21
 
22
22
  namespace 'test' do
23
-
24
23
  unit_tests = FileList['test/unit/**/*_test.rb']
25
24
  all_acceptance_tests = FileList['test/acceptance/*_test.rb']
26
25
  ruby186_incompatible_acceptance_tests = FileList['test/acceptance/stub_class_method_defined_on_*_test.rb'] + FileList['test/acceptance/stub_instance_method_defined_on_*_test.rb']
27
26
  ruby186_compatible_acceptance_tests = all_acceptance_tests - ruby186_incompatible_acceptance_tests
28
27
 
29
- desc "Run unit tests"
28
+ desc 'Run unit tests'
30
29
  Rake::TestTask.new('units') do |t|
31
30
  t.libs << 'test'
32
31
  t.test_files = unit_tests
@@ -34,20 +33,20 @@ namespace 'test' do
34
33
  t.warning = true
35
34
  end
36
35
 
37
- desc "Run acceptance tests"
36
+ desc 'Run acceptance tests'
38
37
  Rake::TestTask.new('acceptance') do |t|
39
38
  t.libs << 'test'
40
- if defined?(RUBY_VERSION) && (RUBY_VERSION >= "1.8.7")
41
- t.test_files = all_acceptance_tests
42
- else
43
- t.test_files = ruby186_compatible_acceptance_tests
44
- end
39
+ t.test_files = if defined?(RUBY_VERSION) && (RUBY_VERSION >= '1.8.7')
40
+ all_acceptance_tests
41
+ else
42
+ ruby186_compatible_acceptance_tests
43
+ end
45
44
  t.verbose = true
46
45
  t.warning = true
47
46
  end
48
47
 
49
48
  namespace 'integration' do
50
- desc "Run MiniTest integration tests (intended to be run in its own process)"
49
+ desc 'Run MiniTest integration tests (intended to be run in its own process)'
51
50
  Rake::TestTask.new('minitest') do |t|
52
51
  t.libs << 'test'
53
52
  t.test_files = FileList['test/integration/mini_test_test.rb']
@@ -55,7 +54,7 @@ namespace 'test' do
55
54
  t.warning = true
56
55
  end
57
56
 
58
- desc "Run Test::Unit integration tests (intended to be run in its own process)"
57
+ desc 'Run Test::Unit integration tests (intended to be run in its own process)'
59
58
  Rake::TestTask.new('test-unit') do |t|
60
59
  t.libs << 'test'
61
60
  t.test_files = FileList['test/integration/test_unit_test.rb']
@@ -74,7 +73,7 @@ namespace 'test' do
74
73
  # t.rcov_opts << '--xref'
75
74
  # end
76
75
 
77
- desc "Run performance tests"
76
+ desc 'Run performance tests'
78
77
  task 'performance' do
79
78
  require File.join(File.dirname(__FILE__), 'test', 'acceptance', 'stubba_example_test')
80
79
  require File.join(File.dirname(__FILE__), 'test', 'acceptance', 'mocha_example_test')
@@ -84,7 +83,15 @@ namespace 'test' do
84
83
  puts "#{test_case}: #{benchmark_test_case(test_case, iterations)} seconds."
85
84
  end
86
85
  end
86
+ end
87
87
 
88
+ begin
89
+ require 'rubocop/rake_task'
90
+ if RUBY_VERSION >= '2.2.0'
91
+ RuboCop::RakeTask.new
92
+ task 'test' => 'rubocop'
93
+ end
94
+ rescue LoadError # rubocop:disable Lint/HandleExceptions
88
95
  end
89
96
 
90
97
  def benchmark_test_case(klass, iterations)
@@ -94,28 +101,28 @@ def benchmark_test_case(klass, iterations)
94
101
  if defined?(MiniTest)
95
102
  minitest_version = Gem::Version.new(Mocha::Detection::MiniTest.version)
96
103
  if Gem::Requirement.new('>= 5.0.0').satisfied_by?(minitest_version)
97
- result = Benchmark.realtime { iterations.times { |i| klass.run(MiniTest::CompositeReporter.new) } }
104
+ result = Benchmark.realtime { iterations.times { |_i| klass.run(MiniTest::CompositeReporter.new) } }
98
105
  MiniTest::Runnable.runnables.delete(klass)
99
106
  result
100
107
  else
101
108
  MiniTest::Unit.output = StringIO.new
102
- Benchmark.realtime { iterations.times { |i| MiniTest::Unit.new.run([klass]) } }
109
+ Benchmark.realtime { iterations.times { |_i| MiniTest::Unit.new.run([klass]) } }
103
110
  end
104
111
  else
105
112
  load 'test/unit/ui/console/testrunner.rb' unless defined?(Test::Unit::UI::Console::TestRunner)
106
- unless $silent_option
113
+ unless @silent_option
107
114
  begin
108
115
  load 'test/unit/ui/console/outputlevel.rb' unless defined?(Test::Unit::UI::Console::OutputLevel::SILENT)
109
- $silent_option = { :output_level => Test::Unit::UI::Console::OutputLevel::SILENT }
116
+ @silent_option = { :output_level => Test::Unit::UI::Console::OutputLevel::SILENT }
110
117
  rescue LoadError
111
- $silent_option = Test::Unit::UI::SILENT
118
+ @silent_option = Test::Unit::UI::SILENT
112
119
  end
113
120
  end
114
- Benchmark.realtime { iterations.times { Test::Unit::UI::Console::TestRunner.run(klass, $silent_option) } }
121
+ Benchmark.realtime { iterations.times { Test::Unit::UI::Console::TestRunner.run(klass, @silent_option) } }
115
122
  end
116
123
  end
117
124
 
118
- if ENV["MOCHA_GENERATE_DOCS"]
125
+ if ENV['MOCHA_GENERATE_DOCS']
119
126
  require 'yard'
120
127
 
121
128
  desc 'Remove generated documentation'
@@ -131,16 +138,16 @@ if ENV["MOCHA_GENERATE_DOCS"]
131
138
 
132
139
  desc 'Generate documentation'
133
140
  YARD::Rake::YardocTask.new('yardoc' => 'docs_environment') do |task|
134
- task.options = ["--title", "Mocha #{Mocha::VERSION}"]
141
+ task.options = ['--title', "Mocha #{Mocha::VERSION}"]
135
142
  end
136
143
 
137
- desc "Generate documentation"
138
- task 'generate_docs' => ['clobber_yardoc', 'yardoc']
144
+ desc 'Generate documentation'
145
+ task 'generate_docs' => %w[clobber_yardoc yardoc]
139
146
 
140
147
  desc "Publish docs to #{MOCHA_DOCS_HOST}/docs/mocha"
141
148
  task 'publish_docs' => 'generate_docs' do
142
- path = "/home/freerange/docs/mocha"
143
- system %{ssh #{MOCHA_DOCS_HOST} "sudo rm -fr #{path} && mkdir -p #{path}" && scp -r doc/* #{MOCHA_DOCS_HOST}:#{path}}
149
+ path = '/home/freerange/docs/mocha'
150
+ system %(ssh #{MOCHA_DOCS_HOST} "sudo rm -fr #{path} && mkdir -p #{path}" && scp -r doc/* #{MOCHA_DOCS_HOST}:#{path})
144
151
  end
145
152
  end
146
153
 
data/bin/build-matrix CHANGED
@@ -5,23 +5,22 @@ require 'yaml'
5
5
  def execute(*commands)
6
6
  commands.each do |command|
7
7
  system(command)
8
- unless $?.success?
9
- message = [
10
- "Executing shell command failed.",
11
- " Command: #{command}",
12
- " Status: #{$?.exitstatus}"
13
- ].join("\n")
14
- raise message
15
- end
8
+ next if $CHILD_STATUS.success?
9
+ message = [
10
+ 'Executing shell command failed.',
11
+ " Command: #{command}",
12
+ " Status: #{$CHILD_STATUS.exitstatus}"
13
+ ].join("\n")
14
+ raise message
16
15
  end
17
16
  end
18
17
 
19
18
  def reset_bundle
20
19
  execute(
21
- "rm -rf .bundle/gems",
22
- "rm -rf gemfiles/.bundle/gems",
23
- "rm -f *.lock",
24
- "rm -f gemfiles/*.lock"
20
+ 'rm -rf .bundle/gems',
21
+ 'rm -rf gemfiles/.bundle/gems',
22
+ 'rm -f *.lock',
23
+ 'rm -f gemfiles/*.lock'
25
24
  )
26
25
  end
27
26
 
@@ -29,18 +28,18 @@ def with_rbenv(command)
29
28
  %{export PATH="$HOME/.rbenv/bin:$PATH"; eval "$(rbenv init -)"; #{command}}
30
29
  end
31
30
 
32
- def run(ruby_version, gemfile, task = "test")
33
- ENV["RBENV_VERSION"] = ruby_version
34
- ENV["BUNDLE_GEMFILE"] = gemfile
35
- ENV["MOCHA_OPTIONS"] = "debug"
31
+ def run(ruby_version, gemfile, task = 'test')
32
+ ENV['RBENV_VERSION'] = ruby_version
33
+ ENV['BUNDLE_GEMFILE'] = gemfile
34
+ ENV['MOCHA_OPTIONS'] = 'debug'
36
35
  reset_bundle
37
36
  execute(
38
37
  with_rbenv("bundle install --gemfile=#{gemfile}"),
39
- with_rbenv("bundle exec rake #{task}"),
38
+ with_rbenv("bundle exec rake #{task}")
40
39
  )
41
40
  end
42
41
 
43
- travis_config = YAML.load(File.read('.travis.yml'))
42
+ travis_config = YAML.safe_load(File.read('.travis.yml'))
44
43
  build_configs = travis_config['matrix']['include']
45
44
  travis_config['rvm'].each do |ruby_version|
46
45
  travis_config['gemfile'].each do |gemfile|
@@ -2,9 +2,7 @@ require 'mocha/ruby_version'
2
2
  require 'mocha/class_method'
3
3
 
4
4
  module Mocha
5
-
6
5
  class AnyInstanceMethod < ClassMethod
7
-
8
6
  def mock
9
7
  stubbee.any_instance.mocha
10
8
  end
@@ -14,21 +12,22 @@ module Mocha
14
12
  end
15
13
 
16
14
  def hide_original_method
17
- if @original_visibility = method_visibility(method)
18
- begin
19
- if RUBY_V2_PLUS
20
- @definition_target = PrependedModule.new
21
- stubbee.__send__ :prepend, @definition_target
22
- else
23
- @original_method = stubbee.instance_method(method)
24
- if @original_method && @original_method.owner == stubbee
25
- stubbee.send(:remove_method, method)
26
- end
15
+ return unless (@original_visibility = method_visibility(method))
16
+ begin
17
+ if RUBY_V2_PLUS
18
+ @definition_target = PrependedModule.new
19
+ stubbee.__send__ :prepend, @definition_target
20
+ else
21
+ @original_method = stubbee.instance_method(method)
22
+ if @original_method && @original_method.owner == stubbee
23
+ stubbee.send(:remove_method, method)
27
24
  end
28
- rescue NameError
29
- # deal with nasties like ActiveRecord::Associations::AssociationProxy
30
25
  end
26
+ # rubocop:disable Lint/HandleExceptions
27
+ rescue NameError
28
+ # deal with nasties like ActiveRecord::Associations::AssociationProxy
31
29
  end
30
+ # rubocop:enable Lint/HandleExceptions
32
31
  end
33
32
 
34
33
  def define_new_method
@@ -37,9 +36,8 @@ module Mocha
37
36
  self.class.any_instance.mocha.method_missing(:#{method}, *args, &block)
38
37
  end
39
38
  CODE
40
- if @original_visibility
41
- Module.instance_method(@original_visibility).bind(definition_target).call(method)
42
- end
39
+ return unless @original_visibility
40
+ Module.instance_method(@original_visibility).bind(definition_target).call(method)
43
41
  end
44
42
 
45
43
  def remove_new_method
@@ -47,12 +45,10 @@ module Mocha
47
45
  end
48
46
 
49
47
  def restore_original_method
50
- unless RUBY_V2_PLUS
51
- if @original_method && @original_method.owner == stubbee
52
- stubbee.send(:define_method, method, @original_method)
53
- Module.instance_method(@original_visibility).bind(stubbee).call(method)
54
- end
55
- end
48
+ return if RUBY_V2_PLUS
49
+ return unless @original_method && @original_method.owner == stubbee
50
+ stubbee.send(:define_method, method, @original_method)
51
+ Module.instance_method(@original_visibility).bind(stubbee).call(method)
56
52
  end
57
53
 
58
54
  def method_visibility(method)
@@ -66,7 +62,5 @@ module Mocha
66
62
  def definition_target
67
63
  @definition_target ||= stubbee
68
64
  end
69
-
70
65
  end
71
-
72
66
  end
data/lib/mocha/api.rb CHANGED
@@ -7,15 +7,13 @@ require 'mocha/module_methods'
7
7
  require 'mocha/class_methods'
8
8
 
9
9
  module Mocha
10
-
11
10
  # Methods added to +Test::Unit::TestCase+, +MiniTest::Unit::TestCase+ or equivalent.
12
11
  module API
13
-
14
12
  include ParameterMatchers
15
13
  include Hooks
16
14
 
17
15
  # @private
18
- def self.included(mod)
16
+ def self.included(_mod)
19
17
  Object.send(:include, Mocha::ObjectMethods)
20
18
  Module.send(:include, Mocha::ModuleMethods)
21
19
  Class.send(:include, Mocha::ClassMethods)
@@ -176,7 +174,5 @@ module Mocha
176
174
  def states(name)
177
175
  Mockery.instance.new_state_machine(name)
178
176
  end
179
-
180
177
  end
181
-
182
178
  end
@@ -1,21 +1,17 @@
1
1
  module Mocha
2
-
3
2
  class ArgumentIterator
4
-
5
3
  def initialize(argument)
6
4
  @argument = argument
7
5
  end
8
6
 
9
- def each(&block)
10
- if @argument.is_a?(Hash) then
7
+ def each
8
+ if @argument.is_a?(Hash)
11
9
  @argument.each do |method_name, return_value|
12
- block.call(method_name, return_value)
10
+ yield method_name, return_value
13
11
  end
14
12
  else
15
- block.call(@argument)
13
+ yield @argument
16
14
  end
17
15
  end
18
-
19
16
  end
20
-
21
17
  end
@@ -1,8 +1,6 @@
1
1
  module Mocha
2
-
3
2
  class BacktraceFilter
4
-
5
- LIB_DIRECTORY = File.expand_path(File.join(File.dirname(__FILE__), "..")) + File::SEPARATOR
3
+ LIB_DIRECTORY = File.expand_path(File.join(File.dirname(__FILE__), '..')) + File::SEPARATOR
6
4
 
7
5
  def initialize(lib_directory = LIB_DIRECTORY)
8
6
  @path_pattern = Regexp.new(lib_directory)
@@ -11,7 +9,5 @@ module Mocha
11
9
  def filtered(backtrace)
12
10
  backtrace.reject { |location| @path_pattern.match(File.expand_path(location)) }
13
11
  end
14
-
15
12
  end
16
-
17
13
  end