mocha 1.4.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (269) hide show
  1. checksums.yaml +5 -5
  2. data/.github/FUNDING.yml +1 -0
  3. data/.rubocop.yml +53 -0
  4. data/.rubocop_todo.yml +27 -0
  5. data/.yardopts +1 -1
  6. data/CONTRIBUTING.md +4 -9
  7. data/COPYING.md +2 -2
  8. data/Gemfile +27 -0
  9. data/MIT-LICENSE.md +1 -1
  10. data/README.md +88 -117
  11. data/RELEASE.md +340 -0
  12. data/Rakefile +53 -52
  13. data/gemfiles/Gemfile.minitest.latest +1 -0
  14. data/gemfiles/Gemfile.test-unit.latest +2 -5
  15. data/lib/mocha/any_instance_method.rb +9 -62
  16. data/lib/mocha/api.rb +84 -74
  17. data/lib/mocha/argument_iterator.rb +4 -8
  18. data/lib/mocha/backtrace_filter.rb +3 -7
  19. data/lib/mocha/block_matcher.rb +31 -0
  20. data/lib/mocha/cardinality.rb +60 -49
  21. data/lib/mocha/central.rb +21 -12
  22. data/lib/mocha/change_state_side_effect.rb +0 -4
  23. data/lib/mocha/class_methods.rb +19 -21
  24. data/lib/mocha/configuration.rb +317 -52
  25. data/lib/mocha/debug.rb +2 -4
  26. data/lib/mocha/deprecation.rb +6 -12
  27. data/lib/mocha/detection/mini_test.rb +0 -2
  28. data/lib/mocha/detection/test_unit.rb +3 -5
  29. data/lib/mocha/error_with_filtered_backtrace.rb +13 -0
  30. data/lib/mocha/exception_raiser.rb +4 -6
  31. data/lib/mocha/expectation.rb +186 -95
  32. data/lib/mocha/expectation_error.rb +1 -1
  33. data/lib/mocha/expectation_error_factory.rb +0 -1
  34. data/lib/mocha/expectation_list.rb +7 -11
  35. data/lib/mocha/hooks.rb +1 -3
  36. data/lib/mocha/in_state_ordering_constraint.rb +0 -4
  37. data/lib/mocha/inspect.rb +30 -28
  38. data/lib/mocha/instance_method.rb +14 -3
  39. data/lib/mocha/integration/mini_test/adapter.rb +3 -5
  40. data/lib/mocha/integration/mini_test/exception_translation.rb +1 -1
  41. data/lib/mocha/integration/mini_test.rb +10 -31
  42. data/lib/mocha/integration/monkey_patcher.rb +5 -7
  43. data/lib/mocha/integration/test_unit/adapter.rb +8 -9
  44. data/lib/mocha/integration/test_unit.rb +10 -26
  45. data/lib/mocha/invocation.rb +73 -0
  46. data/lib/mocha/is_a.rb +0 -2
  47. data/lib/mocha/logger.rb +0 -4
  48. data/lib/mocha/macos_version.rb +5 -0
  49. data/lib/mocha/method_matcher.rb +1 -5
  50. data/lib/mocha/minitest.rb +5 -2
  51. data/lib/mocha/mock.rb +104 -68
  52. data/lib/mocha/mockery.rb +70 -99
  53. data/lib/mocha/names.rb +2 -12
  54. data/lib/mocha/not_initialized_error.rb +7 -0
  55. data/lib/mocha/object_methods.rb +25 -31
  56. data/lib/mocha/parameter_matchers/all_of.rb +2 -8
  57. data/lib/mocha/parameter_matchers/any_of.rb +2 -8
  58. data/lib/mocha/parameter_matchers/any_parameters.rb +3 -9
  59. data/lib/mocha/parameter_matchers/anything.rb +2 -8
  60. data/lib/mocha/parameter_matchers/base.rb +7 -13
  61. data/lib/mocha/parameter_matchers/equals.rb +0 -6
  62. data/lib/mocha/parameter_matchers/equivalent_uri.rb +3 -13
  63. data/lib/mocha/parameter_matchers/has_entries.rb +2 -7
  64. data/lib/mocha/parameter_matchers/has_entry.rb +26 -21
  65. data/lib/mocha/parameter_matchers/has_key.rb +2 -7
  66. data/lib/mocha/parameter_matchers/has_keys.rb +53 -0
  67. data/lib/mocha/parameter_matchers/has_value.rb +2 -7
  68. data/lib/mocha/parameter_matchers/includes.rb +4 -6
  69. data/lib/mocha/parameter_matchers/instance_methods.rb +27 -0
  70. data/lib/mocha/parameter_matchers/instance_of.rb +0 -6
  71. data/lib/mocha/parameter_matchers/is_a.rb +2 -7
  72. data/lib/mocha/parameter_matchers/kind_of.rb +2 -6
  73. data/lib/mocha/parameter_matchers/not.rb +2 -7
  74. data/lib/mocha/parameter_matchers/optionally.rb +4 -10
  75. data/lib/mocha/parameter_matchers/positional_or_keyword_hash.rb +64 -0
  76. data/lib/mocha/parameter_matchers/regexp_matches.rb +0 -6
  77. data/lib/mocha/parameter_matchers/responds_with.rb +3 -8
  78. data/lib/mocha/parameter_matchers/yaml_equivalent.rb +2 -6
  79. data/lib/mocha/parameter_matchers.rb +2 -3
  80. data/lib/mocha/parameters_matcher.rb +8 -11
  81. data/lib/mocha/raised_exception.rb +11 -0
  82. data/lib/mocha/receivers.rb +10 -14
  83. data/lib/mocha/return_values.rb +4 -8
  84. data/lib/mocha/ruby_version.rb +1 -2
  85. data/lib/mocha/sequence.rb +4 -9
  86. data/lib/mocha/single_return_value.rb +2 -5
  87. data/lib/mocha/state_machine.rb +33 -46
  88. data/lib/mocha/stubbed_method.rb +88 -0
  89. data/lib/mocha/stubbing_error.rb +2 -13
  90. data/lib/mocha/test_unit.rb +5 -2
  91. data/lib/mocha/thrower.rb +4 -6
  92. data/lib/mocha/thrown_object.rb +12 -0
  93. data/lib/mocha/version.rb +1 -1
  94. data/lib/mocha/yield_parameters.rb +7 -17
  95. data/mocha.gemspec +15 -65
  96. metadata +27 -257
  97. data/bin/build-matrix +0 -70
  98. data/gemfiles/Gemfile.minitest.1.3.0 +0 -7
  99. data/gemfiles/Gemfile.minitest.1.4.0 +0 -7
  100. data/gemfiles/Gemfile.minitest.1.4.1 +0 -7
  101. data/gemfiles/Gemfile.minitest.1.4.2 +0 -7
  102. data/gemfiles/Gemfile.minitest.2.0.0 +0 -7
  103. data/gemfiles/Gemfile.minitest.2.0.1 +0 -7
  104. data/gemfiles/Gemfile.minitest.2.11.0 +0 -7
  105. data/gemfiles/Gemfile.minitest.2.11.2 +0 -7
  106. data/gemfiles/Gemfile.minitest.2.3.0 +0 -7
  107. data/gemfiles/Gemfile.test-unit.2.0.0 +0 -7
  108. data/gemfiles/Gemfile.test-unit.2.0.1 +0 -7
  109. data/gemfiles/Gemfile.test-unit.2.0.3 +0 -7
  110. data/init.rb +0 -3
  111. data/lib/mocha/class_method.rb +0 -119
  112. data/lib/mocha/integration/mini_test/nothing.rb +0 -19
  113. data/lib/mocha/integration/mini_test/version_13.rb +0 -51
  114. data/lib/mocha/integration/mini_test/version_140.rb +0 -51
  115. data/lib/mocha/integration/mini_test/version_141.rb +0 -62
  116. data/lib/mocha/integration/mini_test/version_142_to_172.rb +0 -62
  117. data/lib/mocha/integration/mini_test/version_200.rb +0 -63
  118. data/lib/mocha/integration/mini_test/version_201_to_222.rb +0 -63
  119. data/lib/mocha/integration/mini_test/version_2110_to_2111.rb +0 -67
  120. data/lib/mocha/integration/mini_test/version_2112_to_320.rb +0 -70
  121. data/lib/mocha/integration/mini_test/version_230_to_2101.rb +0 -65
  122. data/lib/mocha/integration/test_unit/gem_version_200.rb +0 -59
  123. data/lib/mocha/integration/test_unit/gem_version_201_to_202.rb +0 -59
  124. data/lib/mocha/integration/test_unit/gem_version_203_to_220.rb +0 -59
  125. data/lib/mocha/integration/test_unit/gem_version_230_to_250.rb +0 -65
  126. data/lib/mocha/integration/test_unit/nothing.rb +0 -19
  127. data/lib/mocha/integration/test_unit/ruby_version_185_and_below.rb +0 -58
  128. data/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb +0 -60
  129. data/lib/mocha/integration.rb +0 -14
  130. data/lib/mocha/mini_test.rb +0 -5
  131. data/lib/mocha/module_method.rb +0 -16
  132. data/lib/mocha/module_methods.rb +0 -14
  133. data/lib/mocha/multiple_yields.rb +0 -20
  134. data/lib/mocha/no_yields.rb +0 -11
  135. data/lib/mocha/parameter_matchers/object.rb +0 -17
  136. data/lib/mocha/pretty_parameters.rb +0 -28
  137. data/lib/mocha/setup.rb +0 -9
  138. data/lib/mocha/single_yield.rb +0 -18
  139. data/lib/mocha/standalone.rb +0 -4
  140. data/lib/mocha/unexpected_invocation.rb +0 -26
  141. data/lib/mocha_standalone.rb +0 -4
  142. data/test/acceptance/acceptance_test_helper.rb +0 -41
  143. data/test/acceptance/bug_18914_test.rb +0 -43
  144. data/test/acceptance/bug_21465_test.rb +0 -34
  145. data/test/acceptance/bug_21563_test.rb +0 -25
  146. data/test/acceptance/exception_rescue_test.rb +0 -55
  147. data/test/acceptance/expectations_on_multiple_methods_test.rb +0 -55
  148. data/test/acceptance/expected_invocation_count_test.rb +0 -232
  149. data/test/acceptance/failure_messages_test.rb +0 -64
  150. data/test/acceptance/issue_272_test.rb +0 -52
  151. data/test/acceptance/issue_65_test.rb +0 -63
  152. data/test/acceptance/issue_70_test.rb +0 -55
  153. data/test/acceptance/mocha_example_test.rb +0 -98
  154. data/test/acceptance/mocha_test_result_test.rb +0 -84
  155. data/test/acceptance/mock_test.rb +0 -100
  156. data/test/acceptance/mock_with_initializer_block_test.rb +0 -58
  157. data/test/acceptance/mocked_methods_dispatch_test.rb +0 -78
  158. data/test/acceptance/multiple_expectations_failure_message_test.rb +0 -68
  159. data/test/acceptance/optional_parameters_test.rb +0 -70
  160. data/test/acceptance/parameter_matcher_test.rb +0 -301
  161. data/test/acceptance/partial_mocks_test.rb +0 -47
  162. data/test/acceptance/prepend_test.rb +0 -89
  163. data/test/acceptance/raise_exception_test.rb +0 -39
  164. data/test/acceptance/return_value_test.rb +0 -52
  165. data/test/acceptance/sequence_test.rb +0 -192
  166. data/test/acceptance/states_test.rb +0 -70
  167. data/test/acceptance/stub_any_instance_method_defined_on_superclass_test.rb +0 -34
  168. data/test/acceptance/stub_any_instance_method_test.rb +0 -280
  169. data/test/acceptance/stub_class_method_defined_on_active_record_association_proxy_test.rb +0 -106
  170. data/test/acceptance/stub_class_method_defined_on_class_test.rb +0 -78
  171. data/test/acceptance/stub_class_method_defined_on_module_test.rb +0 -75
  172. data/test/acceptance/stub_class_method_defined_on_superclass_test.rb +0 -112
  173. data/test/acceptance/stub_everything_test.rb +0 -56
  174. data/test/acceptance/stub_instance_method_defined_on_active_record_association_proxy_test.rb +0 -93
  175. data/test/acceptance/stub_instance_method_defined_on_class_and_aliased_test.rb +0 -69
  176. data/test/acceptance/stub_instance_method_defined_on_class_test.rb +0 -69
  177. data/test/acceptance/stub_instance_method_defined_on_kernel_module_test.rb +0 -75
  178. data/test/acceptance/stub_instance_method_defined_on_module_test.rb +0 -78
  179. data/test/acceptance/stub_instance_method_defined_on_object_class_test.rb +0 -75
  180. data/test/acceptance/stub_instance_method_defined_on_singleton_class_test.rb +0 -70
  181. data/test/acceptance/stub_instance_method_defined_on_superclass_test.rb +0 -72
  182. data/test/acceptance/stub_method_defined_on_module_and_aliased_test.rb +0 -39
  183. data/test/acceptance/stub_module_method_test.rb +0 -201
  184. data/test/acceptance/stub_test.rb +0 -52
  185. data/test/acceptance/stubba_example_test.rb +0 -102
  186. data/test/acceptance/stubba_test_result_test.rb +0 -75
  187. data/test/acceptance/stubbing_error_backtrace_test.rb +0 -64
  188. data/test/acceptance/stubbing_frozen_object_test.rb +0 -88
  189. data/test/acceptance/stubbing_method_accepting_block_parameter_test.rb +0 -48
  190. data/test/acceptance/stubbing_method_unnecessarily_test.rb +0 -65
  191. data/test/acceptance/stubbing_nil_test.rb +0 -61
  192. data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +0 -143
  193. data/test/acceptance/stubbing_non_existent_class_method_test.rb +0 -157
  194. data/test/acceptance/stubbing_non_existent_instance_method_test.rb +0 -147
  195. data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +0 -130
  196. data/test/acceptance/stubbing_non_public_class_method_test.rb +0 -163
  197. data/test/acceptance/stubbing_non_public_instance_method_test.rb +0 -143
  198. data/test/acceptance/stubbing_on_non_mock_object_test.rb +0 -76
  199. data/test/acceptance/stubbing_same_class_method_on_parent_and_child_classes_test.rb +0 -35
  200. data/test/acceptance/throw_test.rb +0 -45
  201. data/test/acceptance/unexpected_invocation_test.rb +0 -25
  202. data/test/acceptance/unstubbing_test.rb +0 -168
  203. data/test/assertions.rb +0 -8
  204. data/test/deprecation_disabler.rb +0 -16
  205. data/test/execution_point.rb +0 -38
  206. data/test/integration/mini_test_test.rb +0 -8
  207. data/test/integration/shared_tests.rb +0 -174
  208. data/test/integration/test_unit_test.rb +0 -8
  209. data/test/method_definer.rb +0 -24
  210. data/test/mini_test_result.rb +0 -90
  211. data/test/minitest_result.rb +0 -49
  212. data/test/simple_counter.rb +0 -13
  213. data/test/test_helper.rb +0 -50
  214. data/test/test_runner.rb +0 -58
  215. data/test/test_unit_result.rb +0 -20
  216. data/test/unit/any_instance_method_test.rb +0 -136
  217. data/test/unit/array_inspect_test.rb +0 -16
  218. data/test/unit/backtrace_filter_test.rb +0 -19
  219. data/test/unit/cardinality_test.rb +0 -56
  220. data/test/unit/central_test.rb +0 -100
  221. data/test/unit/change_state_side_effect_test.rb +0 -41
  222. data/test/unit/class_method_test.rb +0 -229
  223. data/test/unit/class_methods_test.rb +0 -40
  224. data/test/unit/configuration_test.rb +0 -38
  225. data/test/unit/date_time_inspect_test.rb +0 -21
  226. data/test/unit/exception_raiser_test.rb +0 -42
  227. data/test/unit/expectation_list_test.rb +0 -82
  228. data/test/unit/expectation_test.rb +0 -497
  229. data/test/unit/hash_inspect_test.rb +0 -16
  230. data/test/unit/hooks_test.rb +0 -29
  231. data/test/unit/in_state_ordering_constraint_test.rb +0 -43
  232. data/test/unit/method_matcher_test.rb +0 -28
  233. data/test/unit/mock_test.rb +0 -350
  234. data/test/unit/mockery_test.rb +0 -157
  235. data/test/unit/module_methods_test.rb +0 -19
  236. data/test/unit/multiple_yields_test.rb +0 -18
  237. data/test/unit/no_yields_test.rb +0 -18
  238. data/test/unit/object_inspect_test.rb +0 -39
  239. data/test/unit/object_methods_test.rb +0 -46
  240. data/test/unit/parameter_matchers/all_of_test.rb +0 -26
  241. data/test/unit/parameter_matchers/any_of_test.rb +0 -26
  242. data/test/unit/parameter_matchers/anything_test.rb +0 -21
  243. data/test/unit/parameter_matchers/equals_test.rb +0 -25
  244. data/test/unit/parameter_matchers/equivalent_uri_test.rb +0 -51
  245. data/test/unit/parameter_matchers/has_entries_test.rb +0 -51
  246. data/test/unit/parameter_matchers/has_entry_test.rb +0 -129
  247. data/test/unit/parameter_matchers/has_key_test.rb +0 -55
  248. data/test/unit/parameter_matchers/has_value_test.rb +0 -57
  249. data/test/unit/parameter_matchers/includes_test.rb +0 -107
  250. data/test/unit/parameter_matchers/instance_of_test.rb +0 -25
  251. data/test/unit/parameter_matchers/is_a_test.rb +0 -25
  252. data/test/unit/parameter_matchers/kind_of_test.rb +0 -25
  253. data/test/unit/parameter_matchers/not_test.rb +0 -26
  254. data/test/unit/parameter_matchers/regexp_matches_test.rb +0 -46
  255. data/test/unit/parameter_matchers/responds_with_test.rb +0 -32
  256. data/test/unit/parameter_matchers/stub_matcher.rb +0 -27
  257. data/test/unit/parameter_matchers/yaml_equivalent_test.rb +0 -25
  258. data/test/unit/parameters_matcher_test.rb +0 -121
  259. data/test/unit/receivers_test.rb +0 -66
  260. data/test/unit/return_values_test.rb +0 -63
  261. data/test/unit/sequence_test.rb +0 -104
  262. data/test/unit/single_return_value_test.rb +0 -14
  263. data/test/unit/single_yield_test.rb +0 -18
  264. data/test/unit/state_machine_test.rb +0 -98
  265. data/test/unit/string_inspect_test.rb +0 -11
  266. data/test/unit/thrower_test.rb +0 -20
  267. data/test/unit/yield_parameters_test.rb +0 -93
  268. data/yard-templates/default/layout/html/google_analytics.erb +0 -11
  269. data/yard-templates/default/layout/html/setup.rb +0 -6
data/RELEASE.md CHANGED
@@ -1,5 +1,345 @@
1
1
  # Release Notes
2
2
 
3
+ ## 2.1.0
4
+
5
+ ### External changes
6
+
7
+ * Fix compatibility with Minitest (#614) - thanks to @kyrofa & @manewitz for reporting and to @zenspider for his input
8
+
9
+ ### Internal changes
10
+
11
+ * Update URLs for links to Ruby & MIT licenses (d6470af4)
12
+
13
+ ## 2.0.4
14
+
15
+ ### Internal changes
16
+
17
+ * Update `README.md` (e8c21e1b)
18
+
19
+ ## 2.0.3
20
+
21
+ ### External changes
22
+
23
+ * Fix `BacktraceFilter` to handle special characters (e242033f, #592) - thanks to @casperisfine
24
+
25
+ ### Internal changes
26
+
27
+ * Add Ruby v3.1 to the CircleCI build (3e460489)
28
+ * DRY up `regexp_matches` test (ae9fed4a)
29
+ * Fix regexp_matches tests in Ruby v3.2 (26b106a5, #590)
30
+ * Use Ruby 1.9 hash syntax (8bc0ad2f, #598, #537) - thanks to @herwinw
31
+ * Simplify storage of `MOCHA_OPTIONS` (b70507a1, #600) - thanks to @herwinw
32
+ * Pin JRuby to v9.3.9.0 in CircleCI builds (b8e6d064, #591)
33
+ * Rubocop: enable Style/FormatStringToken cop (089a688e, #603) - thanks to @herwinw
34
+ * Remove Ruby version check from `RespondsLikeTest` (21583129)
35
+ * Add Ruby v3.2 to CircleCI build (f7e17636, #601)
36
+ * Use Ruby v2.6 vs v2.2 to run lint CI job (af40b7db)
37
+ * Pin yard version to v0.9.28 to avoid `ArgumentError` (12f1eef7)
38
+ * Revert "Pin JRuby to v9.3.9.0 in CircleCI builds" (4f5bb2f0, #591)
39
+ * Remove invalid CircleCI token from badge URL (7078e76a)
40
+ * Revert "Pin yard version to v0.9.28 to avoid ArgumentError" (7c6c10c5, #609)
41
+ * Remove Google Analytics tracking code (2279c49d, #612)
42
+ * Update `MIT-LICENSE.md` (48162b4e)
43
+ * Update `COPYING.md` (f3152376)
44
+
45
+ ## 2.0.2
46
+
47
+ ### External changes
48
+
49
+ * Fix regression in `Mock#responds_like` behaviour - thanks to @adrianna-chang-shopify for reporting (#580,#583,ba4d619e)
50
+
51
+ ## 2.0.1
52
+
53
+ ### External changes
54
+
55
+ * Fix `LoadError` when using v2.0.0 with Ruby < v2.7 by moving declaration of runtime dependency on `ruby2_keywords` gem from `Gemfile` to `mocha.gemspec` - thanks to @mishina2228 for reporting (#581, #582, cdeb0356)
56
+
57
+ ## 2.0.0
58
+
59
+ ### External changes
60
+
61
+ * Remove support for Ruby v1.9 - thanks to @wasabigeek (#552)
62
+ * Support strict keyword argument matching - see docs for `Expectation#with` & `Configuration#strict_keyword_argument_matching=` - thanks to @wasabigeek (#446,#535,#544,#562)
63
+ * Deprecate `Hash` args that don't strictly match (#563,981c31be)
64
+ * Drop support for older versions of test-unit - gem versions of test-unit earlier than v2.5.1 and versions of test-unit
65
+ from the Ruby v1.8 standard library are no longer supported (#540,969f4845)
66
+ * Drop support for older versions of minitest - versions of minitest earlier than v3.3.0 are no longer supported (#541,ca69dc9e)
67
+ * Remove deprecated `mocha/setup.rb` mechanism (642a0ff4)
68
+ * Add missing docs for `API#stub` parameter (257b4cb4)
69
+ * Remove optional reinstatement of v1.9 behaviour (#436,#438,#569,1473ee25)
70
+ * Remove deprecated methods in `Configuration` (#421,e7ff7528)
71
+ * Fail fast when mock receives invocations in another test (#440,#442,cb054d59)
72
+ * Improve docs re using matchers in `Expectation#with` (da7237cd)
73
+ * Expand `Expectation#with` docs re keyword arguments (fed6808d)
74
+ * Improve docs for `strict_keyword_argument_matching` (8d8f881d)
75
+ * Remove deprecated Rails plugin `init.rb` file (1c617175)
76
+ * Improve strict keyword argument matching deprecation warning by including the source location of the stub definition (77c0d4cc)
77
+ * Add README section re semantic versioning (00758246)
78
+
79
+ ### Internal changes
80
+
81
+ * Separate linting from tests in terms of Rake tasks & CircleCI jobs - thanks to @wasabigeek (#556)
82
+ * Remove tests specific to Ruby v1.8 behaviour (46fca7ac, 3b369e99)
83
+ * Multi-line rubocop disable in `Mock#method_missing` (af2194c4)
84
+ * Remove unused arg for `HashMethods#mocha_inspect` (4f59e27f)
85
+ * Improve test runner assertions - failure vs error (eec7200a)
86
+ * Improve test coverage of `PositionalOrKeywordHash` (c294fe70)
87
+ * More consistent Test::Unit & Minitest integration (27dd3817)
88
+ * Remove redundant `require` statements (d82218a8,fa17b114)
89
+ * Add missing `require` statement (73493761)
90
+ * Disable Style/Semicolon cop globally (8cd0b705)
91
+
92
+ ## 1.16.1
93
+
94
+ ### External changes
95
+
96
+ * Fix regression in `Mock#responds_like` behaviour - thanks to @adrianna-chang-shopify for reporting (#580,#583,77af2af1)
97
+
98
+ ## 1.16.0
99
+
100
+ ### External changes
101
+
102
+ * Default `Configuration#reinstate_undocumented_behaviour_from_v1_9=` to `false` (6fcaf947)
103
+ * Deprecate `Configuration#reinstate_undocumented_behaviour_from_v1_9=` (a797c5fd)
104
+
105
+ ### Internal changes
106
+
107
+ * Remove redundant deprecation disabling in MockTest (dc8ca969)
108
+
109
+ ## 1.15.1
110
+
111
+ ### External changes
112
+
113
+ * Fix regression in `Mock#responds_like` behaviour - thanks to @adrianna-chang-shopify for reporting (#580,#583,c586a08c)
114
+
115
+ ## 1.15.0
116
+
117
+ ### External changes
118
+
119
+ * Fix examples using mock constructor with block (1cc17667)
120
+ * Add another example for `API#sequence` (b7a7d233, #59)
121
+ * Remove support for Ruby v1.8 (ddb5d672)
122
+ * Deprecate support for Ruby versions earlier than v2.0 - thanks to @wasabigeek (#553, #555)
123
+
124
+ ### Internal changes
125
+
126
+ * Update instructions for obtaining Rubygems API key (ed9c040a)
127
+ * Consistent definitions for `respond_to?` methods (#533)
128
+ * Run test tasks before release tasks (92a1bc6e, #447)
129
+ * Fix test:performance Rake task (#538, #539)
130
+ * Tidying following removal of support for Ruby v1.8 - thanks to @nitishr (#542)
131
+ * Remove `ParametersMatcher` from `Invocation#call_description` - thanks to @wasabigeek (#543)
132
+ * Remove unnecessary splatting in Invocation - thanks to @wasabigeek (#549)
133
+ * Extract `handle_method_call` from `method_missing` - thanks to @wasabigeek (#550)
134
+
135
+ ## 1.14.0
136
+
137
+ ### External changes
138
+
139
+ * Mock#expects,#stubs should return last expectation - thanks to @vlad-pisanov for #524 (b6b637db)
140
+
141
+ ### Internal changes
142
+
143
+ * Avoid breaking change in psych v4 in ruby v3.1 (08b9f4ca)
144
+ * Remove broken Dependabot badge from README (d446657a)
145
+ * Add Ruby 3.0 to the CI matrix - thanks to @mishina2228 for #526 (65bc626e)
146
+ * Move development dependencies from gemspec to Gemfile - thanks to @mishina2228 for #527 (dd127f7b)
147
+
148
+ ## 1.13.0
149
+
150
+ ### External changes
151
+
152
+ * Add `ParameterMatchers#has_keys` - thanks to @cstyles for #512 (18d8104)
153
+ * Fix misleading exception message in `ParameterMatchers#has_entry` - thanks to @cstyles for #513 (9c4ef13)
154
+ * Only add dependency on rubocop if we're actually going to use it (f2f879f)
155
+ * Fix rake dependency constraints for older Ruby versions (7ce5f29)
156
+
157
+ ### Internal changes
158
+
159
+ * Check documentation can be generated as part of CircleCI build (b30d9a9)
160
+ * Add --fail-on-warning option to yard rake task (53a6ee3)
161
+ * Add a weekly scheduled build to the CircleCI build (fd2a4c6)
162
+ * Add Ruby v1.8 to the CircleCI build matrix (818ca03)
163
+ * Add API token to fix CircleCI badge in README (607c5aa)
164
+ * Provide wrapped option for #mocha_inspect on hashes & arrays (d8f44bc)
165
+ * Use CircleCI instead of TravisCI for automated builds (c98c6ec)
166
+ * Switch to newer default Travis CI build env (c78f75c)
167
+ * Use latest Ruby versions in Travis CI builds (9e0043a)
168
+ * Use latest JRuby v9.2.18 in Travis CI builds (8c99a1b)
169
+ * Use consistent JRuby versions in Travis CI builds (0f849aa)
170
+ * Use more recent version of JRuby in Travis CI build matrix (58653db)
171
+
172
+ ## 1.12.0
173
+
174
+ ### External changes
175
+
176
+ * Various improvements to README inspired by #207 and #390 - thanks to @nitishr for his work on #390 (fed0eee6)
177
+ * Improve documentation related to `StateMachine` classes - thanks to @nitishr (#425 & #427)
178
+ * Fix regression in cardinality introduced in v1.10.0 (59454a8) and reported in #473 - thanks to @srvance for reporting and @nitishr for fixing (#474)
179
+ * Fix documentation for `Mocha::Expectation#when` - thanks to @olleolleolle (b4f59daa & #477)
180
+ * Remove `Mocha::Mock#respond_to?` from documentation - thanks to @nitishr (#480)
181
+ * Improvements to documentation for `Expectation#yields` & `#multiple_yields` - thanks to @andyw8 for reporting in #495 (1b6571c)
182
+ * Remove documentation & tests from gem to reduce its size by over 50% - thanks to @gabetax (#500)
183
+ * Update documentation to point to travis-ci.com instead of travis-ci.org
184
+
185
+ ### Internal changes
186
+
187
+ * Refactor `StateMachine`-related classes - thanks to @nitishr (#425 & #427)
188
+ * Remove redundant test - thanks to @nitishr (8e4f1a7c)
189
+ * Add Ruby 2.7 to Travis CI matrix - thanks to @bastelfreak (fc5ea2f2)
190
+ * Simplify `Mockery` - thanks to @nitishr (#449)
191
+ * Update Travis CI badge to point to main vs master branch (bd8028f8)
192
+ * Generate docs using newer version of yard (v0.9.25) (c619afac)
193
+ * Manually upgrade jquery in docs from v1.7.1 -> v1.9.0 to fix CVE-2017-16011 (211098a5, dd5eeedb & 1b76e4d5; also see #492)
194
+ * Remove reference to non-existent jquery source map to fix error in Chrome developer tools (20156555)
195
+ * Temporarily ignore Ruby v1.8.7 build failures (e5b9feef)
196
+
197
+ ## 1.11.2
198
+
199
+ ### External changes
200
+
201
+ * Fix regression introduced in v1.10.0 that meant `Object#inspect` was called unnecessarily (368abd98)
202
+ * Warn when mock object receives invocations in another test - thanks to @nitishr (#442)
203
+ * Avoid rubocop comments appearing in YARD-generated docs (d8019eed)
204
+
205
+ ### Internal changes
206
+
207
+ * Replace `StubbedMethod#original_method` & `#original_visibility` attribute reader methods with instance variables - thanks to @nitishr (d917f332)
208
+ * Set up `MochaExampleTest` & `StubbaExampleTest` as acceptance tests - thanks to @nitishr (4881cc58)
209
+ * Delete unused `PrettyParameters` class - thanks to @nitishr (314ea922)
210
+
211
+ ## 1.11.1
212
+
213
+ ### External changes
214
+
215
+ * The `reinstate_undocumented_behaviour_from_v1_9` configuration option is now enabled by default to give people a chance to see and fix the relevant deprecation warnings before the behaviour is removed in a future release (b91b1c9e)
216
+
217
+ ## 1.11.0
218
+
219
+ ### External changes
220
+
221
+ * Add `Expectation#with_block_given` & `Expectation#with_no_block_given` (#441).
222
+ * Allows non-deprecated solution for #382. Thanks to @yemartin for reporting and to @techbelly & @nitishr for feedback.
223
+ * Fix issue with non-Array arguments passed to `Expectation#multiple_yields` (#444).
224
+ * The undocumented behaviour is now properly supported and documented.
225
+
226
+ ### Internal changes
227
+
228
+ * Move static YARD options from Rake task to `.yardopts` file - thanks to @nitishr (#429)
229
+ * Simplify implementation of yielding functionality - thanks to @nitishr (#439)
230
+ * Add missing require statement to `acceptance_test_helper.rb` (1070fc02)
231
+ * Add some baseline acceptance tests for yielding behaviour (c2cac911)
232
+ * Display a sponsor button on GitHub repo page (9fc5911b)
233
+ * Use new Deprecation.warning behaviour in `Invocation#call` (932d1166)
234
+
235
+ ## 1.10.2
236
+
237
+ * Optionally reinstate undocumented behaviour from v1.9. This introduces a new configuration option (`reinstate_undocumented_behaviour_from_v1_9`) to reinstate a couple of bits of undocumented behaviour from v1.9 which were changed in v1.10 without any prior deprecation warning (#438):
238
+ * The behaviour of `API#mock`, `API#stub` and `API#stub_everything` when called with a symbol as the first argument.
239
+ * The behaviour of `Expectation#yields` and `Expectation#multiple_yields` when the stubbed method is called without a block.
240
+
241
+ ## 1.10.1
242
+
243
+ * Ensure ObjectMethods & ClassMethods included when API extended (43778756)
244
+ * Fix regression in `any_instance` stubbing of methods on object which has an implementation of `#respond_to?` that depends on the object's internal state - thanks to @rafaelfranca for reporting & @nitishr for fixing (#432, #434, 469d4b17)
245
+
246
+ ## 1.10.0
247
+
248
+ * Improve deprecation warning when requiring 'mocha/setup' (388f44d7)
249
+ * Add documentation for Cucumber integration (13ab797b)
250
+ * Add documentation about an undocumented feature of `API#mock`, `API#stub` & `API#stub_everything` being changed (7ed2e4e7, d30c1717)
251
+
252
+ ## 1.10.0.beta.1
253
+
254
+ * Hide `ClassMethods#method_visibility` & `#method_exists?` methods to avoid clash with Rails (#428)
255
+
256
+ ## 1.10.0.alpha
257
+
258
+ ### External changes
259
+
260
+ * Remove dependency on metaclass gem (#49, #365)
261
+ * Accept symbol (as well as a string) as mock/stub name - thanks to @nitishr (#347, #353, #377)
262
+ * More realistic examples in documentation for `Expectation#yields` and `#multiple_yields` - thanks to @nitishr (#352, #383)
263
+ * Improve documentation for `Mock#responds_like` & `#responds_like_instance_of` - thanks to @nitishr (#337, #384)
264
+ * Make `Expectation#yields` & `Expectation#multiple_yields` fail when the caller of the stubbed method does not provide a block. This is a change to an undocumented aspect of the public API's behaviour. If this causes your tests to fail, then fix it by removing the unnecessary call to `Expectation#yields` or `Expectation#multiple_yields` - thanks to @nitishr (#382)
265
+ * Document `MOCHA_OPTIONS` in README - thanks to @nitishr (#311, #386)
266
+ * Add documentation to explain how Mocha is intended to be used - thanks to @nitishr (#330, #385)
267
+ * Deprecation warning if integration using 'mocha/test_unit' or 'mocha/minitest' fails - thanks to @nitishr (#229, #389, c6032d0b)
268
+ * Require at least one specified sequence for `Expectation#in_sequence` - thanks to @nitishr (#79, #396, 9020248a)
269
+ * Make signatures of `Mock#unstub` & `ObjectMethods#unstub` consistent - thanks to @nitishr (#397, f04d437)
270
+ * Deprecate requiring 'mocha/setup' (36adf880)
271
+ * Optionally display matching invocations alongside expectations - thanks to @nitishr (#178, #394, 00f0540, #410)
272
+ * Put deprecations into effect (#400, #418):
273
+ * Remove deprecated 'mocha_standalone.rb' & 'mocha/standalone.rb'
274
+ * Fail fast if no test library loaded
275
+ * Removed optional block for `Mocha::API#mock`, `#stub` & `#stub_everything`
276
+ * Remove deprecated `ParameterMatchers#has_equivalent_query_string` method
277
+ * Remove deprecated 'mocha/mini_test.rb'
278
+ * Fix typo in docs for `Mocha::Configuration.prevent` (266ce71c)
279
+ * New-style configuration (see documentation for `Mocha::Configuration`) (#407, #421)
280
+ * Deprecate support for Ruby versions earlier than v1.9 (#325, c5f8496d)
281
+ * Deprecate support for versions of test-unit & minitest which need monkey-patching (a34e1a88)
282
+ * Deprecate old-style Rails plugin (#403, 2df77134)
283
+ * Documentation fixes & improvements which also fix YARD warnings (472d5416, a2c0d64a)
284
+
285
+ ### Internal changes
286
+
287
+ * Pin minitest to v5.11.3 for Ruby v1.8.7 to fix build; minitest no longer supports Ruby v1.8.7 (4a0a580)
288
+ * Upgrade JRuby to v9.2.8.0 in Travis CI builds (aa29b3f)
289
+ * Only run rubocop for MRI Ruby versions & non-integration test builds (8f1c6af)
290
+ * Reduce duplication in any instance method class - thanks to @nitishr (#378)
291
+ * Simplify `AnyInstanceMethod`, `ClassMethod`, `InstanceMethod`, `ModuleMethod` class hierarchy - thanks to @nitishr (#381)
292
+ * Simplify `ClassMethods#method_exists?` & `ObjectMethods#method_exists?` making them consistent - thanks to @nitishr (#270, #362, #370)
293
+ * Don't override definition of `singleton_class` in `ClassMethods` - thanks to @nitishr (#391, #392)
294
+ * Do not include 'method_definer' methods into all objects (#268, #402)
295
+ * Distinguish different `ObjectMethods` modules (#268, #404)
296
+ * Pass invocation to expectation list methods - thanks to @nitishr (#408, #409, #411)
297
+ * Consistently use `assert_raises` - thanks to @nitishr (#405, #412, a66b7bed)
298
+ * Update Ruby & JRuby versions in Travis CI config (18cb1a93, eb061c53)
299
+ * Rubocop improvements (aa16ea67...6f4db70b, 2a1240e6...e95716ae)
300
+ * Fix inconsistency in CardinalityTest (aa10e0a8)
301
+ * Fix test failures on Mac OSX Catalina - thanks to @nitishr (#413, #417, #419, 8a0f2535)
302
+ * Remove default argument in `Expectation#invoke` - thanks to @nitishr (#414, #420)
303
+
304
+ ## 1.9.0
305
+
306
+ * Add TruffleRuby to Travis CI build matrix - thanks to @deepj (#354)
307
+ * Explicitly set Travis CI OS to Ubuntu Trusty 14.04 (ded1fa45)
308
+ * Expand explanation of thread-safety concerns - thanks to @techbelly (#357)
309
+ * Refactor class method and any instance method - thanks to @chrisroos (#358)
310
+ * Rely on default bundler version in Travis CI builds (3352e9c5)
311
+ * Fix local build-matrix script (11abe231)
312
+ * No need to install latest bundler in build-matrix script (8247a894)
313
+
314
+ ## 1.8.0
315
+
316
+ * Constrain rubocop version to avoid breaking Travis CI builds (05e507f5)
317
+ * Avoid calling Kernel#format from ObjectMethods#mocha_inspect - thanks to @hoffmanilya (#345)
318
+ * Fix build matrix script (#346)
319
+ * Avoid deprecation warning in gemspec (4976e0bc)
320
+ * Removed link to documentation translation (ef428ea2)
321
+ * Don't use the new bundler v2 in builds (683ded9b)
322
+ * Moved documentation from https://gofreerange.com/mocha/docs to https://mocha.jamesmead.org/ [683ded...a17fde](https://github.com/freerange/mocha/compare/683ded...a17fde)
323
+
324
+ ## 1.7.0
325
+
326
+ * Update Ruby & JRuby versions in Travis CI config (9bf55631 & 3883af7e)
327
+ * Simplify gemspec (63744f86)
328
+ * Add rubocop and fix most cop violations (#341)
329
+ * Use Kernel#warn for deprecations - thanks to @etiennebarrie (#333, 196970a)
330
+
331
+ ## 1.6.0
332
+
333
+ * Fix subtle bug in setting correct visibility of stubbed module methods on `Kernel` or `Object` - thanks to @chrisroos (#295)
334
+ * Avoid mocks for partial mocking leaking into subsequent tests - thanks to @skliew for reporting (#331)
335
+ * Remove OpenCollective badge, backers & sponsors (a283a079)
336
+ * Change gem version badge to SVG format and add SemVer stability badge - thanks to @greysteil (#335)
337
+ * Improve documentation for Configuration (#236)
338
+
339
+ ## 1.5.0
340
+
341
+ * Prevent use of Mocha outside the context of a test/example - thanks to @andyw8 & @lzap (#327)
342
+
3
343
  ## 1.4.0
4
344
 
5
345
  * Fix deprecation warning for `assert_nil` in `ClassMethodTest` (#308 & #309)
data/Rakefile CHANGED
@@ -1,17 +1,22 @@
1
- require "bundler"
2
- Bundler::GemHelper.install_tasks
3
- require "bundler/setup"
4
-
5
- MOCHA_DOCS_HOST = ENV['MOCHA_DOCS_HOST'] || 'gofreerange.com'
1
+ require 'bundler'
2
+ namespace 'rubygems' do
3
+ Bundler::GemHelper.install_tasks
4
+ end
5
+ require 'bundler/setup'
6
6
 
7
7
  require 'rake/testtask'
8
+ begin
9
+ # Only available with default Gemfile and in Ruby >= v2.2
10
+ require 'rubocop/rake_task'
11
+ rescue LoadError # rubocop:disable Lint/HandleExceptions
12
+ end
8
13
 
9
- desc "Run all tests"
10
- task 'default' => ['test', 'test:performance']
14
+ desc 'Run all linters and tests'
15
+ task 'default' => ['lint', 'test', 'test:performance']
11
16
 
12
- desc "Run tests"
17
+ desc 'Run tests'
13
18
  task 'test' do
14
- if test_library = ENV['MOCHA_RUN_INTEGRATION_TESTS']
19
+ if (test_library = ENV['MOCHA_RUN_INTEGRATION_TESTS'])
15
20
  Rake::Task["test:integration:#{test_library}"].invoke
16
21
  else
17
22
  Rake::Task['test:units'].invoke
@@ -19,35 +24,25 @@ task 'test' do
19
24
  end
20
25
  end
21
26
 
22
- namespace 'test' do
23
-
24
- unit_tests = FileList['test/unit/**/*_test.rb']
25
- all_acceptance_tests = FileList['test/acceptance/*_test.rb']
26
- 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
- ruby186_compatible_acceptance_tests = all_acceptance_tests - ruby186_incompatible_acceptance_tests
28
-
29
- desc "Run unit tests"
27
+ namespace 'test' do # rubocop:disable Metrics/BlockLength
28
+ desc 'Run unit tests'
30
29
  Rake::TestTask.new('units') do |t|
31
30
  t.libs << 'test'
32
- t.test_files = unit_tests
31
+ t.test_files = FileList['test/unit/**/*_test.rb']
33
32
  t.verbose = true
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 = FileList['test/acceptance/*_test.rb']
45
40
  t.verbose = true
46
41
  t.warning = true
47
42
  end
48
43
 
49
44
  namespace 'integration' do
50
- desc "Run MiniTest integration tests (intended to be run in its own process)"
45
+ desc 'Run MiniTest integration tests (intended to be run in its own process)'
51
46
  Rake::TestTask.new('minitest') do |t|
52
47
  t.libs << 'test'
53
48
  t.test_files = FileList['test/integration/mini_test_test.rb']
@@ -55,7 +50,7 @@ namespace 'test' do
55
50
  t.warning = true
56
51
  end
57
52
 
58
- desc "Run Test::Unit integration tests (intended to be run in its own process)"
53
+ desc 'Run Test::Unit integration tests (intended to be run in its own process)'
59
54
  Rake::TestTask.new('test-unit') do |t|
60
55
  t.libs << 'test'
61
56
  t.test_files = FileList['test/integration/test_unit_test.rb']
@@ -74,7 +69,7 @@ namespace 'test' do
74
69
  # t.rcov_opts << '--xref'
75
70
  # end
76
71
 
77
- desc "Run performance tests"
72
+ desc 'Run performance tests'
78
73
  task 'performance' do
79
74
  require File.join(File.dirname(__FILE__), 'test', 'acceptance', 'stubba_example_test')
80
75
  require File.join(File.dirname(__FILE__), 'test', 'acceptance', 'mocha_example_test')
@@ -84,9 +79,18 @@ namespace 'test' do
84
79
  puts "#{test_case}: #{benchmark_test_case(test_case, iterations)} seconds."
85
80
  end
86
81
  end
82
+ end
87
83
 
84
+ task 'lint' do
85
+ if defined?(RuboCop::RakeTask)
86
+ RuboCop::RakeTask.new
87
+ Rake::Task['rubocop'].invoke
88
+ else
89
+ puts 'RuboCop not available - skipping linting'
90
+ end
88
91
  end
89
92
 
93
+ # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
90
94
  def benchmark_test_case(klass, iterations)
91
95
  require 'benchmark'
92
96
  require 'mocha/detection/mini_test'
@@ -94,56 +98,53 @@ def benchmark_test_case(klass, iterations)
94
98
  if defined?(MiniTest)
95
99
  minitest_version = Gem::Version.new(Mocha::Detection::MiniTest.version)
96
100
  if Gem::Requirement.new('>= 5.0.0').satisfied_by?(minitest_version)
97
- result = Benchmark.realtime { iterations.times { |i| klass.run(MiniTest::CompositeReporter.new) } }
101
+ Minitest.seed = 1
102
+ result = Benchmark.realtime { iterations.times { |_i| klass.run(MiniTest::CompositeReporter.new) } }
98
103
  MiniTest::Runnable.runnables.delete(klass)
99
104
  result
100
105
  else
101
106
  MiniTest::Unit.output = StringIO.new
102
- Benchmark.realtime { iterations.times { |i| MiniTest::Unit.new.run([klass]) } }
107
+ Benchmark.realtime { iterations.times { |_i| MiniTest::Unit.new.run([klass]) } }
103
108
  end
104
109
  else
105
110
  load 'test/unit/ui/console/testrunner.rb' unless defined?(Test::Unit::UI::Console::TestRunner)
106
- unless $silent_option
111
+ unless @silent_option
107
112
  begin
108
113
  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 }
114
+ @silent_option = { output_level: Test::Unit::UI::Console::OutputLevel::SILENT }
110
115
  rescue LoadError
111
- $silent_option = Test::Unit::UI::SILENT
116
+ @silent_option = Test::Unit::UI::SILENT
112
117
  end
113
118
  end
114
- Benchmark.realtime { iterations.times { Test::Unit::UI::Console::TestRunner.run(klass, $silent_option) } }
119
+ Benchmark.realtime { iterations.times { Test::Unit::UI::Console::TestRunner.run(klass, @silent_option) } }
115
120
  end
116
121
  end
122
+ # rubocop:enable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
117
123
 
118
- if ENV["MOCHA_GENERATE_DOCS"]
124
+ if ENV['MOCHA_GENERATE_DOCS']
119
125
  require 'yard'
120
126
 
121
127
  desc 'Remove generated documentation'
122
128
  task 'clobber_yardoc' do
123
- `rm -rf ./doc`
124
- end
125
-
126
- task 'docs_environment' do
127
- unless ENV['GOOGLE_ANALYTICS_WEB_PROPERTY_ID']
128
- puts "\nWarning: GOOGLE_ANALYTICS_WEB_PROPERTY_ID was not defined\n\n"
129
- end
129
+ `rm -rf ./docs`
130
130
  end
131
131
 
132
132
  desc 'Generate documentation'
133
- YARD::Rake::YardocTask.new('yardoc' => 'docs_environment') do |task|
134
- task.options = ["--title", "Mocha #{Mocha::VERSION}"]
133
+ YARD::Rake::YardocTask.new('yardoc') do |task|
134
+ task.options = ['--title', "Mocha #{Mocha::VERSION}", '--fail-on-warning']
135
135
  end
136
136
 
137
- desc "Generate documentation"
138
- task 'generate_docs' => ['clobber_yardoc', 'yardoc']
137
+ task 'checkout_docs_cname' do
138
+ `git checkout docs/CNAME`
139
+ end
139
140
 
140
- desc "Publish docs to #{MOCHA_DOCS_HOST}/docs/mocha"
141
- 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}}
141
+ task 'checkout_docs_js' do
142
+ `git checkout docs/js/app.js`
143
+ `git checkout docs/js/jquery.js`
144
144
  end
145
- end
146
145
 
147
- task 'release' => 'default' do
148
- Rake::Task['publish_docs'].invoke
146
+ desc 'Generate documentation'
147
+ task 'generate_docs' => %w[clobber_yardoc yardoc checkout_docs_cname checkout_docs_js]
149
148
  end
149
+
150
+ task 'release' => ['default', 'rubygems:release']
@@ -3,5 +3,6 @@ source 'https://rubygems.org'
3
3
  gemspec :path=>"../"
4
4
 
5
5
  group :development do
6
+ gem "rake"
6
7
  gem "minitest"
7
8
  end
@@ -3,9 +3,6 @@ source 'https://rubygems.org'
3
3
  gemspec :path=>"../"
4
4
 
5
5
  group :development do
6
- if RUBY_VERSION < '1.9'
7
- gem "test-unit", "~> 2"
8
- else
9
- gem "test-unit"
10
- end
6
+ gem "rake"
7
+ gem "test-unit"
11
8
  end
@@ -1,72 +1,19 @@
1
- require 'mocha/ruby_version'
2
- require 'mocha/class_method'
1
+ require 'mocha/stubbed_method'
3
2
 
4
3
  module Mocha
4
+ class AnyInstanceMethod < StubbedMethod
5
+ private
5
6
 
6
- class AnyInstanceMethod < ClassMethod
7
-
8
- def mock
9
- stubbee.any_instance.mocha
10
- end
11
-
12
- def reset_mocha
13
- stubbee.any_instance.reset_mocha
14
- end
15
-
16
- 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
27
- end
28
- rescue NameError
29
- # deal with nasties like ActiveRecord::Associations::AssociationProxy
30
- end
31
- end
32
- end
33
-
34
- def define_new_method
35
- definition_target.class_eval(<<-CODE, __FILE__, __LINE__ + 1)
36
- def #{method}(*args, &block)
37
- self.class.any_instance.mocha.method_missing(:#{method}, *args, &block)
38
- end
39
- CODE
40
- if @original_visibility
41
- Module.instance_method(@original_visibility).bind(definition_target).call(method)
42
- end
43
- end
44
-
45
- def remove_new_method
46
- definition_target.send(:remove_method, method)
47
- end
48
-
49
- 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
7
+ def mock_owner
8
+ stubbee.any_instance
56
9
  end
57
10
 
58
- def method_visibility(method)
59
- (stubbee.public_instance_methods(true).include?(method) && :public) ||
60
- (stubbee.protected_instance_methods(true).include?(method) && :protected) ||
61
- (stubbee.private_instance_methods(true).include?(method) && :private)
11
+ def stubbee_method(method_name)
12
+ stubbee.instance_method(method_name)
62
13
  end
63
14
 
64
- private
65
-
66
- def definition_target
67
- @definition_target ||= stubbee
15
+ def original_method_owner
16
+ stubbee
68
17
  end
69
-
70
18
  end
71
-
72
19
  end