mocha 1.9.0 → 1.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (215) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +1 -0
  3. data/.rubocop.yml +3 -0
  4. data/.rubocop_todo.yml +7 -30
  5. data/.yardopts +1 -0
  6. data/README.md +30 -11
  7. data/RELEASE.md +93 -0
  8. data/Rakefile +10 -7
  9. data/docs/CNAME +1 -0
  10. data/docs/Mocha.html +132 -5
  11. data/docs/Mocha/API.html +437 -206
  12. data/docs/Mocha/ClassMethods.html +13 -16
  13. data/docs/Mocha/Configuration.html +1126 -227
  14. data/docs/Mocha/Expectation.html +420 -267
  15. data/docs/Mocha/ExpectationError.html +5 -10
  16. data/docs/Mocha/ExpectationErrorFactory.html +9 -18
  17. data/docs/Mocha/Hooks.html +12 -27
  18. data/docs/Mocha/Integration.html +3 -3
  19. data/docs/Mocha/Integration/MiniTest.html +3 -3
  20. data/docs/Mocha/Integration/MiniTest/Adapter.html +5 -6
  21. data/docs/Mocha/Integration/TestUnit.html +3 -3
  22. data/docs/Mocha/Integration/TestUnit/Adapter.html +5 -6
  23. data/docs/Mocha/Mock.html +202 -162
  24. data/docs/Mocha/ObjectMethods.html +121 -68
  25. data/docs/Mocha/ParameterMatchers.html +21 -109
  26. data/docs/Mocha/ParameterMatchers/AllOf.html +4 -5
  27. data/docs/Mocha/ParameterMatchers/AnyOf.html +4 -5
  28. data/docs/Mocha/ParameterMatchers/AnyParameters.html +3 -3
  29. data/docs/Mocha/ParameterMatchers/Anything.html +3 -3
  30. data/docs/Mocha/ParameterMatchers/Base.html +8 -15
  31. data/docs/Mocha/ParameterMatchers/Equals.html +4 -5
  32. data/docs/Mocha/ParameterMatchers/EquivalentUri.html +3 -3
  33. data/docs/Mocha/ParameterMatchers/HasEntries.html +4 -5
  34. data/docs/Mocha/ParameterMatchers/HasEntry.html +4 -5
  35. data/docs/Mocha/ParameterMatchers/HasKey.html +4 -5
  36. data/docs/Mocha/ParameterMatchers/HasValue.html +4 -5
  37. data/docs/Mocha/ParameterMatchers/Includes.html +4 -5
  38. data/docs/Mocha/ParameterMatchers/InstanceOf.html +4 -5
  39. data/docs/Mocha/ParameterMatchers/IsA.html +3 -3
  40. data/docs/Mocha/ParameterMatchers/KindOf.html +4 -5
  41. data/docs/Mocha/ParameterMatchers/Not.html +4 -5
  42. data/docs/Mocha/ParameterMatchers/Optionally.html +3 -3
  43. data/docs/Mocha/ParameterMatchers/RegexpMatches.html +4 -5
  44. data/docs/Mocha/ParameterMatchers/RespondsWith.html +4 -5
  45. data/docs/Mocha/ParameterMatchers/YamlEquivalent.html +4 -5
  46. data/docs/Mocha/Sequence.html +3 -3
  47. data/docs/Mocha/StateMachine.html +13 -25
  48. data/docs/Mocha/StateMachine/State.html +4 -5
  49. data/docs/Mocha/StateMachine/StatePredicate.html +4 -5
  50. data/docs/Mocha/StubbingError.html +3 -3
  51. data/docs/_index.html +4 -22
  52. data/docs/class_list.html +1 -1
  53. data/docs/file.COPYING.html +3 -3
  54. data/docs/file.MIT-LICENSE.html +3 -3
  55. data/docs/file.README.html +36 -14
  56. data/docs/file.RELEASE.html +126 -3
  57. data/docs/frames.html +1 -1
  58. data/docs/index.html +36 -14
  59. data/docs/method_list.html +117 -37
  60. data/docs/top-level-namespace.html +3 -3
  61. data/gemfiles/Gemfile.minitest.5.11.3 +7 -0
  62. data/init.rb +1 -3
  63. data/lib/mocha.rb +8 -0
  64. data/lib/mocha/any_instance_method.rb +9 -25
  65. data/lib/mocha/api.rb +120 -56
  66. data/lib/mocha/block_matcher.rb +31 -0
  67. data/lib/mocha/cardinality.rb +26 -11
  68. data/lib/mocha/class_methods.rb +17 -15
  69. data/lib/mocha/configuration.rb +351 -67
  70. data/lib/mocha/deprecation.rb +2 -1
  71. data/lib/mocha/detection/test_unit.rb +1 -3
  72. data/lib/mocha/exception_raiser.rb +2 -1
  73. data/lib/mocha/expectation.rb +102 -63
  74. data/lib/mocha/expectation_error.rb +1 -3
  75. data/lib/mocha/expectation_list.rb +6 -6
  76. data/lib/mocha/inspect.rb +28 -26
  77. data/lib/mocha/instance_method.rb +19 -2
  78. data/lib/mocha/integration.rb +1 -3
  79. data/lib/mocha/integration/mini_test.rb +7 -0
  80. data/lib/mocha/integration/test_unit.rb +7 -0
  81. data/lib/mocha/invocation.rb +77 -0
  82. data/lib/mocha/macos_version.rb +5 -0
  83. data/lib/mocha/minitest.rb +6 -1
  84. data/lib/mocha/mock.rb +46 -31
  85. data/lib/mocha/mockery.rb +25 -61
  86. data/lib/mocha/names.rb +1 -1
  87. data/lib/mocha/object_methods.rb +13 -19
  88. data/lib/mocha/parameter_matchers.rb +1 -1
  89. data/lib/mocha/parameter_matchers/all_of.rb +1 -1
  90. data/lib/mocha/parameter_matchers/any_of.rb +1 -1
  91. data/lib/mocha/parameter_matchers/equivalent_uri.rb +0 -9
  92. data/lib/mocha/parameter_matchers/includes.rb +2 -0
  93. data/lib/mocha/parameter_matchers/instance_methods.rb +18 -0
  94. data/lib/mocha/raised_exception.rb +11 -0
  95. data/lib/mocha/return_values.rb +3 -3
  96. data/lib/mocha/setup.rb +5 -0
  97. data/lib/mocha/single_return_value.rb +2 -1
  98. data/lib/mocha/singleton_class.rb +9 -0
  99. data/lib/mocha/{class_method.rb → stubbed_method.rb} +23 -43
  100. data/lib/mocha/test_unit.rb +6 -1
  101. data/lib/mocha/thrower.rb +2 -1
  102. data/lib/mocha/thrown_object.rb +12 -0
  103. data/lib/mocha/version.rb +1 -1
  104. data/lib/mocha/yield_parameters.rb +5 -11
  105. data/mocha.gemspec +1 -3
  106. data/test/acceptance/acceptance_test_helper.rb +7 -0
  107. data/test/acceptance/bug_18914_test.rb +0 -1
  108. data/test/acceptance/bug_21465_test.rb +0 -1
  109. data/test/acceptance/bug_21563_test.rb +0 -1
  110. data/test/acceptance/display_matching_invocations_alongside_expectations_test.rb +69 -0
  111. data/test/acceptance/exception_rescue_test.rb +1 -2
  112. data/test/acceptance/expectations_on_multiple_methods_test.rb +0 -1
  113. data/test/acceptance/expected_invocation_count_test.rb +2 -3
  114. data/test/acceptance/failure_messages_test.rb +16 -1
  115. data/test/acceptance/issue_272_test.rb +1 -2
  116. data/test/acceptance/issue_65_test.rb +0 -1
  117. data/test/acceptance/issue_70_test.rb +0 -1
  118. data/test/acceptance/mocha_example_test.rb +0 -1
  119. data/test/acceptance/mocha_test_result_test.rb +0 -1
  120. data/test/acceptance/mock_built_with_first_argument_type_being_string_test.rb +98 -0
  121. data/test/acceptance/mock_test.rb +63 -6
  122. data/test/acceptance/mocked_methods_dispatch_test.rb +0 -1
  123. data/test/acceptance/multiple_expectations_failure_message_test.rb +0 -1
  124. data/test/acceptance/multiple_yielding_test.rb +59 -0
  125. data/test/acceptance/optional_parameters_test.rb +0 -1
  126. data/test/acceptance/parameter_matcher_test.rb +0 -1
  127. data/test/acceptance/partial_mocks_test.rb +0 -1
  128. data/test/acceptance/prepend_test.rb +0 -1
  129. data/test/acceptance/prevent_use_of_mocha_outside_test_test.rb +0 -1
  130. data/test/acceptance/raise_exception_test.rb +0 -1
  131. data/test/acceptance/return_value_test.rb +0 -1
  132. data/test/acceptance/sequence_test.rb +0 -1
  133. data/test/acceptance/states_test.rb +0 -1
  134. data/test/acceptance/stub_any_instance_method_defined_on_superclass_test.rb +1 -2
  135. data/test/acceptance/stub_any_instance_method_test.rb +20 -1
  136. data/test/acceptance/stub_class_method_defined_on_active_record_association_proxy_test.rb +0 -1
  137. data/test/acceptance/stub_class_method_defined_on_class_test.rb +0 -1
  138. data/test/acceptance/stub_class_method_defined_on_module_test.rb +0 -1
  139. data/test/acceptance/stub_class_method_defined_on_superclass_test.rb +1 -2
  140. data/test/acceptance/stub_everything_test.rb +0 -1
  141. data/test/acceptance/stub_instance_method_defined_on_active_record_association_proxy_test.rb +0 -1
  142. data/test/acceptance/stub_instance_method_defined_on_class_and_aliased_test.rb +0 -1
  143. data/test/acceptance/stub_instance_method_defined_on_class_test.rb +0 -1
  144. data/test/acceptance/stub_instance_method_defined_on_kernel_module_test.rb +0 -1
  145. data/test/acceptance/stub_instance_method_defined_on_module_test.rb +0 -1
  146. data/test/acceptance/stub_instance_method_defined_on_object_class_test.rb +0 -1
  147. data/test/acceptance/stub_instance_method_defined_on_singleton_class_test.rb +0 -1
  148. data/test/acceptance/stub_instance_method_defined_on_superclass_test.rb +0 -1
  149. data/test/acceptance/stub_method_defined_on_module_and_aliased_test.rb +0 -1
  150. data/test/acceptance/stub_module_method_test.rb +0 -1
  151. data/test/acceptance/stub_test.rb +0 -1
  152. data/test/acceptance/stubba_example_test.rb +0 -1
  153. data/test/acceptance/stubba_test_result_test.rb +0 -1
  154. data/test/acceptance/stubbing_error_backtrace_test.rb +4 -5
  155. data/test/acceptance/stubbing_frozen_object_test.rb +0 -1
  156. data/test/acceptance/stubbing_method_accepting_block_parameter_test.rb +0 -1
  157. data/test/acceptance/stubbing_method_unnecessarily_test.rb +5 -5
  158. data/test/acceptance/stubbing_nil_test.rb +5 -5
  159. data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +27 -11
  160. data/test/acceptance/stubbing_non_existent_class_method_test.rb +11 -11
  161. data/test/acceptance/stubbing_non_existent_instance_method_test.rb +11 -11
  162. data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +8 -8
  163. data/test/acceptance/stubbing_non_public_class_method_test.rb +9 -9
  164. data/test/acceptance/stubbing_non_public_instance_method_test.rb +9 -9
  165. data/test/acceptance/stubbing_on_non_mock_object_test.rb +5 -5
  166. data/test/acceptance/stubbing_same_class_method_on_parent_and_child_classes_test.rb +0 -1
  167. data/test/acceptance/throw_test.rb +0 -1
  168. data/test/acceptance/unexpected_invocation_test.rb +0 -1
  169. data/test/acceptance/unstubbing_test.rb +0 -1
  170. data/test/acceptance/yielding_test.rb +80 -0
  171. data/test/integration/shared_tests.rb +5 -3
  172. data/test/method_definer.rb +11 -17
  173. data/test/test_runner.rb +2 -0
  174. data/test/unit/any_instance_method_test.rb +41 -40
  175. data/test/unit/cardinality_test.rb +41 -23
  176. data/test/unit/central_test.rb +0 -1
  177. data/test/unit/class_methods_test.rb +1 -1
  178. data/test/unit/configuration_test.rb +12 -12
  179. data/test/unit/exception_raiser_test.rb +10 -5
  180. data/test/unit/expectation_list_test.rb +13 -11
  181. data/test/unit/expectation_test.rb +115 -103
  182. data/test/unit/instance_method_test.rb +282 -0
  183. data/test/unit/mock_test.rb +28 -19
  184. data/test/unit/mockery_test.rb +8 -11
  185. data/test/unit/module_methods_test.rb +2 -3
  186. data/test/unit/object_inspect_test.rb +6 -4
  187. data/test/unit/object_methods_test.rb +3 -2
  188. data/test/unit/parameter_matchers/equivalent_uri_test.rb +0 -9
  189. data/test/unit/parameter_matchers/has_entries_test.rb +1 -1
  190. data/test/unit/parameter_matchers/has_entry_test.rb +1 -1
  191. data/test/unit/parameter_matchers/has_key_test.rb +1 -1
  192. data/test/unit/parameter_matchers/has_value_test.rb +1 -1
  193. data/test/unit/parameter_matchers/includes_test.rb +1 -1
  194. data/test/unit/parameter_matchers/responds_with_test.rb +1 -1
  195. data/test/unit/return_values_test.rb +25 -20
  196. data/test/unit/single_return_value_test.rb +6 -1
  197. data/test/unit/thrower_test.rb +7 -2
  198. data/test/unit/yield_parameters_test.rb +35 -53
  199. metadata +19 -34
  200. data/docs/Mocha/UnexpectedInvocation.html +0 -140
  201. data/lib/mocha/mini_test.rb +0 -5
  202. data/lib/mocha/module_method.rb +0 -6
  203. data/lib/mocha/module_methods.rb +0 -10
  204. data/lib/mocha/multiple_yields.rb +0 -15
  205. data/lib/mocha/no_yields.rb +0 -5
  206. data/lib/mocha/parameter_matchers/object.rb +0 -15
  207. data/lib/mocha/single_yield.rb +0 -13
  208. data/lib/mocha/standalone.rb +0 -4
  209. data/lib/mocha/unexpected_invocation.rb +0 -24
  210. data/lib/mocha_standalone.rb +0 -4
  211. data/test/acceptance/mock_with_initializer_block_test.rb +0 -56
  212. data/test/unit/class_method_test.rb +0 -276
  213. data/test/unit/multiple_yields_test.rb +0 -16
  214. data/test/unit/no_yields_test.rb +0 -16
  215. data/test/unit/single_yield_test.rb +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1d0e385d6aa624c452c0d2e0eb61d9654b95db083371ff2ea3ea942c4ca7826
4
- data.tar.gz: 823ab524717c9fd84d55e9b8be08e583cd183a0dc1b30e7d8f6e7cc8e7739f98
3
+ metadata.gz: c4d2242a81b567af96c5418bb54a86e5c7a4b0d2505c5263734afb920c9f0075
4
+ data.tar.gz: 657404b8cd42ac3430f32f26fab952c0cf55c7f63489343fd81243f5a2eb9462
5
5
  SHA512:
6
- metadata.gz: 404f70ce4517676e56def76d6d21c5d0039afdcfcf46d976162b8c2d50c35c5d4e28a075b84c16481c40574553bda5482b61b5a54118f430b792f7db9bdaa479
7
- data.tar.gz: 439b05b74aa97d6a87288f6477e0caa4c78bf92c2b3942027662d64d9ca631c630f085201d6e79b936b8e6ac70565dfd8be7e9897820f69f3e84b9642919648f
6
+ metadata.gz: 511a89f31cd9389de64d6a690d86abb8126e2290032aadcab124bf5b6947e27f848b131e41d1dd6f87d1b71758e6e76e26e6818325e409ef58ab09087a45f901
7
+ data.tar.gz: a138d451d8676ac8c108a8fc583a1c8f100bc66e8a2bc864cef020d7d05108710221c9e4b54b1f0e25959b66af169fab4f277fa4a6570de958fa996ae1581ecc
@@ -0,0 +1 @@
1
+ github: floehopper
@@ -8,6 +8,9 @@ AllCops:
8
8
  Style/Alias:
9
9
  EnforcedStyle: prefer_alias_method
10
10
 
11
+ Style/Documentation:
12
+ Enabled: false
13
+
11
14
  # Enumerable#each_with_object only available since Ruby v1.9
12
15
  Style/EachWithObject:
13
16
  Enabled: false
@@ -1,49 +1,26 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2018-07-26 12:42:35 +0100 using RuboCop version 0.58.2.
3
+ # on 2019-11-16 18:15:36 +0000 using RuboCop version 0.58.2.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 53
9
+ # Offense count: 57
10
10
  Metrics/AbcSize:
11
- Max: 39
11
+ Max: 26
12
12
 
13
- # Offense count: 2
14
- # Configuration parameters: CountComments, ExcludedMethods.
15
- # ExcludedMethods: refine
16
- Metrics/BlockLength:
17
- Max: 48
18
-
19
- # Offense count: 22
13
+ # Offense count: 23
20
14
  # Configuration parameters: CountComments.
21
15
  Metrics/ClassLength:
22
- Max: 368
23
-
24
- # Offense count: 4
25
- Metrics/CyclomaticComplexity:
26
- Max: 9
16
+ Max: 366
27
17
 
28
- # Offense count: 173
18
+ # Offense count: 172
29
19
  # Configuration parameters: CountComments.
30
20
  Metrics/MethodLength:
31
21
  Max: 31
32
22
 
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
23
+ # Offense count: 545
47
24
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
48
25
  # URISchemes: http, https
49
26
  Metrics/LineLength:
data/.yardopts CHANGED
@@ -1,3 +1,4 @@
1
+ --output-dir docs
1
2
  --template-path yard-templates
2
3
  --no-private
3
4
  lib/mocha/api.rb
data/README.md CHANGED
@@ -3,11 +3,14 @@
3
3
 
4
4
  ### Description
5
5
 
6
- * A Ruby library for mocking and stubbing.
6
+ * A Ruby library for [mocking](http://xunitpatterns.com/Mock%20Object.html) and [stubbing](http://xunitpatterns.com/Test%20Stub.html) - but deliberately not (yet) [faking](http://xunitpatterns.com/Fake%20Object.html) or [spying](http://xunitpatterns.com/Test%20Spy.html).
7
7
  * A unified, simple and readable syntax for both full & partial mocking.
8
8
  * Built-in support for MiniTest and Test::Unit.
9
9
  * Supported by many other test frameworks.
10
10
 
11
+ ### Intended Usage
12
+ Mocha is intended to be used in unit tests for the [Mock Object](http://xunitpatterns.com/Mock%20Object.html) or [Test Stub](http://xunitpatterns.com/Test%20Stub.html) types of [Test Double](http://xunitpatterns.com/Test%20Double.html), not the [Fake Object](http://xunitpatterns.com/Fake%20Object.html) or [Test Spy](http://xunitpatterns.com/Test%20Spy.html) types. Although it would be possible to extend Mocha to allow the implementation of fakes and spies, we have chosen to keep it focused on mocks and stubs.
13
+
11
14
  ### Installation
12
15
 
13
16
  #### Gem
@@ -92,14 +95,6 @@ end
92
95
 
93
96
  Note: There is no need to use a require statement to setup Mocha; RSpec does this itself.
94
97
 
95
- #### Rails Plugin
96
-
97
- Install the Rails plugin...
98
-
99
- $ rails plugin install git://github.com/freerange/mocha.git
100
-
101
- Note: As of version 0.9.8, the Mocha plugin is not automatically setup at plugin load time. Instead it must be manually setup e.g. at the bottom of your `test_helper.rb`.
102
-
103
98
  ##### MiniTest
104
99
 
105
100
  ```ruby
@@ -107,15 +102,34 @@ Note: As of version 0.9.8, the Mocha plugin is not automatically setup at plugin
107
102
  require 'mocha/minitest'
108
103
  ```
109
104
 
105
+ ##### Cucumber
106
+
107
+ ```ruby
108
+ # In e.g. features/support/mocha.rb
109
+ require 'mocha/api'
110
+
111
+ World(Mocha::API)
112
+
113
+ Around do |scenario, block|
114
+ begin
115
+ mocha_setup
116
+ block.call
117
+ mocha_verify
118
+ ensure
119
+ mocha_teardown
120
+ end
121
+ end
122
+ ```
123
+
110
124
  #### Known Issues
111
125
 
126
+ * In Mocha v1.10.0 an undocumented feature of `API#mock`, `API#stub` & `API#stub_everything` was changed. Previously when these methods were passed a single symbol, they returned a mock object that responded to the method identified by the symbol. Now Passing a single symbol is equivalent to passing a single string, i.e. it now defines the "name" of the mock object.
112
127
  * In Mocha v1.2.0 there is a scenario where stubbing a class method originally defined in a module hangs the Ruby interpreter due to [a bug in Ruby v2.3.1](https://bugs.ruby-lang.org/issues/12832). See #272. This was fixed in Mocha v1.2.1.
113
128
  * Since v1.1.0 Mocha has used prepended modules internally for stubbing methods. There is [an obscure Ruby bug](https://bugs.ruby-lang.org/issues/12876) in many (but not all) versions of Ruby between v2.0 & v2.3 which under certain circumstances may cause your Ruby interpreter to hang. See the Ruby bug report for more details. The bug has been fixed in Ruby v2.3.3 & v2.4.0.
114
129
  * Stubbing an aliased class method, where the original method is defined in a module that's used to `extend` the class doesn't work in Ruby 1.8.x. See stub_method_defined_on_module_and_aliased_test.rb for an example of this behaviour.
115
130
  * 0.13.x versions cause a harmless, but annoying, deprecation warning when used with Rails 3.2.0-3.2.12, 3.1.0-3.1.10 & 3.0.0-3.0.19.
116
131
  * 0.11.x versions don't work with Rails 3.2.13 (`TypeError: superclass mismatch for class ExpectationError`). See #115.
117
132
  * Versions 0.10.2, 0.10.3 & 0.11.0 of the Mocha gem were broken. Please do not use these versions.
118
- * Versions 0.9.6 & 0.9.7 of the Mocha Rails plugin were broken. Please do not use these versions.
119
133
 
120
134
  ### Usage
121
135
 
@@ -285,6 +299,11 @@ If you want, Mocha can generate a warning or raise an exception when:
285
299
 
286
300
  See the [documentation](https://mocha.jamesmead.org/Mocha/Configuration.html) for `Mocha::Configuration` for further details.
287
301
 
302
+ ##### MOCHA_OPTIONS
303
+ `MOCHA_OPTIONS` is an environment variable whose value can be set to a comma-separated list, so that we can specify multiple options e.g. `MOCHA_OPTIONS=debug,use_test_unit_gem`.
304
+ Only the following values are currently recognized and have an effect:
305
+ * `debug`: Enables a debug mode which will output backtraces for each deprecation warning. This is useful for finding where in the test suite the deprecated calls are.
306
+
288
307
  ### Useful Links
289
308
 
290
309
  * [Official Documentation](https://mocha.jamesmead.org)
@@ -309,7 +328,7 @@ See this [list of contributors](https://github.com/freerange/mocha/graphs/contri
309
328
  * Check Travis CI build is passing - https://travis-ci.org/freerange/mocha
310
329
 
311
330
  * Sign in to Google Analytics - https://analytics.google.com/analytics/web/
312
- * Find the web property ID for Go Free Range Ltd > Mocha Documentation (UA-625523-7)
331
+ * Find the web property ID for floehopper (625523) > Mocha Documentation (UA-625523-7)
313
332
  * Generate documentation:
314
333
 
315
334
  ```bash
data/RELEASE.md CHANGED
@@ -1,5 +1,98 @@
1
1
  # Release Notes
2
2
 
3
+ ## 1.11.1
4
+
5
+ ### External changes
6
+
7
+ * 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)
8
+
9
+ ## 1.11.0
10
+
11
+ ### External changes
12
+
13
+ * Add `Expectation#with_block_given` & `Expectation#with_no_block_given` (#441).
14
+ * Allows non-deprecated solution for #382. Thanks to @yemartin for reporting and to @techbelly & @nitishr for feedback.
15
+ * Fix issue with non-Array arguments passed to `Expectation#multiple_yields` (#444).
16
+ * The undocumented behaviour is now properly supported and documented.
17
+
18
+ ### Internal changes
19
+
20
+ * Move static YARD options from Rake task to `.yardopts` file - thanks to @nitishr (#429)
21
+ * Simplify implementation of yielding functionality - thanks to @nitishr (#439)
22
+ * Add missing require statement to `acceptance_test_helper.rb` (1070fc02)
23
+ * Add some baseline acceptance tests for yielding behaviour (c2cac911)
24
+ * Display a sponsor button on GitHub repo page (9fc5911b)
25
+ * Use new Deprecation.warning behaviour in `Invocation#call` (932d1166)
26
+
27
+ ## 1.10.2
28
+
29
+ * 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):
30
+ * The behaviour of `API#mock`, `API#stub` and `API#stub_everything` when called with a symbol as the first argument.
31
+ * The behaviour of `Expectation#yields` and `Expectation#multiple_yields` when the stubbed method is called without a block.
32
+
33
+ ## 1.10.1
34
+
35
+ * Ensure ObjectMethods & ClassMethods included when API extended (43778756)
36
+ * 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)
37
+
38
+ ## 1.10.0
39
+
40
+ * Improve deprecation warning when requiring 'mocha/setup' (388f44d7)
41
+ * Add documentation for Cucumber integration (13ab797b)
42
+ * Add documentation about an undocumented feature of `API#mock`, `API#stub` & `API#stub_everything` being changed (7ed2e4e7, d30c1717)
43
+
44
+ ## 1.10.0.beta.1
45
+
46
+ * Hide `ClassMethods#method_visibility` & `#method_exists?` methods to avoid clash with Rails (#428)
47
+
48
+ ## 1.10.0.alpha
49
+
50
+ ### External changes
51
+
52
+ * Remove dependency on metaclass gem (#49, #365)
53
+ * Accept symbol (as well as a string) as mock/stub name - thanks to @nitishr (#347, #353, #377)
54
+ * More realistic examples in documentation for `Expectation#yields` and `#multiple_yields` - thanks to @nitishr (#352, #383)
55
+ * Improve documentation for `Mock#responds_like` & `#responds_like_instance_of` - thanks to @nitishr (#337, #384)
56
+ * 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)
57
+ * Document `MOCHA_OPTIONS` in README - thanks to @nitishr (#311, #386)
58
+ * Add documentation to explain how Mocha is intended to be used - thanks to @nitishr (#330, #385)
59
+ * Deprecation warning if integration using 'mocha/test_unit' or 'mocha/minitest' fails - thanks to @nitishr (#229, #389, c6032d0b)
60
+ * Require at least one specified sequence for `Expectation#in_sequence` - thanks to @nitishr (#79, #396, 9020248a)
61
+ * Make signatures of `Mock#unstub` & `ObjectMethods#unstub` consistent - thanks to @nitishr (#397, f04d437)
62
+ * Deprecate requiring 'mocha/setup' (36adf880)
63
+ * Optionally display matching invocations alongside expectations - thanks to @nitishr (#178, #394, 00f0540, #410)
64
+ * Put deprecations into effect (#400, #418):
65
+ * Remove deprecated 'mocha_standalone.rb' & 'mocha/standalone.rb'
66
+ * Fail fast if no test library loaded
67
+ * Removed optional block for `Mocha::API#mock`, `#stub` & `#stub_everything`
68
+ * Remove deprecated `ParameterMatchers#has_equivalent_query_string` method
69
+ * Remove deprecated 'mocha/mini_test.rb'
70
+ * Fix typo in docs for `Mocha::Configuration.prevent` (266ce71c)
71
+ * New-style configuration (see documentation for `Mocha::Configuration`) (#407, #421)
72
+ * Deprecate support for Ruby versions earlier than v1.9 (#325, c5f8496d)
73
+ * Deprecate support for versions of test-unit & minitest which need monkey-patching (a34e1a88)
74
+ * Deprecate old-style Rails plugin (#403, 2df77134)
75
+ * Documentation fixes & improvements which also fix YARD warnings (472d5416, a2c0d64a)
76
+
77
+ ### Internal changes
78
+
79
+ * Pin minitest to v5.11.3 for Ruby v1.8.7 to fix build; minitest no longer supports Ruby v1.8.7 (4a0a580)
80
+ * Upgrade JRuby to v9.2.8.0 in Travis CI builds (aa29b3f)
81
+ * Only run rubocop for MRI Ruby versions & non-integration test builds (8f1c6af)
82
+ * Reduce duplication in any instance method class - thanks to @nitishr (#378)
83
+ * Simplify `AnyInstanceMethod`, `ClassMethod`, `InstanceMethod`, `ModuleMethod` class hierarchy - thanks to @nitishr (#381)
84
+ * Simplify `ClassMethods#method_exists?` & `ObjectMethods#method_exists?` making them consistent - thanks to @nitishr (#270, #362, #370)
85
+ * Don't override definition of `singleton_class` in `ClassMethods` - thanks to @nitishr (#391, #392)
86
+ * Do not include 'method_definer' methods into all objects (#268, #402)
87
+ * Distinguish different `ObjectMethods` modules (#268, #404)
88
+ * Pass invocation to expectation list methods - thanks to @nitishr (#408, #409, #411)
89
+ * Consistently use `assert_raises` - thanks to @nitishr (#405, #412, a66b7bed)
90
+ * Update Ruby & JRuby versions in Travis CI config (18cb1a93, eb061c53)
91
+ * Rubocop improvements (aa16ea67...6f4db70b, 2a1240e6...e95716ae)
92
+ * Fix inconsistency in CardinalityTest (aa10e0a8)
93
+ * Fix test failures on Mac OSX Catalina - thanks to @nitishr (#413, #417, #419, 8a0f2535)
94
+ * Remove default argument in `Expectation#invoke` - thanks to @nitishr (#414, #420)
95
+
3
96
  ## 1.9.0
4
97
 
5
98
  * Add TruffleRuby to Travis CI build matrix - thanks to @deepj (#354)
data/Rakefile CHANGED
@@ -17,7 +17,7 @@ task 'test' do
17
17
  end
18
18
  end
19
19
 
20
- namespace 'test' do
20
+ namespace 'test' do # rubocop:disable Metrics/BlockLength
21
21
  unit_tests = FileList['test/unit/**/*_test.rb']
22
22
  all_acceptance_tests = FileList['test/acceptance/*_test.rb']
23
23
  ruby186_incompatible_acceptance_tests = FileList['test/acceptance/stub_class_method_defined_on_*_test.rb'] + FileList['test/acceptance/stub_instance_method_defined_on_*_test.rb']
@@ -85,13 +85,14 @@ end
85
85
 
86
86
  begin
87
87
  require 'rubocop/rake_task'
88
- if RUBY_VERSION >= '2.2.0'
88
+ if RUBY_VERSION >= '2.2.0' && (defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ruby') && ENV['MOCHA_RUN_INTEGRATION_TESTS'].nil?
89
89
  RuboCop::RakeTask.new
90
90
  task 'test' => 'rubocop'
91
91
  end
92
92
  rescue LoadError # rubocop:disable Lint/HandleExceptions
93
93
  end
94
94
 
95
+ # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
95
96
  def benchmark_test_case(klass, iterations)
96
97
  require 'benchmark'
97
98
  require 'mocha/detection/mini_test'
@@ -119,6 +120,7 @@ def benchmark_test_case(klass, iterations)
119
120
  Benchmark.realtime { iterations.times { Test::Unit::UI::Console::TestRunner.run(klass, @silent_option) } }
120
121
  end
121
122
  end
123
+ # rubocop:enable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
122
124
 
123
125
  if ENV['MOCHA_GENERATE_DOCS']
124
126
  require 'yard'
@@ -136,14 +138,15 @@ if ENV['MOCHA_GENERATE_DOCS']
136
138
 
137
139
  desc 'Generate documentation'
138
140
  YARD::Rake::YardocTask.new('yardoc' => 'docs_environment') do |task|
139
- task.options = [
140
- '--title', "Mocha #{Mocha::VERSION}",
141
- '--output-dir', 'docs'
142
- ]
141
+ task.options = ['--title', "Mocha #{Mocha::VERSION}"]
142
+ end
143
+
144
+ task 'checkout_docs_cname' do
145
+ `git checkout docs/CNAME`
143
146
  end
144
147
 
145
148
  desc 'Generate documentation'
146
- task 'generate_docs' => %w[clobber_yardoc yardoc]
149
+ task 'generate_docs' => %w[clobber_yardoc yardoc checkout_docs_cname]
147
150
  end
148
151
 
149
152
  task 'release' => 'default'
@@ -0,0 +1 @@
1
+ mocha.jamesmead.org
@@ -6,7 +6,7 @@
6
6
  <title>
7
7
  Module: Mocha
8
8
 
9
- &mdash; Mocha 1.9.0
9
+ &mdash; Mocha 1.11.1
10
10
 
11
11
  </title>
12
12
 
@@ -79,7 +79,7 @@
79
79
  <dl>
80
80
  <dt>Defined in:</dt>
81
81
  <dd>lib/mocha/api.rb<span class="defines">,<br />
82
- lib/mocha/hooks.rb,<br /> lib/mocha/mock.rb,<br /> lib/mocha/expectation.rb,<br /> lib/mocha/object_methods.rb,<br /> lib/mocha/class_methods.rb,<br /> lib/mocha/parameter_matchers.rb,<br /> lib/mocha/parameter_matchers/not.rb,<br /> lib/mocha/parameter_matchers/base.rb,<br /> lib/mocha/parameter_matchers/is_a.rb,<br /> lib/mocha/parameter_matchers/all_of.rb,<br /> lib/mocha/parameter_matchers/any_of.rb,<br /> lib/mocha/parameter_matchers/equals.rb,<br /> lib/mocha/parameter_matchers/object.rb,<br /> lib/mocha/parameter_matchers/has_key.rb,<br /> lib/mocha/parameter_matchers/kind_of.rb,<br /> lib/mocha/parameter_matchers/anything.rb,<br /> lib/mocha/parameter_matchers/includes.rb,<br /> lib/mocha/parameter_matchers/has_entry.rb,<br /> lib/mocha/parameter_matchers/has_value.rb,<br /> lib/mocha/parameter_matchers/optionally.rb,<br /> lib/mocha/parameter_matchers/has_entries.rb,<br /> lib/mocha/parameter_matchers/instance_of.rb,<br /> lib/mocha/parameter_matchers/responds_with.rb,<br /> lib/mocha/parameter_matchers/any_parameters.rb,<br /> lib/mocha/parameter_matchers/equivalent_uri.rb,<br /> lib/mocha/parameter_matchers/regexp_matches.rb,<br /> lib/mocha/parameter_matchers/yaml_equivalent.rb,<br /> lib/mocha/state_machine.rb,<br /> lib/mocha/sequence.rb,<br /> lib/mocha/configuration.rb,<br /> lib/mocha/expectation_error_factory.rb,<br /> lib/mocha/expectation_error.rb,<br /> lib/mocha/stubbing_error.rb,<br /> lib/mocha/unexpected_invocation.rb,<br /> lib/mocha/integration/test_unit/adapter.rb,<br /> lib/mocha/integration/mini_test/adapter.rb</span>
82
+ lib/mocha/hooks.rb,<br /> lib/mocha/mock.rb,<br /> lib/mocha/expectation.rb,<br /> lib/mocha/object_methods.rb,<br /> lib/mocha/class_methods.rb,<br /> lib/mocha/parameter_matchers.rb,<br /> lib/mocha/parameter_matchers/not.rb,<br /> lib/mocha/parameter_matchers/base.rb,<br /> lib/mocha/parameter_matchers/is_a.rb,<br /> lib/mocha/parameter_matchers/all_of.rb,<br /> lib/mocha/parameter_matchers/any_of.rb,<br /> lib/mocha/parameter_matchers/equals.rb,<br /> lib/mocha/parameter_matchers/has_key.rb,<br /> lib/mocha/parameter_matchers/kind_of.rb,<br /> lib/mocha/parameter_matchers/anything.rb,<br /> lib/mocha/parameter_matchers/includes.rb,<br /> lib/mocha/parameter_matchers/has_entry.rb,<br /> lib/mocha/parameter_matchers/has_value.rb,<br /> lib/mocha/parameter_matchers/optionally.rb,<br /> lib/mocha/parameter_matchers/has_entries.rb,<br /> lib/mocha/parameter_matchers/instance_of.rb,<br /> lib/mocha/parameter_matchers/responds_with.rb,<br /> lib/mocha/parameter_matchers/any_parameters.rb,<br /> lib/mocha/parameter_matchers/equivalent_uri.rb,<br /> lib/mocha/parameter_matchers/regexp_matches.rb,<br /> lib/mocha/parameter_matchers/yaml_equivalent.rb,<br /> lib/mocha/parameter_matchers/instance_methods.rb,<br /> lib/mocha/state_machine.rb,<br /> lib/mocha/sequence.rb,<br /> lib/mocha/configuration.rb,<br /> lib/mocha/expectation_error_factory.rb,<br /> lib/mocha/expectation_error.rb,<br /> lib/mocha/stubbing_error.rb,<br /> lib/mocha/integration/test_unit/adapter.rb,<br /> lib/mocha/integration/mini_test/adapter.rb</span>
83
83
  </dd>
84
84
  </dl>
85
85
 
@@ -93,7 +93,7 @@
93
93
 
94
94
 
95
95
 
96
- <strong class="classes">Classes:</strong> <span class='object_link'><a href="Mocha/Configuration.html" title="Mocha::Configuration (class)">Configuration</a></span>, <span class='object_link'><a href="Mocha/Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span>, <span class='object_link'><a href="Mocha/ExpectationError.html" title="Mocha::ExpectationError (class)">ExpectationError</a></span>, <span class='object_link'><a href="Mocha/ExpectationErrorFactory.html" title="Mocha::ExpectationErrorFactory (class)">ExpectationErrorFactory</a></span>, <span class='object_link'><a href="Mocha/Mock.html" title="Mocha::Mock (class)">Mock</a></span>, <span class='object_link'><a href="Mocha/Sequence.html" title="Mocha::Sequence (class)">Sequence</a></span>, <span class='object_link'><a href="Mocha/StateMachine.html" title="Mocha::StateMachine (class)">StateMachine</a></span>, <span class='object_link'><a href="Mocha/StubbingError.html" title="Mocha::StubbingError (class)">StubbingError</a></span>, <span class='object_link'><a href="Mocha/UnexpectedInvocation.html" title="Mocha::UnexpectedInvocation (class)">UnexpectedInvocation</a></span>
96
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="Mocha/Configuration.html" title="Mocha::Configuration (class)">Configuration</a></span>, <span class='object_link'><a href="Mocha/Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span>, <span class='object_link'><a href="Mocha/ExpectationError.html" title="Mocha::ExpectationError (class)">ExpectationError</a></span>, <span class='object_link'><a href="Mocha/ExpectationErrorFactory.html" title="Mocha::ExpectationErrorFactory (class)">ExpectationErrorFactory</a></span>, <span class='object_link'><a href="Mocha/Mock.html" title="Mocha::Mock (class)">Mock</a></span>, <span class='object_link'><a href="Mocha/Sequence.html" title="Mocha::Sequence (class)">Sequence</a></span>, <span class='object_link'><a href="Mocha/StateMachine.html" title="Mocha::StateMachine (class)">StateMachine</a></span>, <span class='object_link'><a href="Mocha/StubbingError.html" title="Mocha::StubbingError (class)">StubbingError</a></span>
97
97
 
98
98
 
99
99
  </p>
@@ -104,7 +104,134 @@
104
104
 
105
105
 
106
106
 
107
+
108
+ <h2>
109
+ Class Method Summary
110
+ <small><a href="#" class="summary_toggle">collapse</a></small>
111
+ </h2>
112
+
113
+ <ul class="summary">
114
+
115
+ <li class="public ">
116
+ <span class="summary_signature">
117
+
118
+ <a href="#configure-class_method" title="configure (class method)">.<strong>configure</strong> {|configuration| ... } &#x21d2; Object </a>
119
+
120
+
121
+
122
+ </span>
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+ <span class="summary_desc"><div class='inline'>
133
+ <p>Allows setting of configuration options.</p>
134
+ </div></span>
135
+
136
+ </li>
107
137
 
138
+
139
+ </ul>
140
+
141
+
142
+
143
+
144
+ <div id="class_method_details" class="method_details_list">
145
+ <h2>Class Method Details</h2>
146
+
147
+
148
+ <div class="method_details first">
149
+ <h3 class="signature first" id="configure-class_method">
150
+
151
+ .<strong>configure</strong> {|configuration| ... } &#x21d2; <tt><span class='object_link'>Object</span></tt>
152
+
153
+
154
+
155
+
156
+
157
+ </h3><div class="docstring">
158
+ <div class="discussion">
159
+
160
+ <p>Allows setting of configuration options. See <span class='object_link'><a href="Mocha/Configuration.html" title="Mocha::Configuration (class)">Configuration</a></span> for the available options.</p>
161
+
162
+ <p>Typically the configuration is set globally in a <code>test_helper.rb</code> or <code>spec_helper.rb</code> file.</p>
163
+
164
+
165
+ </div>
166
+ </div>
167
+ <div class="tags">
168
+
169
+ <div class="examples">
170
+ <p class="tag_title">Examples:</p>
171
+
172
+
173
+ <p class="example_title"><div class='inline'>
174
+ <p>Setting multiple configuration options</p>
175
+ </div></p>
176
+
177
+ <pre class="example code"><code><span class='const'><span class='object_link'><a href="" title="Mocha (module)">Mocha</a></span></span><span class='period'>.</span><span class='id identifier rubyid_configure'>configure</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_c'>c</span><span class='op'>|</span>
178
+ <span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_stubbing_method_unnecessarily'>stubbing_method_unnecessarily</span> <span class='op'>=</span> <span class='symbol'>:prevent</span>
179
+ <span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_stubbing_method_on_non_mock_object'>stubbing_method_on_non_mock_object</span> <span class='op'>=</span> <span class='symbol'>:warn</span>
180
+ <span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_stubbing_method_on_nil'>stubbing_method_on_nil</span> <span class='op'>=</span> <span class='symbol'>:allow</span>
181
+ <span class='kw'>end</span></code></pre>
182
+
183
+ </div>
184
+
185
+ <p class="tag_title">Yield Parameters:</p>
186
+ <ul class="yieldparam">
187
+
188
+ <li>
189
+
190
+ <span class='name'>configuration</span>
191
+
192
+
193
+ <span class='type'>(<tt><span class='object_link'><a href="Mocha/Configuration.html" title="Mocha::Configuration (class)">Configuration</a></span></tt>)</span>
194
+
195
+
196
+
197
+ &mdash;
198
+ <div class='inline'>
199
+ <p>the configuration for modification</p>
200
+ </div>
201
+
202
+ </li>
203
+
204
+ </ul>
205
+
206
+ <p class="tag_title">See Also:</p>
207
+ <ul class="see">
208
+
209
+ <li><span class='object_link'><a href="Mocha/Configuration.html" title="Mocha::Configuration (class)">Configuration</a></span></li>
210
+
211
+ </ul>
212
+
213
+ </div><table class="source_code">
214
+ <tr>
215
+ <td>
216
+ <pre class="lines">
217
+
218
+
219
+ 17
220
+ 18
221
+ 19</pre>
222
+ </td>
223
+ <td>
224
+ <pre class="code"><span class="info file"># File 'lib/mocha/configuration.rb', line 17</span>
225
+
226
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_configure'>configure</span>
227
+ <span class='kw'>yield</span> <span class='id identifier rubyid_configuration'>configuration</span>
228
+ <span class='kw'>end</span></pre>
229
+ </td>
230
+ </tr>
231
+ </table>
232
+ </div>
233
+
234
+ </div>
108
235
 
109
236
  <script async src="https://www.googletagmanager.com/gtag/js?id=UA-625523-7"></script>
110
237
  <script>
@@ -117,9 +244,9 @@
117
244
  </div>
118
245
 
119
246
  <div id="footer">
120
- Generated on Mon Jun 17 18:38:43 2019 by
247
+ Generated on Tue Dec 17 12:49:35 2019 by
121
248
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
122
- 0.9.19 (ruby-2.5.3).
249
+ 0.9.20 (ruby-2.6.5).
123
250
  </div>
124
251
 
125
252
  </div>