mocha 1.9.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/.rubocop_todo.yml +7 -30
- data/README.md +30 -11
- data/RELEASE.md +58 -0
- data/Rakefile +9 -3
- data/docs/CNAME +1 -0
- data/docs/Mocha.html +132 -5
- data/docs/Mocha/API.html +313 -216
- data/docs/Mocha/ClassMethods.html +13 -16
- data/docs/Mocha/Configuration.html +931 -174
- data/docs/Mocha/Expectation.html +200 -255
- data/docs/Mocha/ExpectationError.html +5 -10
- data/docs/Mocha/ExpectationErrorFactory.html +9 -18
- data/docs/Mocha/Hooks.html +12 -27
- data/docs/Mocha/Integration.html +3 -3
- data/docs/Mocha/Integration/MiniTest.html +3 -3
- data/docs/Mocha/Integration/MiniTest/Adapter.html +5 -6
- data/docs/Mocha/Integration/TestUnit.html +3 -3
- data/docs/Mocha/Integration/TestUnit/Adapter.html +5 -6
- data/docs/Mocha/Mock.html +202 -162
- data/docs/Mocha/ObjectMethods.html +121 -68
- data/docs/Mocha/ParameterMatchers.html +21 -109
- data/docs/Mocha/ParameterMatchers/AllOf.html +4 -5
- data/docs/Mocha/ParameterMatchers/AnyOf.html +4 -5
- data/docs/Mocha/ParameterMatchers/AnyParameters.html +3 -3
- data/docs/Mocha/ParameterMatchers/Anything.html +3 -3
- data/docs/Mocha/ParameterMatchers/Base.html +8 -15
- data/docs/Mocha/ParameterMatchers/Equals.html +4 -5
- data/docs/Mocha/ParameterMatchers/EquivalentUri.html +3 -3
- data/docs/Mocha/ParameterMatchers/HasEntries.html +4 -5
- data/docs/Mocha/ParameterMatchers/HasEntry.html +4 -5
- data/docs/Mocha/ParameterMatchers/HasKey.html +4 -5
- data/docs/Mocha/ParameterMatchers/HasValue.html +4 -5
- data/docs/Mocha/ParameterMatchers/Includes.html +4 -5
- data/docs/Mocha/ParameterMatchers/InstanceOf.html +4 -5
- data/docs/Mocha/ParameterMatchers/IsA.html +3 -3
- data/docs/Mocha/ParameterMatchers/KindOf.html +4 -5
- data/docs/Mocha/ParameterMatchers/Not.html +4 -5
- data/docs/Mocha/ParameterMatchers/Optionally.html +3 -3
- data/docs/Mocha/ParameterMatchers/RegexpMatches.html +4 -5
- data/docs/Mocha/ParameterMatchers/RespondsWith.html +4 -5
- data/docs/Mocha/ParameterMatchers/YamlEquivalent.html +4 -5
- data/docs/Mocha/Sequence.html +3 -3
- data/docs/Mocha/StateMachine.html +13 -25
- data/docs/Mocha/StateMachine/State.html +4 -5
- data/docs/Mocha/StateMachine/StatePredicate.html +4 -5
- data/docs/Mocha/StubbingError.html +3 -3
- data/docs/_index.html +4 -22
- data/docs/class_list.html +1 -1
- data/docs/file.COPYING.html +3 -3
- data/docs/file.MIT-LICENSE.html +3 -3
- data/docs/file.README.html +36 -14
- data/docs/file.RELEASE.html +72 -3
- data/docs/frames.html +1 -1
- data/docs/index.html +36 -14
- data/docs/method_list.html +96 -40
- data/docs/top-level-namespace.html +3 -3
- data/gemfiles/Gemfile.minitest.5.11.3 +7 -0
- data/init.rb +1 -3
- data/lib/mocha.rb +8 -0
- data/lib/mocha/any_instance_method.rb +9 -25
- data/lib/mocha/api.rb +65 -66
- data/lib/mocha/cardinality.rb +26 -11
- data/lib/mocha/class_methods.rb +17 -15
- data/lib/mocha/configuration.rb +295 -67
- data/lib/mocha/detection/test_unit.rb +1 -3
- data/lib/mocha/exception_raiser.rb +2 -1
- data/lib/mocha/expectation.rb +56 -58
- data/lib/mocha/expectation_error.rb +1 -3
- data/lib/mocha/expectation_list.rb +6 -6
- data/lib/mocha/inspect.rb +28 -26
- data/lib/mocha/instance_method.rb +19 -2
- data/lib/mocha/integration.rb +1 -3
- data/lib/mocha/integration/mini_test.rb +7 -0
- data/lib/mocha/integration/test_unit.rb +7 -0
- data/lib/mocha/invocation.rb +61 -0
- data/lib/mocha/macos_version.rb +5 -0
- data/lib/mocha/minitest.rb +6 -1
- data/lib/mocha/mock.rb +46 -31
- data/lib/mocha/mockery.rb +28 -61
- data/lib/mocha/names.rb +1 -1
- data/lib/mocha/object_methods.rb +13 -19
- data/lib/mocha/parameter_matchers.rb +1 -1
- data/lib/mocha/parameter_matchers/all_of.rb +1 -1
- data/lib/mocha/parameter_matchers/any_of.rb +1 -1
- data/lib/mocha/parameter_matchers/equivalent_uri.rb +0 -9
- data/lib/mocha/parameter_matchers/includes.rb +2 -0
- data/lib/mocha/parameter_matchers/instance_methods.rb +18 -0
- data/lib/mocha/raised_exception.rb +11 -0
- data/lib/mocha/return_values.rb +3 -3
- data/lib/mocha/setup.rb +5 -0
- data/lib/mocha/single_return_value.rb +2 -1
- data/lib/mocha/singleton_class.rb +9 -0
- data/lib/mocha/{class_method.rb → stubbed_method.rb} +23 -43
- data/lib/mocha/test_unit.rb +6 -1
- data/lib/mocha/thrower.rb +2 -1
- data/lib/mocha/thrown_object.rb +12 -0
- data/lib/mocha/version.rb +1 -1
- data/mocha.gemspec +1 -3
- data/test/acceptance/acceptance_test_helper.rb +6 -0
- data/test/acceptance/bug_18914_test.rb +0 -1
- data/test/acceptance/bug_21465_test.rb +0 -1
- data/test/acceptance/bug_21563_test.rb +0 -1
- data/test/acceptance/display_matching_invocations_alongside_expectations_test.rb +69 -0
- data/test/acceptance/exception_rescue_test.rb +1 -2
- data/test/acceptance/expectations_on_multiple_methods_test.rb +0 -1
- data/test/acceptance/expected_invocation_count_test.rb +2 -3
- data/test/acceptance/failure_messages_test.rb +0 -1
- data/test/acceptance/issue_272_test.rb +1 -2
- data/test/acceptance/issue_65_test.rb +0 -1
- data/test/acceptance/issue_70_test.rb +0 -1
- data/test/acceptance/mocha_example_test.rb +0 -1
- data/test/acceptance/mocha_test_result_test.rb +0 -1
- data/test/acceptance/mock_test.rb +47 -6
- data/test/acceptance/mocked_methods_dispatch_test.rb +0 -1
- data/test/acceptance/multiple_expectations_failure_message_test.rb +0 -1
- data/test/acceptance/optional_parameters_test.rb +0 -1
- data/test/acceptance/parameter_matcher_test.rb +0 -1
- data/test/acceptance/partial_mocks_test.rb +0 -1
- data/test/acceptance/prepend_test.rb +0 -1
- data/test/acceptance/prevent_use_of_mocha_outside_test_test.rb +0 -1
- data/test/acceptance/raise_exception_test.rb +0 -1
- data/test/acceptance/return_value_test.rb +0 -1
- data/test/acceptance/sequence_test.rb +0 -1
- data/test/acceptance/states_test.rb +0 -1
- data/test/acceptance/stub_any_instance_method_defined_on_superclass_test.rb +1 -2
- data/test/acceptance/stub_any_instance_method_test.rb +20 -1
- data/test/acceptance/stub_class_method_defined_on_active_record_association_proxy_test.rb +0 -1
- data/test/acceptance/stub_class_method_defined_on_class_test.rb +0 -1
- data/test/acceptance/stub_class_method_defined_on_module_test.rb +0 -1
- data/test/acceptance/stub_class_method_defined_on_superclass_test.rb +1 -2
- data/test/acceptance/stub_everything_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_active_record_association_proxy_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_class_and_aliased_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_class_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_kernel_module_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_module_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_object_class_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_singleton_class_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_superclass_test.rb +0 -1
- data/test/acceptance/stub_method_defined_on_module_and_aliased_test.rb +0 -1
- data/test/acceptance/stub_module_method_test.rb +0 -1
- data/test/acceptance/stub_test.rb +0 -1
- data/test/acceptance/stubba_example_test.rb +0 -1
- data/test/acceptance/stubba_test_result_test.rb +0 -1
- data/test/acceptance/stubbing_error_backtrace_test.rb +4 -5
- data/test/acceptance/stubbing_frozen_object_test.rb +0 -1
- data/test/acceptance/stubbing_method_accepting_block_parameter_test.rb +0 -1
- data/test/acceptance/stubbing_method_unnecessarily_test.rb +5 -5
- data/test/acceptance/stubbing_nil_test.rb +5 -5
- data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +11 -11
- data/test/acceptance/stubbing_non_existent_class_method_test.rb +11 -11
- data/test/acceptance/stubbing_non_existent_instance_method_test.rb +11 -11
- data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +8 -8
- data/test/acceptance/stubbing_non_public_class_method_test.rb +9 -9
- data/test/acceptance/stubbing_non_public_instance_method_test.rb +9 -9
- data/test/acceptance/stubbing_on_non_mock_object_test.rb +5 -5
- data/test/acceptance/stubbing_same_class_method_on_parent_and_child_classes_test.rb +0 -1
- data/test/acceptance/throw_test.rb +0 -1
- data/test/acceptance/unexpected_invocation_test.rb +0 -1
- data/test/acceptance/unstubbing_test.rb +0 -1
- data/test/integration/shared_tests.rb +5 -3
- data/test/method_definer.rb +11 -17
- data/test/test_runner.rb +2 -0
- data/test/unit/any_instance_method_test.rb +41 -40
- data/test/unit/cardinality_test.rb +41 -23
- data/test/unit/central_test.rb +0 -1
- data/test/unit/class_methods_test.rb +1 -1
- data/test/unit/configuration_test.rb +12 -12
- data/test/unit/exception_raiser_test.rb +10 -5
- data/test/unit/expectation_list_test.rb +13 -11
- data/test/unit/expectation_test.rb +88 -103
- data/test/unit/instance_method_test.rb +282 -0
- data/test/unit/mock_test.rb +28 -19
- data/test/unit/mockery_test.rb +8 -11
- data/test/unit/module_methods_test.rb +2 -3
- data/test/unit/object_inspect_test.rb +6 -4
- data/test/unit/object_methods_test.rb +3 -2
- data/test/unit/parameter_matchers/equivalent_uri_test.rb +0 -9
- data/test/unit/parameter_matchers/has_entries_test.rb +1 -1
- data/test/unit/parameter_matchers/has_entry_test.rb +1 -1
- data/test/unit/parameter_matchers/has_key_test.rb +1 -1
- data/test/unit/parameter_matchers/has_value_test.rb +1 -1
- data/test/unit/parameter_matchers/includes_test.rb +1 -1
- data/test/unit/parameter_matchers/responds_with_test.rb +1 -1
- data/test/unit/return_values_test.rb +25 -20
- data/test/unit/single_return_value_test.rb +6 -1
- data/test/unit/thrower_test.rb +7 -2
- metadata +14 -28
- data/docs/Mocha/UnexpectedInvocation.html +0 -140
- data/lib/mocha/mini_test.rb +0 -5
- data/lib/mocha/module_method.rb +0 -6
- data/lib/mocha/module_methods.rb +0 -10
- data/lib/mocha/parameter_matchers/object.rb +0 -15
- data/lib/mocha/standalone.rb +0 -4
- data/lib/mocha/unexpected_invocation.rb +0 -24
- data/lib/mocha_standalone.rb +0 -4
- data/test/acceptance/mock_with_initializer_block_test.rb +0 -56
- data/test/unit/class_method_test.rb +0 -276
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 36e0a4cb730451038106d6246562a358642a6651206ab432e9a57b4f9744ed50
|
|
4
|
+
data.tar.gz: d5094f0893d49a4a3e74b506c887bbb4c2afe18bb7fdefa4a11a63e672799e50
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4cd3f74de8609e8ce4c88ea53a31e590f5d9ba4afdc0626842b85ba9eaf971d5db810b63f3924ea10f0b23f01cfc17e590b49b0169a14d6f9d4f33c64ec0804d
|
|
7
|
+
data.tar.gz: 9d10054c6f3c7288f4e220fbcbfbcf9b86aa5466b6e85e2ad536da649f4468856e3a8c8ac73e491b22bd1665af3ae9fc9e2baa35d37f446308f9f6df5cdb97a3
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
|
@@ -1,49 +1,26 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on
|
|
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:
|
|
9
|
+
# Offense count: 57
|
|
10
10
|
Metrics/AbcSize:
|
|
11
|
-
Max:
|
|
11
|
+
Max: 26
|
|
12
12
|
|
|
13
|
-
# Offense count:
|
|
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:
|
|
23
|
-
|
|
24
|
-
# Offense count: 4
|
|
25
|
-
Metrics/CyclomaticComplexity:
|
|
26
|
-
Max: 9
|
|
16
|
+
Max: 366
|
|
27
17
|
|
|
28
|
-
# Offense count:
|
|
18
|
+
# Offense count: 172
|
|
29
19
|
# Configuration parameters: CountComments.
|
|
30
20
|
Metrics/MethodLength:
|
|
31
21
|
Max: 31
|
|
32
22
|
|
|
33
|
-
# Offense count:
|
|
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/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
|
|
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,63 @@
|
|
|
1
1
|
# Release Notes
|
|
2
2
|
|
|
3
|
+
## 1.10.0
|
|
4
|
+
|
|
5
|
+
* Improve deprecation warning when requiring 'mocha/setup' (388f44d7)
|
|
6
|
+
* Add documentation for Cucumber integration (13ab797b)
|
|
7
|
+
* Add documentation about an undocumented feature of `API#mock`, `API#stub` & `API#stub_everything` being changed (7ed2e4e7, d30c1717)
|
|
8
|
+
|
|
9
|
+
## 1.10.0.beta.1
|
|
10
|
+
|
|
11
|
+
* Hide `ClassMethods#method_visibility` & `#method_exists?` methods to avoid clash with Rails (#428)
|
|
12
|
+
|
|
13
|
+
## 1.10.0.alpha
|
|
14
|
+
|
|
15
|
+
### External changes
|
|
16
|
+
|
|
17
|
+
* Remove dependency on metaclass gem (#49, #365)
|
|
18
|
+
* Accept symbol (as well as a string) as mock/stub name - thanks to @nitishr (#347, #353, #377)
|
|
19
|
+
* More realistic examples in documentation for `Expectation#yields` and `#multiple_yields` - thanks to @nitishr (#352, #383)
|
|
20
|
+
* Improve documentation for `Mock#responds_like` & `#responds_like_instance_of` - thanks to @nitishr (#337, #384)
|
|
21
|
+
* 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)
|
|
22
|
+
* Document `MOCHA_OPTIONS` in README - thanks to @nitishr (#311, #386)
|
|
23
|
+
* Add documentation to explain how Mocha is intended to be used - thanks to @nitishr (#330, #385)
|
|
24
|
+
* Deprecation warning if integration using 'mocha/test_unit' or 'mocha/minitest' fails - thanks to @nitishr (#229, #389, c6032d0b)
|
|
25
|
+
* Require at least one specified sequence for `Expectation#in_sequence` - thanks to @nitishr (#79, #396, 9020248a)
|
|
26
|
+
* Make signatures of `Mock#unstub` & `ObjectMethods#unstub` consistent - thanks to @nitishr (#397, f04d437)
|
|
27
|
+
* Deprecate requiring 'mocha/setup' (36adf880)
|
|
28
|
+
* Optionally display matching invocations alongside expectations - thanks to @nitishr (#178, #394, 00f0540, #410)
|
|
29
|
+
* Put deprecations into effect (#400, #418):
|
|
30
|
+
* Remove deprecated 'mocha_standalone.rb' & 'mocha/standalone.rb'
|
|
31
|
+
* Fail fast if no test library loaded
|
|
32
|
+
* Removed optional block for `Mocha::API#mock`, `#stub` & `#stub_everything`
|
|
33
|
+
* Remove deprecated `ParameterMatchers#has_equivalent_query_string` method
|
|
34
|
+
* Remove deprecated 'mocha/mini_test.rb'
|
|
35
|
+
* Fix typo in docs for `Mocha::Configuration.prevent` (266ce71c)
|
|
36
|
+
* New-style configuration (see documentation for `Mocha::Configuration`) (#407, #421)
|
|
37
|
+
* Deprecate support for Ruby versions earlier than v1.9 (#325, c5f8496d)
|
|
38
|
+
* Deprecate support for versions of test-unit & minitest which need monkey-patching (a34e1a88)
|
|
39
|
+
* Deprecate old-style Rails plugin (#403, 2df77134)
|
|
40
|
+
* Documentation fixes & improvements which also fix YARD warnings (472d5416, a2c0d64a)
|
|
41
|
+
|
|
42
|
+
### Internal changes
|
|
43
|
+
|
|
44
|
+
* Pin minitest to v5.11.3 for Ruby v1.8.7 to fix build; minitest no longer supports Ruby v1.8.7 (4a0a580)
|
|
45
|
+
* Upgrade JRuby to v9.2.8.0 in Travis CI builds (aa29b3f)
|
|
46
|
+
* Only run rubocop for MRI Ruby versions & non-integration test builds (8f1c6af)
|
|
47
|
+
* Reduce duplication in any instance method class - thanks to @nitishr (#378)
|
|
48
|
+
* Simplify `AnyInstanceMethod`, `ClassMethod`, `InstanceMethod`, `ModuleMethod` class hierarchy - thanks to @nitishr (#381)
|
|
49
|
+
* Simplify `ClassMethods#method_exists?` & `ObjectMethods#method_exists?` making them consistent - thanks to @nitishr (#270, #362, #370)
|
|
50
|
+
* Don't override definition of `singleton_class` in `ClassMethods` - thanks to @nitishr (#391, #392)
|
|
51
|
+
* Do not include 'method_definer' methods into all objects (#268, #402)
|
|
52
|
+
* Distinguish different `ObjectMethods` modules (#268, #404)
|
|
53
|
+
* Pass invocation to expectation list methods - thanks to @nitishr (#408, #409, #411)
|
|
54
|
+
* Consistently use `assert_raises` - thanks to @nitishr (#405, #412, a66b7bed)
|
|
55
|
+
* Update Ruby & JRuby versions in Travis CI config (18cb1a93, eb061c53)
|
|
56
|
+
* Rubocop improvements (aa16ea67...6f4db70b, 2a1240e6...e95716ae)
|
|
57
|
+
* Fix inconsistency in CardinalityTest (aa10e0a8)
|
|
58
|
+
* Fix test failures on Mac OSX Catalina - thanks to @nitishr (#413, #417, #419, 8a0f2535)
|
|
59
|
+
* Remove default argument in `Expectation#invoke` - thanks to @nitishr (#414, #420)
|
|
60
|
+
|
|
3
61
|
## 1.9.0
|
|
4
62
|
|
|
5
63
|
* 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'
|
|
@@ -142,8 +144,12 @@ if ENV['MOCHA_GENERATE_DOCS']
|
|
|
142
144
|
]
|
|
143
145
|
end
|
|
144
146
|
|
|
147
|
+
task 'checkout_docs_cname' do
|
|
148
|
+
`git checkout docs/CNAME`
|
|
149
|
+
end
|
|
150
|
+
|
|
145
151
|
desc 'Generate documentation'
|
|
146
|
-
task 'generate_docs' => %w[clobber_yardoc yardoc]
|
|
152
|
+
task 'generate_docs' => %w[clobber_yardoc yardoc checkout_docs_cname]
|
|
147
153
|
end
|
|
148
154
|
|
|
149
155
|
task 'release' => 'default'
|
data/docs/CNAME
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mocha.jamesmead.org
|
data/docs/Mocha.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<title>
|
|
7
7
|
Module: Mocha
|
|
8
8
|
|
|
9
|
-
— Mocha 1.
|
|
9
|
+
— Mocha 1.10.0
|
|
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/
|
|
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
|
|
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| ... } ⇒ 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| ... } ⇒ <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
|
+
—
|
|
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
|
|
247
|
+
Generated on Mon Dec 2 17:48:40 2019 by
|
|
121
248
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
122
|
-
0.9.
|
|
249
|
+
0.9.20 (ruby-2.6.5).
|
|
123
250
|
</div>
|
|
124
251
|
|
|
125
252
|
</div>
|