mocha 1.2.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (266) hide show
  1. checksums.yaml +5 -5
  2. data/.github/FUNDING.yml +1 -0
  3. data/.rubocop.yml +65 -0
  4. data/.rubocop_todo.yml +27 -0
  5. data/.yardopts +1 -0
  6. data/CONTRIBUTING.md +4 -9
  7. data/Gemfile +29 -0
  8. data/README.md +110 -106
  9. data/RELEASE.md +306 -1
  10. data/Rakefile +52 -45
  11. data/gemfiles/Gemfile.minitest.latest +1 -0
  12. data/gemfiles/Gemfile.test-unit.latest +2 -5
  13. data/lib/mocha/any_instance_method.rb +9 -62
  14. data/lib/mocha/api.rb +84 -68
  15. data/lib/mocha/argument_iterator.rb +4 -8
  16. data/lib/mocha/backtrace_filter.rb +1 -5
  17. data/lib/mocha/block_matcher.rb +31 -0
  18. data/lib/mocha/cardinality.rb +60 -49
  19. data/lib/mocha/central.rb +21 -12
  20. data/lib/mocha/change_state_side_effect.rb +0 -4
  21. data/lib/mocha/class_methods.rb +19 -21
  22. data/lib/mocha/configuration.rb +312 -47
  23. data/lib/mocha/debug.rb +3 -2
  24. data/lib/mocha/deprecation.rb +8 -11
  25. data/lib/mocha/detection/mini_test.rb +0 -2
  26. data/lib/mocha/detection/test_unit.rb +3 -5
  27. data/lib/mocha/error_with_filtered_backtrace.rb +13 -0
  28. data/lib/mocha/exception_raiser.rb +4 -6
  29. data/lib/mocha/expectation.rb +186 -95
  30. data/lib/mocha/expectation_error.rb +1 -1
  31. data/lib/mocha/expectation_error_factory.rb +0 -1
  32. data/lib/mocha/expectation_list.rb +7 -11
  33. data/lib/mocha/hooks.rb +1 -3
  34. data/lib/mocha/in_state_ordering_constraint.rb +0 -4
  35. data/lib/mocha/inspect.rb +30 -38
  36. data/lib/mocha/instance_method.rb +11 -8
  37. data/lib/mocha/integration/mini_test/adapter.rb +2 -4
  38. data/lib/mocha/integration/mini_test/exception_translation.rb +1 -1
  39. data/lib/mocha/integration/mini_test.rb +10 -31
  40. data/lib/mocha/integration/monkey_patcher.rb +5 -7
  41. data/lib/mocha/integration/test_unit/adapter.rb +5 -6
  42. data/lib/mocha/integration/test_unit.rb +10 -26
  43. data/lib/mocha/invocation.rb +73 -0
  44. data/lib/mocha/is_a.rb +0 -2
  45. data/lib/mocha/logger.rb +0 -4
  46. data/lib/mocha/macos_version.rb +5 -0
  47. data/lib/mocha/method_matcher.rb +1 -5
  48. data/lib/mocha/minitest.rb +6 -0
  49. data/lib/mocha/mock.rb +99 -51
  50. data/lib/mocha/mockery.rb +70 -99
  51. data/lib/mocha/names.rb +2 -12
  52. data/lib/mocha/not_initialized_error.rb +7 -0
  53. data/lib/mocha/object_methods.rb +25 -31
  54. data/lib/mocha/parameter_matchers/all_of.rb +2 -8
  55. data/lib/mocha/parameter_matchers/any_of.rb +2 -8
  56. data/lib/mocha/parameter_matchers/any_parameters.rb +3 -9
  57. data/lib/mocha/parameter_matchers/anything.rb +2 -8
  58. data/lib/mocha/parameter_matchers/base.rb +7 -13
  59. data/lib/mocha/parameter_matchers/equals.rb +0 -6
  60. data/lib/mocha/parameter_matchers/{query_string.rb → equivalent_uri.rb} +14 -15
  61. data/lib/mocha/parameter_matchers/has_entries.rb +2 -7
  62. data/lib/mocha/parameter_matchers/has_entry.rb +26 -21
  63. data/lib/mocha/parameter_matchers/has_key.rb +2 -7
  64. data/lib/mocha/parameter_matchers/has_keys.rb +53 -0
  65. data/lib/mocha/parameter_matchers/has_value.rb +2 -7
  66. data/lib/mocha/parameter_matchers/includes.rb +6 -7
  67. data/lib/mocha/parameter_matchers/instance_methods.rb +27 -0
  68. data/lib/mocha/parameter_matchers/instance_of.rb +0 -6
  69. data/lib/mocha/parameter_matchers/is_a.rb +2 -7
  70. data/lib/mocha/parameter_matchers/kind_of.rb +2 -6
  71. data/lib/mocha/parameter_matchers/not.rb +2 -7
  72. data/lib/mocha/parameter_matchers/optionally.rb +4 -10
  73. data/lib/mocha/parameter_matchers/positional_or_keyword_hash.rb +64 -0
  74. data/lib/mocha/parameter_matchers/regexp_matches.rb +0 -6
  75. data/lib/mocha/parameter_matchers/responds_with.rb +3 -8
  76. data/lib/mocha/parameter_matchers/yaml_equivalent.rb +2 -6
  77. data/lib/mocha/parameter_matchers.rb +3 -4
  78. data/lib/mocha/parameters_matcher.rb +8 -11
  79. data/lib/mocha/raised_exception.rb +11 -0
  80. data/lib/mocha/receivers.rb +10 -14
  81. data/lib/mocha/return_values.rb +4 -8
  82. data/lib/mocha/ruby_version.rb +1 -2
  83. data/lib/mocha/sequence.rb +4 -9
  84. data/lib/mocha/single_return_value.rb +2 -5
  85. data/lib/mocha/state_machine.rb +33 -46
  86. data/lib/mocha/stubbed_method.rb +88 -0
  87. data/lib/mocha/stubbing_error.rb +2 -13
  88. data/lib/mocha/test_unit.rb +5 -2
  89. data/lib/mocha/thrower.rb +4 -6
  90. data/lib/mocha/thrown_object.rb +12 -0
  91. data/lib/mocha/version.rb +1 -1
  92. data/lib/mocha/yield_parameters.rb +7 -17
  93. data/mocha.gemspec +14 -65
  94. data/yard-templates/default/layout/html/google_analytics.erb +6 -9
  95. data/yard-templates/default/layout/html/setup.rb +2 -3
  96. metadata +26 -266
  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 -3
  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 -51
  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 -337
  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 -163
  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 -66
  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 -64
  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 -15
  205. data/test/execution_point.rb +0 -36
  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 -134
  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 -225
  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 -342
  234. data/test/unit/mockery_test.rb +0 -151
  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/has_entries_test.rb +0 -51
  245. data/test/unit/parameter_matchers/has_entry_test.rb +0 -129
  246. data/test/unit/parameter_matchers/has_key_test.rb +0 -55
  247. data/test/unit/parameter_matchers/has_value_test.rb +0 -57
  248. data/test/unit/parameter_matchers/includes_test.rb +0 -102
  249. data/test/unit/parameter_matchers/instance_of_test.rb +0 -25
  250. data/test/unit/parameter_matchers/is_a_test.rb +0 -25
  251. data/test/unit/parameter_matchers/kind_of_test.rb +0 -25
  252. data/test/unit/parameter_matchers/not_test.rb +0 -26
  253. data/test/unit/parameter_matchers/regexp_matches_test.rb +0 -46
  254. data/test/unit/parameter_matchers/responds_with_test.rb +0 -32
  255. data/test/unit/parameter_matchers/stub_matcher.rb +0 -27
  256. data/test/unit/parameter_matchers/yaml_equivalent_test.rb +0 -25
  257. data/test/unit/parameters_matcher_test.rb +0 -121
  258. data/test/unit/receivers_test.rb +0 -66
  259. data/test/unit/return_values_test.rb +0 -63
  260. data/test/unit/sequence_test.rb +0 -104
  261. data/test/unit/single_return_value_test.rb +0 -14
  262. data/test/unit/single_yield_test.rb +0 -18
  263. data/test/unit/state_machine_test.rb +0 -98
  264. data/test/unit/string_inspect_test.rb +0 -11
  265. data/test/unit/thrower_test.rb +0 -20
  266. data/test/unit/yield_parameters_test.rb +0 -93
data/RELEASE.md CHANGED
@@ -1,5 +1,310 @@
1
1
  # Release Notes
2
2
 
3
+ ## 2.0.0
4
+
5
+ ### External changes
6
+
7
+ * Remove support for Ruby v1.9 - thanks to @wasabigeek (#552)
8
+ * Support strict keyword argument matching - see docs for `Expectation#with` & `Configuration#strict_keyword_argument_matching=` - thanks to @wasabigeek (#446,#535,#544,#562)
9
+ * Deprecate `Hash` args that don't strictly match (#563,981c31be)
10
+ * Drop support for older versions of test-unit - gem versions of test-unit earlier than v2.5.1 and versions of test-unit
11
+ from the Ruby v1.8 standard library are no longer supported (#540,969f4845)
12
+ * Drop support for older versions of minitest - versions of minitest earlier than v3.3.0 are no longer supported (#541,ca69dc9e)
13
+ * Remove deprecated `mocha/setup.rb` mechanism (642a0ff4)
14
+ * Add missing docs for `API#stub` parameter (257b4cb4)
15
+ * Remove optional reinstatement of v1.9 behaviour (#436,#438,#569,1473ee25)
16
+ * Remove deprecated methods in `Configuration` (#421,e7ff7528)
17
+ * Fail fast when mock receives invocations in another test (#440,#442,cb054d59)
18
+ * Improve docs re using matchers in `Expectation#with` (da7237cd)
19
+ * Expand `Expectation#with` docs re keyword arguments (fed6808d)
20
+ * Improve docs for `strict_keyword_argument_matching` (8d8f881d)
21
+ * Remove deprecated Rails plugin `init.rb` file (1c617175)
22
+ * Improve strict keyword argument matching deprecation warning by including the source location of the stub definition (77c0d4cc)
23
+ * Add README section re semantic versioning (00758246)
24
+
25
+ ### Internal changes
26
+
27
+ * Separate linting from tests in terms of Rake tasks & CircleCI jobs - thanks to @wasabigeek (#556)
28
+ * Remove tests specific to Ruby v1.8 behaviour (46fca7ac, 3b369e99)
29
+ * Multi-line rubocop disable in `Mock#method_missing` (af2194c4)
30
+ * Remove unused arg for `HashMethods#mocha_inspect` (4f59e27f)
31
+ * Improve test runner assertions - failure vs error (eec7200a)
32
+ * Improve test coverage of `PositionalOrKeywordHash` (c294fe70)
33
+ * More consistent Test::Unit & Minitest integration (27dd3817)
34
+ * Remove redundant `require` statements (d82218a8,fa17b114)
35
+ * Add missing `require` statement (73493761)
36
+ * Disable Style/Semicolon cop globally (8cd0b705)
37
+
38
+ ## 1.16.0
39
+
40
+ ### External changes
41
+
42
+ * Default `Configuration#reinstate_undocumented_behaviour_from_v1_9=` to `false` (6fcaf947)
43
+ * Deprecate `Configuration#reinstate_undocumented_behaviour_from_v1_9=` (a797c5fd)
44
+
45
+ ### Internal changes
46
+
47
+ * Remove redundant deprecation disabling in MockTest (dc8ca969)
48
+
49
+ ## 1.15.0
50
+
51
+ ### External changes
52
+
53
+ * Fix examples using mock constructor with block (1cc17667)
54
+ * Add another example for `API#sequence` (b7a7d233, #59)
55
+ * Remove support for Ruby v1.8 (ddb5d672)
56
+ * Deprecate support for Ruby versions earlier than v2.0 - thanks to @wasabigeek (#553, #555)
57
+
58
+ ### Internal changes
59
+
60
+ * Update instructions for obtaining Rubygems API key (ed9c040a)
61
+ * Consistent definitions for `respond_to?` methods (#533)
62
+ * Run test tasks before release tasks (92a1bc6e, #447)
63
+ * Fix test:performance Rake task (#538, #539)
64
+ * Tidying following removal of support for Ruby v1.8 - thanks to @nitishr (#542)
65
+ * Remove `ParametersMatcher` from `Invocation#call_description` - thanks to @wasabigeek (#543)
66
+ * Remove unnecessary splatting in Invocation - thanks to @wasabigeek (#549)
67
+ * Extract `handle_method_call` from `method_missing` - thanks to @wasabigeek (#550)
68
+
69
+ ## 1.14.0
70
+
71
+ ### External changes
72
+
73
+ * Mock#expects,#stubs should return last expectation - thanks to @vlad-pisanov for #524 (b6b637db)
74
+
75
+ ### Internal changes
76
+
77
+ * Avoid breaking change in psych v4 in ruby v3.1 (08b9f4ca)
78
+ * Remove broken Dependabot badge from README (d446657a)
79
+ * Add Ruby 3.0 to the CI matrix - thanks to @mishina2228 for #526 (65bc626e)
80
+ * Move development dependencies from gemspec to Gemfile - thanks to @mishina2228 for #527 (dd127f7b)
81
+
82
+ ## 1.13.0
83
+
84
+ ### External changes
85
+
86
+ * Add `ParameterMatchers#has_keys` - thanks to @cstyles for #512 (18d8104)
87
+ * Fix misleading exception message in `ParameterMatchers#has_entry` - thanks to @cstyles for #513 (9c4ef13)
88
+ * Only add dependency on rubocop if we're actually going to use it (f2f879f)
89
+ * Fix rake dependency constraints for older Ruby versions (7ce5f29)
90
+
91
+ ### Internal changes
92
+
93
+ * Check documentation can be generated as part of CircleCI build (b30d9a9)
94
+ * Add --fail-on-warning option to yard rake task (53a6ee3)
95
+ * Add a weekly scheduled build to the CircleCI build (fd2a4c6)
96
+ * Add Ruby v1.8 to the CircleCI build matrix (818ca03)
97
+ * Add API token to fix CircleCI badge in README (607c5aa)
98
+ * Provide wrapped option for #mocha_inspect on hashes & arrays (d8f44bc)
99
+ * Use CircleCI instead of TravisCI for automated builds (c98c6ec)
100
+ * Switch to newer default Travis CI build env (c78f75c)
101
+ * Use latest Ruby versions in Travis CI builds (9e0043a)
102
+ * Use latest JRuby v9.2.18 in Travis CI builds (8c99a1b)
103
+ * Use consistent JRuby versions in Travis CI builds (0f849aa)
104
+ * Use more recent version of JRuby in Travis CI build matrix (58653db)
105
+
106
+ ## 1.12.0
107
+
108
+ ### External changes
109
+
110
+ * Various improvements to README inspired by #207 and #390 - thanks to @nitishr for his work on #390 (fed0eee6)
111
+ * Improve documentation related to `StateMachine` classes - thanks to @nitishr (#425 & #427)
112
+ * Fix regression in cardinality introduced in v1.10.0 (59454a8) and reported in #473 - thanks to @srvance for reporting and @nitishr for fixing (#474)
113
+ * Fix documentation for `Mocha::Expectation#when` - thanks to @olleolleolle (b4f59daa & #477)
114
+ * Remove `Mocha::Mock#respond_to?` from documentation - thanks to @nitishr (#480)
115
+ * Improvements to documentation for `Expectation#yields` & `#multiple_yields` - thanks to @andyw8 for reporting in #495 (1b6571c)
116
+ * Remove documentation & tests from gem to reduce its size by over 50% - thanks to @gabetax (#500)
117
+ * Update documentation to point to travis-ci.com instead of travis-ci.org
118
+
119
+ ### Internal changes
120
+
121
+ * Refactor `StateMachine`-related classes - thanks to @nitishr (#425 & #427)
122
+ * Remove redundant test - thanks to @nitishr (8e4f1a7c)
123
+ * Add Ruby 2.7 to Travis CI matrix - thanks to @bastelfreak (fc5ea2f2)
124
+ * Simplify `Mockery` - thanks to @nitishr (#449)
125
+ * Update Travis CI badge to point to main vs master branch (bd8028f8)
126
+ * Generate docs using newer version of yard (v0.9.25) (c619afac)
127
+ * Manually upgrade jquery in docs from v1.7.1 -> v1.9.0 to fix CVE-2017-16011 (211098a5, dd5eeedb & 1b76e4d5; also see #492)
128
+ * Remove reference to non-existent jquery source map to fix error in Chrome developer tools (20156555)
129
+ * Temporarily ignore Ruby v1.8.7 build failures (e5b9feef)
130
+
131
+ ## 1.11.2
132
+
133
+ ### External changes
134
+
135
+ * Fix regression introduced in v1.10.0 that meant `Object#inspect` was called unnecessarily (368abd98)
136
+ * Warn when mock object receives invocations in another test - thanks to @nitishr (#442)
137
+ * Avoid rubocop comments appearing in YARD-generated docs (d8019eed)
138
+
139
+ ### Internal changes
140
+
141
+ * Replace `StubbedMethod#original_method` & `#original_visibility` attribute reader methods with instance variables - thanks to @nitishr (d917f332)
142
+ * Set up `MochaExampleTest` & `StubbaExampleTest` as acceptance tests - thanks to @nitishr (4881cc58)
143
+ * Delete unused `PrettyParameters` class - thanks to @nitishr (314ea922)
144
+
145
+ ## 1.11.1
146
+
147
+ ### External changes
148
+
149
+ * 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)
150
+
151
+ ## 1.11.0
152
+
153
+ ### External changes
154
+
155
+ * Add `Expectation#with_block_given` & `Expectation#with_no_block_given` (#441).
156
+ * Allows non-deprecated solution for #382. Thanks to @yemartin for reporting and to @techbelly & @nitishr for feedback.
157
+ * Fix issue with non-Array arguments passed to `Expectation#multiple_yields` (#444).
158
+ * The undocumented behaviour is now properly supported and documented.
159
+
160
+ ### Internal changes
161
+
162
+ * Move static YARD options from Rake task to `.yardopts` file - thanks to @nitishr (#429)
163
+ * Simplify implementation of yielding functionality - thanks to @nitishr (#439)
164
+ * Add missing require statement to `acceptance_test_helper.rb` (1070fc02)
165
+ * Add some baseline acceptance tests for yielding behaviour (c2cac911)
166
+ * Display a sponsor button on GitHub repo page (9fc5911b)
167
+ * Use new Deprecation.warning behaviour in `Invocation#call` (932d1166)
168
+
169
+ ## 1.10.2
170
+
171
+ * 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):
172
+ * The behaviour of `API#mock`, `API#stub` and `API#stub_everything` when called with a symbol as the first argument.
173
+ * The behaviour of `Expectation#yields` and `Expectation#multiple_yields` when the stubbed method is called without a block.
174
+
175
+ ## 1.10.1
176
+
177
+ * Ensure ObjectMethods & ClassMethods included when API extended (43778756)
178
+ * 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)
179
+
180
+ ## 1.10.0
181
+
182
+ * Improve deprecation warning when requiring 'mocha/setup' (388f44d7)
183
+ * Add documentation for Cucumber integration (13ab797b)
184
+ * Add documentation about an undocumented feature of `API#mock`, `API#stub` & `API#stub_everything` being changed (7ed2e4e7, d30c1717)
185
+
186
+ ## 1.10.0.beta.1
187
+
188
+ * Hide `ClassMethods#method_visibility` & `#method_exists?` methods to avoid clash with Rails (#428)
189
+
190
+ ## 1.10.0.alpha
191
+
192
+ ### External changes
193
+
194
+ * Remove dependency on metaclass gem (#49, #365)
195
+ * Accept symbol (as well as a string) as mock/stub name - thanks to @nitishr (#347, #353, #377)
196
+ * More realistic examples in documentation for `Expectation#yields` and `#multiple_yields` - thanks to @nitishr (#352, #383)
197
+ * Improve documentation for `Mock#responds_like` & `#responds_like_instance_of` - thanks to @nitishr (#337, #384)
198
+ * 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)
199
+ * Document `MOCHA_OPTIONS` in README - thanks to @nitishr (#311, #386)
200
+ * Add documentation to explain how Mocha is intended to be used - thanks to @nitishr (#330, #385)
201
+ * Deprecation warning if integration using 'mocha/test_unit' or 'mocha/minitest' fails - thanks to @nitishr (#229, #389, c6032d0b)
202
+ * Require at least one specified sequence for `Expectation#in_sequence` - thanks to @nitishr (#79, #396, 9020248a)
203
+ * Make signatures of `Mock#unstub` & `ObjectMethods#unstub` consistent - thanks to @nitishr (#397, f04d437)
204
+ * Deprecate requiring 'mocha/setup' (36adf880)
205
+ * Optionally display matching invocations alongside expectations - thanks to @nitishr (#178, #394, 00f0540, #410)
206
+ * Put deprecations into effect (#400, #418):
207
+ * Remove deprecated 'mocha_standalone.rb' & 'mocha/standalone.rb'
208
+ * Fail fast if no test library loaded
209
+ * Removed optional block for `Mocha::API#mock`, `#stub` & `#stub_everything`
210
+ * Remove deprecated `ParameterMatchers#has_equivalent_query_string` method
211
+ * Remove deprecated 'mocha/mini_test.rb'
212
+ * Fix typo in docs for `Mocha::Configuration.prevent` (266ce71c)
213
+ * New-style configuration (see documentation for `Mocha::Configuration`) (#407, #421)
214
+ * Deprecate support for Ruby versions earlier than v1.9 (#325, c5f8496d)
215
+ * Deprecate support for versions of test-unit & minitest which need monkey-patching (a34e1a88)
216
+ * Deprecate old-style Rails plugin (#403, 2df77134)
217
+ * Documentation fixes & improvements which also fix YARD warnings (472d5416, a2c0d64a)
218
+
219
+ ### Internal changes
220
+
221
+ * Pin minitest to v5.11.3 for Ruby v1.8.7 to fix build; minitest no longer supports Ruby v1.8.7 (4a0a580)
222
+ * Upgrade JRuby to v9.2.8.0 in Travis CI builds (aa29b3f)
223
+ * Only run rubocop for MRI Ruby versions & non-integration test builds (8f1c6af)
224
+ * Reduce duplication in any instance method class - thanks to @nitishr (#378)
225
+ * Simplify `AnyInstanceMethod`, `ClassMethod`, `InstanceMethod`, `ModuleMethod` class hierarchy - thanks to @nitishr (#381)
226
+ * Simplify `ClassMethods#method_exists?` & `ObjectMethods#method_exists?` making them consistent - thanks to @nitishr (#270, #362, #370)
227
+ * Don't override definition of `singleton_class` in `ClassMethods` - thanks to @nitishr (#391, #392)
228
+ * Do not include 'method_definer' methods into all objects (#268, #402)
229
+ * Distinguish different `ObjectMethods` modules (#268, #404)
230
+ * Pass invocation to expectation list methods - thanks to @nitishr (#408, #409, #411)
231
+ * Consistently use `assert_raises` - thanks to @nitishr (#405, #412, a66b7bed)
232
+ * Update Ruby & JRuby versions in Travis CI config (18cb1a93, eb061c53)
233
+ * Rubocop improvements (aa16ea67...6f4db70b, 2a1240e6...e95716ae)
234
+ * Fix inconsistency in CardinalityTest (aa10e0a8)
235
+ * Fix test failures on Mac OSX Catalina - thanks to @nitishr (#413, #417, #419, 8a0f2535)
236
+ * Remove default argument in `Expectation#invoke` - thanks to @nitishr (#414, #420)
237
+
238
+ ## 1.9.0
239
+
240
+ * Add TruffleRuby to Travis CI build matrix - thanks to @deepj (#354)
241
+ * Explicitly set Travis CI OS to Ubuntu Trusty 14.04 (ded1fa45)
242
+ * Expand explanation of thread-safety concerns - thanks to @techbelly (#357)
243
+ * Refactor class method and any instance method - thanks to @chrisroos (#358)
244
+ * Rely on default bundler version in Travis CI builds (3352e9c5)
245
+ * Fix local build-matrix script (11abe231)
246
+ * No need to install latest bundler in build-matrix script (8247a894)
247
+
248
+ ## 1.8.0
249
+
250
+ * Constrain rubocop version to avoid breaking Travis CI builds (05e507f5)
251
+ * Avoid calling Kernel#format from ObjectMethods#mocha_inspect - thanks to @hoffmanilya (#345)
252
+ * Fix build matrix script (#346)
253
+ * Avoid deprecation warning in gemspec (4976e0bc)
254
+ * Removed link to documentation translation (ef428ea2)
255
+ * Don't use the new bundler v2 in builds (683ded9b)
256
+ * Moved documentation from https://gofreerange.com/mocha/docs to https://mocha.jamesmead.org/ [683ded...a17fde](https://github.com/freerange/mocha/compare/683ded...a17fde)
257
+
258
+ ## 1.7.0
259
+
260
+ * Update Ruby & JRuby versions in Travis CI config (9bf55631 & 3883af7e)
261
+ * Simplify gemspec (63744f86)
262
+ * Add rubocop and fix most cop violations (#341)
263
+ * Use Kernel#warn for deprecations - thanks to @etiennebarrie (#333, 196970a)
264
+
265
+ ## 1.6.0
266
+
267
+ * Fix subtle bug in setting correct visibility of stubbed module methods on `Kernel` or `Object` - thanks to @chrisroos (#295)
268
+ * Avoid mocks for partial mocking leaking into subsequent tests - thanks to @skliew for reporting (#331)
269
+ * Remove OpenCollective badge, backers & sponsors (a283a079)
270
+ * Change gem version badge to SVG format and add SemVer stability badge - thanks to @greysteil (#335)
271
+ * Improve documentation for Configuration (#236)
272
+
273
+ ## 1.5.0
274
+
275
+ * Prevent use of Mocha outside the context of a test/example - thanks to @andyw8 & @lzap (#327)
276
+
277
+ ## 1.4.0
278
+
279
+ * Fix deprecation warning for `assert_nil` in `ClassMethodTest` (#308 & #309)
280
+ * Display file and line number in deprecation warning - thanks to @chrisarcand (#310, #312 & #313)
281
+ * Rename `mocha/mini_test.rb` to `mocha/minitest.rb` - thanks to @grosser (#320 & #322)
282
+ * Fix warning when delegating to mock in Ruby 2.4 - thanks to @tjvc (#321 & #323)
283
+ * Updates to Travis CI configuration ([73af600..9732726](https://github.com/freerange/mocha/compare/73af600...9732726) & 0426e5e)
284
+
285
+ ## 1.3.0
286
+
287
+ * Ensure all tests run individually - thanks to @chrisroos (#267)
288
+ * Update Travis CI build status badge to show master branch status (#264)
289
+ * Correct RSpec section of the README - thanks to @myronmarston (0cc039c8)
290
+ * Fix pretty printing of quotes in `String#mocha_inspect` (#215 & #223)
291
+ * Add release instructions to README - thanks to @chrisroos (70a5febd & 3c664df7)
292
+ * Require at least Ruby v1.8.7 in gemspec - thanks to @knappe (3e20be8e)
293
+ * Remove redundant InstanceMethod#method_exists? - thanks to @chrisroos (8f58eddf)
294
+ * Reduce risk of hitting bug 12832 in Ruby v2.3 - thanks to @chrisroos (#277 & eca7560c)
295
+ * Fix JRuby build - thanks to @headius (jruby/jruby#4250) & @chrisroos (#274)
296
+ * Add latest stable version of JRuby to Travis CI build matrix (#288)
297
+ * Fix Ruby v1.8.7 builds on Travis CI (928b5a40 & 460dce5b)
298
+ * Deprecate passing block to mock object constructor (#290)
299
+ * Add a known issue to README for Ruby bug 12876 (#276)
300
+ * Add Ruby 2.4 and ruby-head to Travis CI build matrix - thanks to @junaruga (#297)
301
+ * Fix `Mocha::ParameterMatchers#includes` for `Array` values - thanks to @timcraft (#302)
302
+ * Use faster container-based virtual environments for Travis CI builds (#305)
303
+ * Rename `Mocha::ParameterMatchers::QueryStringMatches` to `QueryString` (#306)
304
+ * Handle blank parameter value for query string matcher - thanks to @weynsee (#303 & #304)
305
+ * Rename `Mocha::ParameterMatchers::QueryString` -> `EquivalentUri` (#307)
306
+ * Use `do ... end` instead of `{ ... }` in acceptance tests - thanks to @chrisroos (#294)
307
+
3
308
  ## 1.2.1
4
309
 
5
310
  * Fixed #272. Workaround Ruby bug 12832 which caused interpreter to hang. See https://bugs.ruby-lang.org/issues/12832. Thanks to @chrisroos & @petems (6f1c8b9b, #273).
@@ -395,7 +700,7 @@ Hash with wrong number of entries.
395
700
 
396
701
  ## 0.5.0
397
702
 
398
- - Parameter Matchers - Ive added a few Hamcrest-style parameter matchers which are designed to be used inside Expectation#with. The following matchers are currently available: anything(), includes(), has_key(), has_value(), has_entry(), all_of() & any_of(). More to follow soon. The idea is eventually to get rid of the nasty parameter_block option on Expectation#with.
703
+ - Parameter Matchers - I've added a few Hamcrest-style parameter matchers which are designed to be used inside Expectation#with. The following matchers are currently available: anything(), includes(), has_key(), has_value(), has_entry(), all_of() & any_of(). More to follow soon. The idea is eventually to get rid of the nasty parameter_block option on Expectation#with.
399
704
 
400
705
  object = mock()
401
706
  object.expects(:method).with(has_key('key_1'))
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,33 +98,35 @@ 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`
129
+ `rm -rf ./docs`
124
130
  end
125
131
 
126
132
  task 'docs_environment' do
@@ -131,19 +137,20 @@ if ENV["MOCHA_GENERATE_DOCS"]
131
137
 
132
138
  desc 'Generate documentation'
133
139
  YARD::Rake::YardocTask.new('yardoc' => 'docs_environment') do |task|
134
- task.options = ["--title", "Mocha #{Mocha::VERSION}"]
140
+ task.options = ['--title', "Mocha #{Mocha::VERSION}", '--fail-on-warning']
135
141
  end
136
142
 
137
- desc "Generate documentation"
138
- task 'generate_docs' => ['clobber_yardoc', 'yardoc']
143
+ task 'checkout_docs_cname' do
144
+ `git checkout docs/CNAME`
145
+ end
139
146
 
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}}
147
+ task 'checkout_docs_js' do
148
+ `git checkout docs/js/app.js`
149
+ `git checkout docs/js/jquery.js`
144
150
  end
145
- end
146
151
 
147
- task 'release' => 'default' do
148
- Rake::Task['publish_docs'].invoke
152
+ desc 'Generate documentation'
153
+ task 'generate_docs' => %w[clobber_yardoc yardoc checkout_docs_cname checkout_docs_js]
149
154
  end
155
+
156
+ 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
- @original_method = stubbee.instance_method(method)
20
- if RUBY_V2_PLUS
21
- @definition_target = PrependedModule.new
22
- stubbee.__send__ :prepend, @definition_target
23
- else
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