mocha 1.9.0 → 1.10.0.alpha
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 +10 -11
- data/RELEASE.md +48 -0
- data/Rakefile +9 -3
- data/docs/CNAME +1 -0
- data/docs/Mocha.html +132 -5
- data/docs/Mocha/API.html +289 -216
- data/docs/Mocha/ClassMethods.html +88 -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 +18 -15
- data/docs/file.RELEASE.html +58 -3
- data/docs/frames.html +1 -1
- data/docs/index.html +18 -15
- data/docs/method_list.html +103 -39
- 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 +62 -66
- data/lib/mocha/cardinality.rb +26 -11
- data/lib/mocha/class_methods.rb +16 -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 +16 -30
- 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: 17067ef2117df2bcf63d40f8e764f28d584a5e6243e40d42533a571532329c43
|
|
4
|
+
data.tar.gz: c2ce2f9b3ca8950dc8fa8958a106bac339f3a96018849c50954ac4b53f024893
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c40927eb7a63d40a2fd77676e5a3c2362d20f3e0601386c3e848f96d631d1ee1101d46619ed8a3f1fea952e3d9a56f0cc9205fe94b115866358bac2baadf3958
|
|
7
|
+
data.tar.gz: ce24527412963c7c89611d2517ee20790e01efa4dafa5b3c0f6229b7993baaf5c8db2b7e49b378f65d61070390ab0ccf797f7b1cbf1bcfa3ba98f363b6473e21
|
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
|
|
@@ -115,7 +110,6 @@ require 'mocha/minitest'
|
|
|
115
110
|
* 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
111
|
* 0.11.x versions don't work with Rails 3.2.13 (`TypeError: superclass mismatch for class ExpectationError`). See #115.
|
|
117
112
|
* 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
113
|
|
|
120
114
|
### Usage
|
|
121
115
|
|
|
@@ -285,6 +279,11 @@ If you want, Mocha can generate a warning or raise an exception when:
|
|
|
285
279
|
|
|
286
280
|
See the [documentation](https://mocha.jamesmead.org/Mocha/Configuration.html) for `Mocha::Configuration` for further details.
|
|
287
281
|
|
|
282
|
+
##### MOCHA_OPTIONS
|
|
283
|
+
`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`.
|
|
284
|
+
Only the following values are currently recognized and have an effect:
|
|
285
|
+
* `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.
|
|
286
|
+
|
|
288
287
|
### Useful Links
|
|
289
288
|
|
|
290
289
|
* [Official Documentation](https://mocha.jamesmead.org)
|
|
@@ -309,7 +308,7 @@ See this [list of contributors](https://github.com/freerange/mocha/graphs/contri
|
|
|
309
308
|
* Check Travis CI build is passing - https://travis-ci.org/freerange/mocha
|
|
310
309
|
|
|
311
310
|
* Sign in to Google Analytics - https://analytics.google.com/analytics/web/
|
|
312
|
-
* Find the web property ID for
|
|
311
|
+
* Find the web property ID for floehopper (625523) > Mocha Documentation (UA-625523-7)
|
|
313
312
|
* Generate documentation:
|
|
314
313
|
|
|
315
314
|
```bash
|
data/RELEASE.md
CHANGED
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
# Release Notes
|
|
2
2
|
|
|
3
|
+
## 1.10.0.alpha
|
|
4
|
+
|
|
5
|
+
### External changes
|
|
6
|
+
|
|
7
|
+
* Remove dependency on metaclass gem (#49, #365)
|
|
8
|
+
* Accept symbol (as well as a string) as mock/stub name - thanks to @nitishr (#347, #353, #377)
|
|
9
|
+
* More realistic examples in documentation for `Expectation#yields` and `#multiple_yields` - thanks to @nitishr (#352, #383)
|
|
10
|
+
* Improve documentation for `Mock#responds_like` & `#responds_like_instance_of` - thanks to @nitishr (#337, #384)
|
|
11
|
+
* 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)
|
|
12
|
+
* Document `MOCHA_OPTIONS` in README - thanks to @nitishr (#311, #386)
|
|
13
|
+
* Add documentation to explain how Mocha is intended to be used - thanks to @nitishr (#330, #385)
|
|
14
|
+
* Deprecation warning if integration using 'mocha/test_unit' or 'mocha/minitest' fails - thanks to @nitishr (#229, #389, c6032d0b)
|
|
15
|
+
* Require at least one specified sequence for `Expectation#in_sequence` - thanks to @nitishr (#79, #396, 9020248a)
|
|
16
|
+
* Make signatures of `Mock#unstub` & `ObjectMethods#unstub` consistent - thanks to @nitishr (#397, f04d437)
|
|
17
|
+
* Deprecate requiring 'mocha/setup' (36adf880)
|
|
18
|
+
* Optionally display matching invocations alongside expectations - thanks to @nitishr (#178, #394, 00f0540, #410)
|
|
19
|
+
* Put deprecations into effect (#400, #418):
|
|
20
|
+
* Remove deprecated 'mocha_standalone.rb' & 'mocha/standalone.rb'
|
|
21
|
+
* Fail fast if no test library loaded
|
|
22
|
+
* Removed optional block for `Mocha::API#mock`, `#stub` & `#stub_everything`
|
|
23
|
+
* Remove deprecated `ParameterMatchers#has_equivalent_query_string` method
|
|
24
|
+
* Remove deprecated 'mocha/mini_test.rb'
|
|
25
|
+
* Fix typo in docs for `Mocha::Configuration.prevent` (266ce71c)
|
|
26
|
+
* New-style configuration (see documentation for `Mocha::Configuration`) (#407, #421)
|
|
27
|
+
* Deprecate support for Ruby versions earlier than v1.9 (#325, c5f8496d)
|
|
28
|
+
* Deprecate support for versions of test-unit & minitest which need monkey-patching (a34e1a88)
|
|
29
|
+
* Deprecate old-style Rails plugin (#403, 2df77134)
|
|
30
|
+
* Documentation fixes & improvements which also fix YARD warnings (472d5416, a2c0d64a)
|
|
31
|
+
|
|
32
|
+
### Internal changes
|
|
33
|
+
|
|
34
|
+
* Pin minitest to v5.11.3 for Ruby v1.8.7 to fix build; minitest no longer supports Ruby v1.8.7 (4a0a580)
|
|
35
|
+
* Upgrade JRuby to v9.2.8.0 in Travis CI builds (aa29b3f)
|
|
36
|
+
* Only run rubocop for MRI Ruby versions & non-integration test builds (8f1c6af)
|
|
37
|
+
* Reduce duplication in any instance method class - thanks to @nitishr (#378)
|
|
38
|
+
* Simplify `AnyInstanceMethod`, `ClassMethod`, `InstanceMethod`, `ModuleMethod` class hierarchy - thanks to @nitishr (#381)
|
|
39
|
+
* Simplify `ClassMethods#method_exists?` & `ObjectMethods#method_exists?` making them consistent - thanks to @nitishr (#270, #362, #370)
|
|
40
|
+
* Don't override definition of `singleton_class` in `ClassMethods` - thanks to @nitishr (#391, #392)
|
|
41
|
+
* Do not include 'method_definer' methods into all objects (#268, #402)
|
|
42
|
+
* Distinguish different `ObjectMethods` modules (#268, #404)
|
|
43
|
+
* Pass invocation to expectation list methods - thanks to @nitishr (#408, #409, #411)
|
|
44
|
+
* Consistently use `assert_raises` - thanks to @nitishr (#405, #412, a66b7bed)
|
|
45
|
+
* Update Ruby & JRuby versions in Travis CI config (18cb1a93, eb061c53)
|
|
46
|
+
* Rubocop improvements (aa16ea67...6f4db70b, 2a1240e6...e95716ae)
|
|
47
|
+
* Fix inconsistency in CardinalityTest (aa10e0a8)
|
|
48
|
+
* Fix test failures on Mac OSX Catalina - thanks to @nitishr (#413, #417, #419, 8a0f2535)
|
|
49
|
+
* Remove default argument in `Expectation#invoke` - thanks to @nitishr (#414, #420)
|
|
50
|
+
|
|
3
51
|
## 1.9.0
|
|
4
52
|
|
|
5
53
|
* 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.alpha
|
|
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
|
|
247
|
+
Generated on Sun Nov 24 15:26:48 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>
|
data/docs/Mocha/API.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<title>
|
|
7
7
|
Module: Mocha::API
|
|
8
8
|
|
|
9
|
-
— Mocha 1.
|
|
9
|
+
— Mocha 1.10.0.alpha
|
|
10
10
|
|
|
11
11
|
</title>
|
|
12
12
|
|
|
@@ -96,14 +96,40 @@
|
|
|
96
96
|
<h2>Overview</h2><div class="docstring">
|
|
97
97
|
<div class="discussion">
|
|
98
98
|
|
|
99
|
-
<p>Methods added to <code>Test::Unit::TestCase</code>,
|
|
100
|
-
|
|
99
|
+
<p>Methods added to <code>Test::Unit::TestCase</code>, <code>MiniTest::Unit::TestCase</code> or equivalent. The mock creation methods are <span class='object_link'><a href="#mock-instance_method" title="Mocha::API#mock (method)">#mock</a></span>, <span class='object_link'><a href="#stub-instance_method" title="Mocha::API#stub (method)">#stub</a></span> and <span class='object_link'><a href="#stub_everything-instance_method" title="Mocha::API#stub_everything (method)">#stub_everything</a></span>, all of which return a #<span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span> which can be further modified by <span class='object_link'><a href="Mock.html#responds_like-instance_method" title="Mocha::Mock#responds_like (method)">Mock#responds_like</a></span> and <span class='object_link'><a href="Mock.html#responds_like_instance_of-instance_method" title="Mocha::Mock#responds_like_instance_of (method)">Mock#responds_like_instance_of</a></span> methods, both of which return a <span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span>, too, and can therefore, be chained to the original creation methods.</p>
|
|
100
|
+
|
|
101
|
+
<p><span class='object_link'><a href="Mock.html#responds_like-instance_method" title="Mocha::Mock#responds_like (method)">Mock#responds_like</a></span> and <span class='object_link'><a href="Mock.html#responds_like_instance_of-instance_method" title="Mocha::Mock#responds_like_instance_of (method)">Mock#responds_like_instance_of</a></span> force the mock to indicate what it is supposed to be mocking, thus making it a safer verifying mock. They check that the underlying <code>responder</code> will actually respond to the methods being stubbed, throwing a <code>NoMethodError</code> upon invocation otherwise.</p>
|
|
101
102
|
|
|
102
103
|
|
|
103
104
|
</div>
|
|
104
105
|
</div>
|
|
105
106
|
<div class="tags">
|
|
106
107
|
|
|
108
|
+
<div class="examples">
|
|
109
|
+
<p class="tag_title">Examples:</p>
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
<p class="example_title"><div class='inline'>
|
|
113
|
+
<p>Verifying mock using <span class='object_link'><a href="Mock.html#responds_like_instance_of-instance_method" title="Mocha::Mock#responds_like_instance_of (method)">Mock#responds_like_instance_of</a></span></p>
|
|
114
|
+
</div></p>
|
|
115
|
+
|
|
116
|
+
<pre class="example code"><code><span class='kw'>class</span> <span class='const'>Sheep</span>
|
|
117
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span>
|
|
118
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>some awkward code we don't want to call</span><span class='tstring_end'>"</span></span>
|
|
119
|
+
<span class='kw'>end</span>
|
|
120
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_chew'>chew</span><span class='lparen'>(</span><span class='id identifier rubyid_grass'>grass</span><span class='rparen'>)</span><span class='semicolon'>;</span> <span class='kw'>end</span>
|
|
121
|
+
<span class='kw'>end</span>
|
|
122
|
+
|
|
123
|
+
<span class='id identifier rubyid_sheep'>sheep</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>sheep</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_responds_like_instance_of'>responds_like_instance_of</span><span class='lparen'>(</span><span class='const'>Sheep</span><span class='rparen'>)</span>
|
|
124
|
+
<span class='id identifier rubyid_sheep'>sheep</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:chew</span><span class='rparen'>)</span>
|
|
125
|
+
<span class='id identifier rubyid_sheep'>sheep</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:foo</span><span class='rparen'>)</span>
|
|
126
|
+
<span class='id identifier rubyid_sheep'>sheep</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:chew</span><span class='rparen'>)</span> <span class='comment'># => true
|
|
127
|
+
</span><span class='id identifier rubyid_sheep'>sheep</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:foo</span><span class='rparen'>)</span> <span class='comment'># => false
|
|
128
|
+
</span><span class='id identifier rubyid_sheep'>sheep</span><span class='period'>.</span><span class='id identifier rubyid_chew'>chew</span>
|
|
129
|
+
<span class='id identifier rubyid_sheep'>sheep</span><span class='period'>.</span><span class='id identifier rubyid_foo'>foo</span> <span class='comment'># => raises NoMethodError exception</span></code></pre>
|
|
130
|
+
|
|
131
|
+
</div>
|
|
132
|
+
|
|
107
133
|
|
|
108
134
|
</div>
|
|
109
135
|
|
|
@@ -123,7 +149,7 @@
|
|
|
123
149
|
<li class="public ">
|
|
124
150
|
<span class="summary_signature">
|
|
125
151
|
|
|
126
|
-
<a href="#mock-instance_method" title="#mock (instance method)">#<strong>mock</strong>(*arguments)
|
|
152
|
+
<a href="#mock-instance_method" title="#mock (instance method)">#<strong>mock</strong>(*arguments) ⇒ Mock </a>
|
|
127
153
|
|
|
128
154
|
|
|
129
155
|
|
|
@@ -162,8 +188,7 @@
|
|
|
162
188
|
|
|
163
189
|
|
|
164
190
|
<span class="summary_desc"><div class='inline'>
|
|
165
|
-
<p>Builds a new sequence which can be used to constrain the order in which
|
|
166
|
-
expectations can occur.</p>
|
|
191
|
+
<p>Builds a new sequence which can be used to constrain the order in which expectations can occur.</p>
|
|
167
192
|
</div></span>
|
|
168
193
|
|
|
169
194
|
</li>
|
|
@@ -187,8 +212,7 @@ expectations can occur.</p>
|
|
|
187
212
|
|
|
188
213
|
|
|
189
214
|
<span class="summary_desc"><div class='inline'>
|
|
190
|
-
<p>Builds a new state machine which can be used to constrain the order in
|
|
191
|
-
which expectations can occur.</p>
|
|
215
|
+
<p>Builds a new state machine which can be used to constrain the order in which expectations can occur.</p>
|
|
192
216
|
</div></span>
|
|
193
217
|
|
|
194
218
|
</li>
|
|
@@ -197,7 +221,7 @@ which expectations can occur.</p>
|
|
|
197
221
|
<li class="public ">
|
|
198
222
|
<span class="summary_signature">
|
|
199
223
|
|
|
200
|
-
<a href="#stub-instance_method" title="#stub (instance method)">#<strong>stub</strong>(*arguments)
|
|
224
|
+
<a href="#stub-instance_method" title="#stub (instance method)">#<strong>stub</strong>(*arguments) ⇒ Mock </a>
|
|
201
225
|
|
|
202
226
|
|
|
203
227
|
|
|
@@ -221,7 +245,7 @@ which expectations can occur.</p>
|
|
|
221
245
|
<li class="public ">
|
|
222
246
|
<span class="summary_signature">
|
|
223
247
|
|
|
224
|
-
<a href="#stub_everything-instance_method" title="#stub_everything (instance method)">#<strong>stub_everything</strong>(*arguments)
|
|
248
|
+
<a href="#stub_everything-instance_method" title="#stub_everything (instance method)">#<strong>stub_everything</strong>(*arguments) ⇒ Mock </a>
|
|
225
249
|
|
|
226
250
|
|
|
227
251
|
|
|
@@ -266,7 +290,7 @@ which expectations can occur.</p>
|
|
|
266
290
|
|
|
267
291
|
|
|
268
292
|
<h3 class="inherited">Methods included from <span class='object_link'><a href="ParameterMatchers.html" title="Mocha::ParameterMatchers (module)">ParameterMatchers</a></span></h3>
|
|
269
|
-
<p class="inherited"><span class='object_link'><a href="ParameterMatchers.html#Not-instance_method" title="Mocha::ParameterMatchers#Not (method)">#Not</a></span>, <span class='object_link'><a href="ParameterMatchers.html#all_of-instance_method" title="Mocha::ParameterMatchers#all_of (method)">#all_of</a></span>, <span class='object_link'><a href="ParameterMatchers.html#any_of-instance_method" title="Mocha::ParameterMatchers#any_of (method)">#any_of</a></span>, <span class='object_link'><a href="ParameterMatchers.html#any_parameters-instance_method" title="Mocha::ParameterMatchers#any_parameters (method)">#any_parameters</a></span>, <span class='object_link'><a href="ParameterMatchers.html#anything-instance_method" title="Mocha::ParameterMatchers#anything (method)">#anything</a></span>, <span class='object_link'><a href="ParameterMatchers.html#equals-instance_method" title="Mocha::ParameterMatchers#equals (method)">#equals</a></span>, <span class='object_link'><a href="ParameterMatchers.html#equivalent_uri-instance_method" title="Mocha::ParameterMatchers#equivalent_uri (method)">#equivalent_uri</a></span>, <span class='object_link'><a href="ParameterMatchers.html#has_entries-instance_method" title="Mocha::ParameterMatchers#has_entries (method)">#has_entries</a></span>, <span class='object_link'><a href="ParameterMatchers.html#has_entry-instance_method" title="Mocha::ParameterMatchers#has_entry (method)">#has_entry</a></span>, <span class='object_link'><a href="ParameterMatchers.html#
|
|
293
|
+
<p class="inherited"><span class='object_link'><a href="ParameterMatchers.html#Not-instance_method" title="Mocha::ParameterMatchers#Not (method)">#Not</a></span>, <span class='object_link'><a href="ParameterMatchers.html#all_of-instance_method" title="Mocha::ParameterMatchers#all_of (method)">#all_of</a></span>, <span class='object_link'><a href="ParameterMatchers.html#any_of-instance_method" title="Mocha::ParameterMatchers#any_of (method)">#any_of</a></span>, <span class='object_link'><a href="ParameterMatchers.html#any_parameters-instance_method" title="Mocha::ParameterMatchers#any_parameters (method)">#any_parameters</a></span>, <span class='object_link'><a href="ParameterMatchers.html#anything-instance_method" title="Mocha::ParameterMatchers#anything (method)">#anything</a></span>, <span class='object_link'><a href="ParameterMatchers.html#equals-instance_method" title="Mocha::ParameterMatchers#equals (method)">#equals</a></span>, <span class='object_link'><a href="ParameterMatchers.html#equivalent_uri-instance_method" title="Mocha::ParameterMatchers#equivalent_uri (method)">#equivalent_uri</a></span>, <span class='object_link'><a href="ParameterMatchers.html#has_entries-instance_method" title="Mocha::ParameterMatchers#has_entries (method)">#has_entries</a></span>, <span class='object_link'><a href="ParameterMatchers.html#has_entry-instance_method" title="Mocha::ParameterMatchers#has_entry (method)">#has_entry</a></span>, <span class='object_link'><a href="ParameterMatchers.html#has_key-instance_method" title="Mocha::ParameterMatchers#has_key (method)">#has_key</a></span>, <span class='object_link'><a href="ParameterMatchers.html#has_value-instance_method" title="Mocha::ParameterMatchers#has_value (method)">#has_value</a></span>, <span class='object_link'><a href="ParameterMatchers.html#includes-instance_method" title="Mocha::ParameterMatchers#includes (method)">#includes</a></span>, <span class='object_link'><a href="ParameterMatchers.html#instance_of-instance_method" title="Mocha::ParameterMatchers#instance_of (method)">#instance_of</a></span>, <span class='object_link'><a href="ParameterMatchers.html#is_a-instance_method" title="Mocha::ParameterMatchers#is_a (method)">#is_a</a></span>, <span class='object_link'><a href="ParameterMatchers.html#kind_of-instance_method" title="Mocha::ParameterMatchers#kind_of (method)">#kind_of</a></span>, <span class='object_link'><a href="ParameterMatchers.html#optionally-instance_method" title="Mocha::ParameterMatchers#optionally (method)">#optionally</a></span>, <span class='object_link'><a href="ParameterMatchers.html#regexp_matches-instance_method" title="Mocha::ParameterMatchers#regexp_matches (method)">#regexp_matches</a></span>, <span class='object_link'><a href="ParameterMatchers.html#responds_with-instance_method" title="Mocha::ParameterMatchers#responds_with (method)">#responds_with</a></span>, <span class='object_link'><a href="ParameterMatchers.html#yaml_equivalent-instance_method" title="Mocha::ParameterMatchers#yaml_equivalent (method)">#yaml_equivalent</a></span></p>
|
|
270
294
|
|
|
271
295
|
|
|
272
296
|
<div id="instance_method_details" class="method_details_list">
|
|
@@ -277,11 +301,11 @@ which expectations can occur.</p>
|
|
|
277
301
|
<h3 class="signature first" id="mock-instance_method">
|
|
278
302
|
|
|
279
303
|
|
|
280
|
-
<span class="overload">#<strong>mock</strong>(name
|
|
304
|
+
<span class="overload">#<strong>mock</strong>(name) ⇒ <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
|
|
281
305
|
|
|
282
|
-
<span class="overload">#<strong>mock</strong>(expected_methods_vs_return_values = {}
|
|
306
|
+
<span class="overload">#<strong>mock</strong>(expected_methods_vs_return_values = {}) ⇒ <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
|
|
283
307
|
|
|
284
|
-
<span class="overload">#<strong>mock</strong>(name, expected_methods_vs_return_values = {}
|
|
308
|
+
<span class="overload">#<strong>mock</strong>(name, expected_methods_vs_return_values = {}) ⇒ <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
|
|
285
309
|
|
|
286
310
|
|
|
287
311
|
|
|
@@ -313,24 +337,22 @@ which expectations can occur.</p>
|
|
|
313
337
|
<span class='comment'># an error will be raised unless both Motor#start and Motor#stop have been called
|
|
314
338
|
</span><span class='kw'>end</span></code></pre>
|
|
315
339
|
|
|
340
|
+
</div>
|
|
341
|
+
|
|
342
|
+
<p class="tag_title">Overloads:</p>
|
|
343
|
+
<ul class="overload">
|
|
344
|
+
|
|
316
345
|
|
|
317
|
-
|
|
318
|
-
<
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
<pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_test_motor_starts_and_stops'>test_motor_starts_and_stops</span>
|
|
323
|
-
<span class='id identifier rubyid_motor'>motor</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>motor</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='kw'>do</span>
|
|
324
|
-
<span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:start</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='int'>100</span><span class='period'>.</span><span class='id identifier rubyid_rpm'>rpm</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_returns'>returns</span><span class='lparen'>(</span><span class='kw'>true</span><span class='rparen'>)</span>
|
|
325
|
-
<span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='symbol'>:stop</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_returns'>returns</span><span class='lparen'>(</span><span class='kw'>true</span><span class='rparen'>)</span>
|
|
326
|
-
<span class='kw'>end</span>
|
|
327
|
-
<span class='id identifier rubyid_assert'>assert</span> <span class='id identifier rubyid_motor'>motor</span><span class='period'>.</span><span class='id identifier rubyid_start'>start</span><span class='lparen'>(</span><span class='int'>100</span><span class='period'>.</span><span class='id identifier rubyid_rpm'>rpm</span><span class='rparen'>)</span>
|
|
328
|
-
<span class='id identifier rubyid_assert'>assert</span> <span class='id identifier rubyid_motor'>motor</span><span class='period'>.</span><span class='id identifier rubyid_stop'>stop</span>
|
|
329
|
-
<span class='comment'># an error will only be raised if Motor#start(100.rpm) has not been called
|
|
330
|
-
</span><span class='kw'>end</span></code></pre>
|
|
346
|
+
<li class="overload_item">
|
|
347
|
+
<span class="signature">#<strong>mock</strong>(name) ⇒ <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
|
|
348
|
+
<div class="docstring">
|
|
349
|
+
<div class="discussion">
|
|
331
350
|
|
|
351
|
+
|
|
332
352
|
</div>
|
|
333
|
-
|
|
353
|
+
</div>
|
|
354
|
+
<div class="tags">
|
|
355
|
+
<p class="tag_title">Parameters:</p>
|
|
334
356
|
<ul class="param">
|
|
335
357
|
|
|
336
358
|
<li>
|
|
@@ -338,7 +360,7 @@ which expectations can occur.</p>
|
|
|
338
360
|
<span class='name'>name</span>
|
|
339
361
|
|
|
340
362
|
|
|
341
|
-
<span class='type'>(<tt>String</tt>)</span>
|
|
363
|
+
<span class='type'>(<tt>String</tt>, <tt>Symbol</tt>)</span>
|
|
342
364
|
|
|
343
365
|
|
|
344
366
|
|
|
@@ -349,6 +371,25 @@ which expectations can occur.</p>
|
|
|
349
371
|
|
|
350
372
|
</li>
|
|
351
373
|
|
|
374
|
+
</ul>
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
</div>
|
|
378
|
+
</li>
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
<li class="overload_item">
|
|
382
|
+
<span class="signature">#<strong>mock</strong>(expected_methods_vs_return_values = {}) ⇒ <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
|
|
383
|
+
<div class="docstring">
|
|
384
|
+
<div class="discussion">
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
</div>
|
|
388
|
+
</div>
|
|
389
|
+
<div class="tags">
|
|
390
|
+
<p class="tag_title">Parameters:</p>
|
|
391
|
+
<ul class="param">
|
|
392
|
+
|
|
352
393
|
<li>
|
|
353
394
|
|
|
354
395
|
<span class='name'>expected_methods_vs_return_values</span>
|
|
@@ -357,68 +398,77 @@ which expectations can occur.</p>
|
|
|
357
398
|
<span class='type'>(<tt>Hash</tt>)</span>
|
|
358
399
|
|
|
359
400
|
|
|
401
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
|
402
|
+
|
|
360
403
|
|
|
361
404
|
—
|
|
362
405
|
<div class='inline'>
|
|
363
|
-
<p>expected method name symbols as keys and corresponding return values as
|
|
364
|
-
values - these expectations are setup as if <span class='object_link'><a href="Mock.html#expects-instance_method" title="Mocha::Mock#expects (method)">Mock#expects</a></span> were called
|
|
365
|
-
multiple times.</p>
|
|
406
|
+
<p>expected method name symbols as keys and corresponding return values as values - these expectations are setup as if <span class='object_link'><a href="Mock.html#expects-instance_method" title="Mocha::Mock#expects (method)">Mock#expects</a></span> were called multiple times.</p>
|
|
366
407
|
</div>
|
|
367
408
|
|
|
368
409
|
</li>
|
|
369
410
|
|
|
370
411
|
</ul>
|
|
371
412
|
|
|
372
|
-
|
|
373
|
-
<ul class="yield">
|
|
374
|
-
|
|
375
|
-
<li>
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
<span class='type'></span>
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
<div class='inline'>
|
|
384
|
-
<p>optional block to be evaluated in the context of the mock object instance,
|
|
385
|
-
giving an alternative way to setup stubbed methods.</p>
|
|
413
|
+
|
|
386
414
|
</div>
|
|
415
|
+
</li>
|
|
416
|
+
|
|
387
417
|
|
|
388
|
-
|
|
418
|
+
<li class="overload_item">
|
|
419
|
+
<span class="signature">#<strong>mock</strong>(name, expected_methods_vs_return_values = {}) ⇒ <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
|
|
420
|
+
<div class="docstring">
|
|
421
|
+
<div class="discussion">
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
</div>
|
|
425
|
+
</div>
|
|
426
|
+
<div class="tags">
|
|
427
|
+
<p class="tag_title">Parameters:</p>
|
|
428
|
+
<ul class="param">
|
|
389
429
|
|
|
390
430
|
<li>
|
|
391
431
|
|
|
432
|
+
<span class='name'>name</span>
|
|
433
|
+
|
|
392
434
|
|
|
393
|
-
<span class='type'
|
|
435
|
+
<span class='type'>(<tt>String</tt>, <tt>Symbol</tt>)</span>
|
|
394
436
|
|
|
395
437
|
|
|
396
438
|
|
|
397
|
-
|
|
439
|
+
—
|
|
398
440
|
<div class='inline'>
|
|
399
|
-
<p>
|
|
400
|
-
things like instance variables declared in the test will not be available
|
|
401
|
-
within the block.</p>
|
|
441
|
+
<p>identifies mock object in error messages.</p>
|
|
402
442
|
</div>
|
|
403
443
|
|
|
404
444
|
</li>
|
|
405
445
|
|
|
406
446
|
<li>
|
|
407
447
|
|
|
448
|
+
<span class='name'>expected_methods_vs_return_values</span>
|
|
408
449
|
|
|
409
|
-
<span class='type'></span>
|
|
410
450
|
|
|
451
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
|
411
455
|
|
|
412
456
|
|
|
413
|
-
|
|
457
|
+
—
|
|
414
458
|
<div class='inline'>
|
|
415
|
-
<p>
|
|
416
|
-
receiver instead.</p>
|
|
459
|
+
<p>expected method name symbols as keys and corresponding return values as values - these expectations are setup as if <span class='object_link'><a href="Mock.html#expects-instance_method" title="Mocha::Mock#expects (method)">Mock#expects</a></span> were called multiple times.</p>
|
|
417
460
|
</div>
|
|
418
461
|
|
|
419
462
|
</li>
|
|
420
463
|
|
|
421
464
|
</ul>
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
</div>
|
|
468
|
+
</li>
|
|
469
|
+
|
|
470
|
+
</ul>
|
|
471
|
+
|
|
422
472
|
<p class="tag_title">Returns:</p>
|
|
423
473
|
<ul class="return">
|
|
424
474
|
|
|
@@ -444,23 +494,15 @@ receiver instead.</p>
|
|
|
444
494
|
<pre class="lines">
|
|
445
495
|
|
|
446
496
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
55
|
|
451
|
-
56
|
|
452
|
-
57
|
|
453
|
-
58</pre>
|
|
497
|
+
62
|
|
498
|
+
63
|
|
499
|
+
64</pre>
|
|
454
500
|
</td>
|
|
455
501
|
<td>
|
|
456
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/api.rb', line
|
|
457
|
-
|
|
458
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_arguments'>arguments</span><span class='
|
|
459
|
-
<span class='id identifier
|
|
460
|
-
<span class='id identifier rubyid_expectations'>expectations</span> <span class='op'>=</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span> <span class='op'>||</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
|
461
|
-
<span class='id identifier rubyid_mock'>mock</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span> <span class='op'>?</span> <span class='const'>Mockery</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_named_mock'>named_mock</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='const'>Mockery</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_unnamed_mock'>unnamed_mock</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
|
462
|
-
<span class='id identifier rubyid_mock'>mock</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='id identifier rubyid_expectations'>expectations</span><span class='rparen'>)</span>
|
|
463
|
-
<span class='id identifier rubyid_mock'>mock</span>
|
|
502
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/api.rb', line 62</span>
|
|
503
|
+
|
|
504
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_arguments'>arguments</span><span class='rparen'>)</span>
|
|
505
|
+
<span class='id identifier rubyid_create_mock'>create_mock</span><span class='lparen'>(</span><span class='id identifier rubyid_arguments'>arguments</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_mock'>mock</span><span class='comma'>,</span> <span class='id identifier rubyid_expectations'>expectations</span><span class='op'>|</span> <span class='id identifier rubyid_mock'>mock</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='id identifier rubyid_expectations'>expectations</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
|
464
506
|
<span class='kw'>end</span></pre>
|
|
465
507
|
</td>
|
|
466
508
|
</tr>
|
|
@@ -479,11 +521,9 @@ receiver instead.</p>
|
|
|
479
521
|
</h3><div class="docstring">
|
|
480
522
|
<div class="discussion">
|
|
481
523
|
|
|
482
|
-
<p>Builds a new sequence which can be used to constrain the order in which
|
|
483
|
-
expectations can occur.</p>
|
|
524
|
+
<p>Builds a new sequence which can be used to constrain the order in which expectations can occur.</p>
|
|
484
525
|
|
|
485
|
-
<p>Specify that an expected invocation must occur within a named <span class='object_link'><a href="Sequence.html" title="Mocha::Sequence (class)">Sequence</a></span> by
|
|
486
|
-
using <span class='object_link'><a href="Expectation.html#in_sequence-instance_method" title="Mocha::Expectation#in_sequence (method)">Expectation#in_sequence</a></span>.</p>
|
|
526
|
+
<p>Specify that an expected invocation must occur within a named <span class='object_link'><a href="Sequence.html" title="Mocha::Sequence (class)">Sequence</a></span> by using <span class='object_link'><a href="Expectation.html#in_sequence-instance_method" title="Mocha::Expectation#in_sequence (method)">Expectation#in_sequence</a></span>.</p>
|
|
487
527
|
|
|
488
528
|
|
|
489
529
|
</div>
|
|
@@ -540,12 +580,12 @@ using <span class='object_link'><a href="Expectation.html#in_sequence-instance_m
|
|
|
540
580
|
<pre class="lines">
|
|
541
581
|
|
|
542
582
|
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
583
|
+
130
|
|
584
|
+
131
|
|
585
|
+
132</pre>
|
|
546
586
|
</td>
|
|
547
587
|
<td>
|
|
548
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/api.rb', line
|
|
588
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/api.rb', line 130</span>
|
|
549
589
|
|
|
550
590
|
<span class='kw'>def</span> <span class='id identifier rubyid_sequence'>sequence</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
|
|
551
591
|
<span class='const'><span class='object_link'><a href="Sequence.html" title="Mocha::Sequence (class)">Sequence</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
|
|
@@ -567,17 +607,13 @@ using <span class='object_link'><a href="Expectation.html#in_sequence-instance_m
|
|
|
567
607
|
</h3><div class="docstring">
|
|
568
608
|
<div class="discussion">
|
|
569
609
|
|
|
570
|
-
<p>Builds a new state machine which can be used to constrain the order in
|
|
571
|
-
which expectations can occur.</p>
|
|
610
|
+
<p>Builds a new state machine which can be used to constrain the order in which expectations can occur.</p>
|
|
572
611
|
|
|
573
|
-
<p>Specify the initial state of the state machine by using
|
|
574
|
-
<span class='object_link'><a href="StateMachine.html#starts_as-instance_method" title="Mocha::StateMachine#starts_as (method)">StateMachine#starts_as</a></span>.</p>
|
|
612
|
+
<p>Specify the initial state of the state machine by using <span class='object_link'><a href="StateMachine.html#starts_as-instance_method" title="Mocha::StateMachine#starts_as (method)">StateMachine#starts_as</a></span>.</p>
|
|
575
613
|
|
|
576
|
-
<p>Specify that an expected invocation should change the state of the state
|
|
577
|
-
machine by using <span class='object_link'><a href="Expectation.html#then-instance_method" title="Mocha::Expectation#then (method)">Expectation#then</a></span>.</p>
|
|
614
|
+
<p>Specify that an expected invocation should change the state of the state machine by using <span class='object_link'><a href="Expectation.html#then-instance_method" title="Mocha::Expectation#then (method)">Expectation#then</a></span>.</p>
|
|
578
615
|
|
|
579
|
-
<p>Specify that an expected invocation should be constrained to occur within a
|
|
580
|
-
particular <code>state</code> by using <span class='object_link'><a href="Expectation.html#when-instance_method" title="Mocha::Expectation#when (method)">Expectation#when</a></span>.</p>
|
|
616
|
+
<p>Specify that an expected invocation should be constrained to occur within a particular <code>state</code> by using <span class='object_link'><a href="Expectation.html#when-instance_method" title="Mocha::Expectation#when (method)">Expectation#when</a></span>.</p>
|
|
581
617
|
|
|
582
618
|
<p>A test can contain multiple state machines.</p>
|
|
583
619
|
|
|
@@ -643,12 +679,12 @@ particular <code>state</code> by using <span class='object_link'><a href="Expect
|
|
|
643
679
|
<pre class="lines">
|
|
644
680
|
|
|
645
681
|
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
682
|
+
160
|
|
683
|
+
161
|
|
684
|
+
162</pre>
|
|
649
685
|
</td>
|
|
650
686
|
<td>
|
|
651
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/api.rb', line
|
|
687
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/api.rb', line 160</span>
|
|
652
688
|
|
|
653
689
|
<span class='kw'>def</span> <span class='id identifier rubyid_states'>states</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
|
|
654
690
|
<span class='const'>Mockery</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_new_state_machine'>new_state_machine</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
|
|
@@ -662,11 +698,11 @@ particular <code>state</code> by using <span class='object_link'><a href="Expect
|
|
|
662
698
|
<h3 class="signature " id="stub-instance_method">
|
|
663
699
|
|
|
664
700
|
|
|
665
|
-
<span class="overload">#<strong>stub</strong>(name
|
|
701
|
+
<span class="overload">#<strong>stub</strong>(name) ⇒ <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
|
|
666
702
|
|
|
667
|
-
<span class="overload">#<strong>stub</strong>(stubbed_methods_vs_return_values = {}
|
|
703
|
+
<span class="overload">#<strong>stub</strong>(stubbed_methods_vs_return_values = {}) ⇒ <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
|
|
668
704
|
|
|
669
|
-
<span class="overload">#<strong>stub</strong>(name, stubbed_methods_vs_return_values = {}
|
|
705
|
+
<span class="overload">#<strong>stub</strong>(name, stubbed_methods_vs_return_values = {}) ⇒ <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
|
|
670
706
|
|
|
671
707
|
|
|
672
708
|
|
|
@@ -698,24 +734,22 @@ particular <code>state</code> by using <span class='object_link'><a href="Expect
|
|
|
698
734
|
<span class='comment'># an error will not be raised even if either Motor#start or Motor#stop has not been called
|
|
699
735
|
</span><span class='kw'>end</span></code></pre>
|
|
700
736
|
|
|
737
|
+
</div>
|
|
738
|
+
|
|
739
|
+
<p class="tag_title">Overloads:</p>
|
|
740
|
+
<ul class="overload">
|
|
741
|
+
|
|
701
742
|
|
|
702
|
-
|
|
703
|
-
<
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
<pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_test_motor_starts_and_stops'>test_motor_starts_and_stops</span>
|
|
708
|
-
<span class='id identifier rubyid_motor'>motor</span> <span class='op'>=</span> <span class='id identifier rubyid_stub'>stub</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>motor</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='kw'>do</span>
|
|
709
|
-
<span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:start</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='int'>100</span><span class='period'>.</span><span class='id identifier rubyid_rpm'>rpm</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_returns'>returns</span><span class='lparen'>(</span><span class='kw'>true</span><span class='rparen'>)</span>
|
|
710
|
-
<span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='symbol'>:stop</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_returns'>returns</span><span class='lparen'>(</span><span class='kw'>true</span><span class='rparen'>)</span>
|
|
711
|
-
<span class='kw'>end</span>
|
|
712
|
-
<span class='id identifier rubyid_assert'>assert</span> <span class='id identifier rubyid_motor'>motor</span><span class='period'>.</span><span class='id identifier rubyid_start'>start</span><span class='lparen'>(</span><span class='int'>100</span><span class='period'>.</span><span class='id identifier rubyid_rpm'>rpm</span><span class='rparen'>)</span>
|
|
713
|
-
<span class='id identifier rubyid_assert'>assert</span> <span class='id identifier rubyid_motor'>motor</span><span class='period'>.</span><span class='id identifier rubyid_stop'>stop</span>
|
|
714
|
-
<span class='comment'># an error will only be raised if Motor#start(100.rpm) has not been called
|
|
715
|
-
</span><span class='kw'>end</span></code></pre>
|
|
743
|
+
<li class="overload_item">
|
|
744
|
+
<span class="signature">#<strong>stub</strong>(name) ⇒ <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
|
|
745
|
+
<div class="docstring">
|
|
746
|
+
<div class="discussion">
|
|
716
747
|
|
|
748
|
+
|
|
717
749
|
</div>
|
|
718
|
-
|
|
750
|
+
</div>
|
|
751
|
+
<div class="tags">
|
|
752
|
+
<p class="tag_title">Parameters:</p>
|
|
719
753
|
<ul class="param">
|
|
720
754
|
|
|
721
755
|
<li>
|
|
@@ -723,7 +757,7 @@ particular <code>state</code> by using <span class='object_link'><a href="Expect
|
|
|
723
757
|
<span class='name'>name</span>
|
|
724
758
|
|
|
725
759
|
|
|
726
|
-
<span class='type'>(<tt>String</tt>)</span>
|
|
760
|
+
<span class='type'>(<tt>String</tt>, <tt>Symbol</tt>)</span>
|
|
727
761
|
|
|
728
762
|
|
|
729
763
|
|
|
@@ -734,6 +768,25 @@ particular <code>state</code> by using <span class='object_link'><a href="Expect
|
|
|
734
768
|
|
|
735
769
|
</li>
|
|
736
770
|
|
|
771
|
+
</ul>
|
|
772
|
+
|
|
773
|
+
|
|
774
|
+
</div>
|
|
775
|
+
</li>
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
<li class="overload_item">
|
|
779
|
+
<span class="signature">#<strong>stub</strong>(stubbed_methods_vs_return_values = {}) ⇒ <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
|
|
780
|
+
<div class="docstring">
|
|
781
|
+
<div class="discussion">
|
|
782
|
+
|
|
783
|
+
|
|
784
|
+
</div>
|
|
785
|
+
</div>
|
|
786
|
+
<div class="tags">
|
|
787
|
+
<p class="tag_title">Parameters:</p>
|
|
788
|
+
<ul class="param">
|
|
789
|
+
|
|
737
790
|
<li>
|
|
738
791
|
|
|
739
792
|
<span class='name'>stubbed_methods_vs_return_values</span>
|
|
@@ -742,68 +795,59 @@ particular <code>state</code> by using <span class='object_link'><a href="Expect
|
|
|
742
795
|
<span class='type'>(<tt>Hash</tt>)</span>
|
|
743
796
|
|
|
744
797
|
|
|
798
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
|
799
|
+
|
|
745
800
|
|
|
746
801
|
—
|
|
747
802
|
<div class='inline'>
|
|
748
|
-
<p>stubbed method name symbols as keys and corresponding return values as
|
|
749
|
-
values - these stubbed methods are setup as if <span class='object_link'><a href="Mock.html#stubs-instance_method" title="Mocha::Mock#stubs (method)">Mock#stubs</a></span> were called
|
|
750
|
-
multiple times.</p>
|
|
803
|
+
<p>stubbed method name symbols as keys and corresponding return values as values - these stubbed methods are setup as if <span class='object_link'><a href="Mock.html#stubs-instance_method" title="Mocha::Mock#stubs (method)">Mock#stubs</a></span> were called multiple times.</p>
|
|
751
804
|
</div>
|
|
752
805
|
|
|
753
806
|
</li>
|
|
754
807
|
|
|
755
808
|
</ul>
|
|
756
809
|
|
|
757
|
-
|
|
758
|
-
<ul class="yield">
|
|
759
|
-
|
|
760
|
-
<li>
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
<span class='type'></span>
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
<div class='inline'>
|
|
769
|
-
<p>optional block to be evaluated in the context of the mock object instance,
|
|
770
|
-
giving an alternative way to setup stubbed methods.</p>
|
|
810
|
+
|
|
771
811
|
</div>
|
|
812
|
+
</li>
|
|
813
|
+
|
|
772
814
|
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
<div class='inline'>
|
|
784
|
-
<p>note that the block is evaulated by calling Mock#instance_eval and so
|
|
785
|
-
things like instance variables declared in the test will not be available
|
|
786
|
-
within the block.</p>
|
|
815
|
+
<li class="overload_item">
|
|
816
|
+
<span class="signature">#<strong>stub</strong>(name, stubbed_methods_vs_return_values = {}) ⇒ <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
|
|
817
|
+
<div class="docstring">
|
|
818
|
+
<div class="discussion">
|
|
819
|
+
|
|
820
|
+
|
|
821
|
+
</div>
|
|
787
822
|
</div>
|
|
788
|
-
|
|
789
|
-
|
|
823
|
+
<div class="tags">
|
|
824
|
+
<p class="tag_title">Parameters:</p>
|
|
825
|
+
<ul class="param">
|
|
790
826
|
|
|
791
827
|
<li>
|
|
792
828
|
|
|
829
|
+
<span class='name'>name</span>
|
|
830
|
+
|
|
793
831
|
|
|
794
|
-
<span class='type'
|
|
832
|
+
<span class='type'>(<tt>String</tt>, <tt>Symbol</tt>)</span>
|
|
795
833
|
|
|
796
834
|
|
|
797
835
|
|
|
798
|
-
|
|
836
|
+
—
|
|
799
837
|
<div class='inline'>
|
|
800
|
-
<p>
|
|
801
|
-
receiver instead.</p>
|
|
838
|
+
<p>identifies mock object in error messages.</p>
|
|
802
839
|
</div>
|
|
803
840
|
|
|
804
841
|
</li>
|
|
805
842
|
|
|
806
843
|
</ul>
|
|
844
|
+
|
|
845
|
+
|
|
846
|
+
</div>
|
|
847
|
+
</li>
|
|
848
|
+
|
|
849
|
+
</ul>
|
|
850
|
+
|
|
807
851
|
<p class="tag_title">Returns:</p>
|
|
808
852
|
<ul class="return">
|
|
809
853
|
|
|
@@ -829,23 +873,15 @@ receiver instead.</p>
|
|
|
829
873
|
<pre class="lines">
|
|
830
874
|
|
|
831
875
|
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
94
|
|
836
|
-
95
|
|
837
|
-
96
|
|
838
|
-
97</pre>
|
|
876
|
+
84
|
|
877
|
+
85
|
|
878
|
+
86</pre>
|
|
839
879
|
</td>
|
|
840
880
|
<td>
|
|
841
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/api.rb', line
|
|
842
|
-
|
|
843
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_stub'>stub</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_arguments'>arguments</span><span class='
|
|
844
|
-
<span class='id identifier
|
|
845
|
-
<span class='id identifier rubyid_expectations'>expectations</span> <span class='op'>=</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span> <span class='op'>||</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
|
846
|
-
<span class='id identifier rubyid_stub'>stub</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span> <span class='op'>?</span> <span class='const'>Mockery</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_named_mock'>named_mock</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='const'>Mockery</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_unnamed_mock'>unnamed_mock</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
|
847
|
-
<span class='id identifier rubyid_stub'>stub</span><span class='period'>.</span><span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='id identifier rubyid_expectations'>expectations</span><span class='rparen'>)</span>
|
|
848
|
-
<span class='id identifier rubyid_stub'>stub</span>
|
|
881
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/api.rb', line 84</span>
|
|
882
|
+
|
|
883
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_stub'>stub</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_arguments'>arguments</span><span class='rparen'>)</span>
|
|
884
|
+
<span class='id identifier rubyid_create_mock'>create_mock</span><span class='lparen'>(</span><span class='id identifier rubyid_arguments'>arguments</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_stub'>stub</span><span class='comma'>,</span> <span class='id identifier rubyid_expectations'>expectations</span><span class='op'>|</span> <span class='id identifier rubyid_stub'>stub</span><span class='period'>.</span><span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='id identifier rubyid_expectations'>expectations</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
|
849
885
|
<span class='kw'>end</span></pre>
|
|
850
886
|
</td>
|
|
851
887
|
</tr>
|
|
@@ -856,11 +892,11 @@ receiver instead.</p>
|
|
|
856
892
|
<h3 class="signature " id="stub_everything-instance_method">
|
|
857
893
|
|
|
858
894
|
|
|
859
|
-
<span class="overload">#<strong>stub_everything</strong>(name
|
|
895
|
+
<span class="overload">#<strong>stub_everything</strong>(name) ⇒ <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
|
|
860
896
|
|
|
861
|
-
<span class="overload">#<strong>stub_everything</strong>(stubbed_methods_vs_return_values = {}
|
|
897
|
+
<span class="overload">#<strong>stub_everything</strong>(stubbed_methods_vs_return_values = {}) ⇒ <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
|
|
862
898
|
|
|
863
|
-
<span class="overload">#<strong>stub_everything</strong>(name, stubbed_methods_vs_return_values = {}
|
|
899
|
+
<span class="overload">#<strong>stub_everything</strong>(name, stubbed_methods_vs_return_values = {}) ⇒ <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
|
|
864
900
|
|
|
865
901
|
|
|
866
902
|
|
|
@@ -870,8 +906,7 @@ receiver instead.</p>
|
|
|
870
906
|
</h3><div class="docstring">
|
|
871
907
|
<div class="discussion">
|
|
872
908
|
|
|
873
|
-
<p>Builds a mock object that accepts calls to any method. By default it will
|
|
874
|
-
return <code>nil</code> for any method call.</p>
|
|
909
|
+
<p>Builds a mock object that accepts calls to any method. By default it will return <code>nil</code> for any method call.</p>
|
|
875
910
|
|
|
876
911
|
|
|
877
912
|
</div>
|
|
@@ -894,7 +929,21 @@ return <code>nil</code> for any method call.</p>
|
|
|
894
929
|
<span class='kw'>end</span></code></pre>
|
|
895
930
|
|
|
896
931
|
</div>
|
|
897
|
-
|
|
932
|
+
|
|
933
|
+
<p class="tag_title">Overloads:</p>
|
|
934
|
+
<ul class="overload">
|
|
935
|
+
|
|
936
|
+
|
|
937
|
+
<li class="overload_item">
|
|
938
|
+
<span class="signature">#<strong>stub_everything</strong>(name) ⇒ <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
|
|
939
|
+
<div class="docstring">
|
|
940
|
+
<div class="discussion">
|
|
941
|
+
|
|
942
|
+
|
|
943
|
+
</div>
|
|
944
|
+
</div>
|
|
945
|
+
<div class="tags">
|
|
946
|
+
<p class="tag_title">Parameters:</p>
|
|
898
947
|
<ul class="param">
|
|
899
948
|
|
|
900
949
|
<li>
|
|
@@ -902,7 +951,7 @@ return <code>nil</code> for any method call.</p>
|
|
|
902
951
|
<span class='name'>name</span>
|
|
903
952
|
|
|
904
953
|
|
|
905
|
-
<span class='type'>(<tt>String</tt>)</span>
|
|
954
|
+
<span class='type'>(<tt>String</tt>, <tt>Symbol</tt>)</span>
|
|
906
955
|
|
|
907
956
|
|
|
908
957
|
|
|
@@ -913,6 +962,25 @@ return <code>nil</code> for any method call.</p>
|
|
|
913
962
|
|
|
914
963
|
</li>
|
|
915
964
|
|
|
965
|
+
</ul>
|
|
966
|
+
|
|
967
|
+
|
|
968
|
+
</div>
|
|
969
|
+
</li>
|
|
970
|
+
|
|
971
|
+
|
|
972
|
+
<li class="overload_item">
|
|
973
|
+
<span class="signature">#<strong>stub_everything</strong>(stubbed_methods_vs_return_values = {}) ⇒ <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
|
|
974
|
+
<div class="docstring">
|
|
975
|
+
<div class="discussion">
|
|
976
|
+
|
|
977
|
+
|
|
978
|
+
</div>
|
|
979
|
+
</div>
|
|
980
|
+
<div class="tags">
|
|
981
|
+
<p class="tag_title">Parameters:</p>
|
|
982
|
+
<ul class="param">
|
|
983
|
+
|
|
916
984
|
<li>
|
|
917
985
|
|
|
918
986
|
<span class='name'>stubbed_methods_vs_return_values</span>
|
|
@@ -921,68 +989,77 @@ return <code>nil</code> for any method call.</p>
|
|
|
921
989
|
<span class='type'>(<tt>Hash</tt>)</span>
|
|
922
990
|
|
|
923
991
|
|
|
992
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
|
993
|
+
|
|
924
994
|
|
|
925
995
|
—
|
|
926
996
|
<div class='inline'>
|
|
927
|
-
<p>stubbed method name symbols as keys and corresponding return values as
|
|
928
|
-
values - these stubbed methods are setup as if <span class='object_link'><a href="Mock.html#stubs-instance_method" title="Mocha::Mock#stubs (method)">Mock#stubs</a></span> were called
|
|
929
|
-
multiple times.</p>
|
|
997
|
+
<p>stubbed method name symbols as keys and corresponding return values as values - these stubbed methods are setup as if <span class='object_link'><a href="Mock.html#stubs-instance_method" title="Mocha::Mock#stubs (method)">Mock#stubs</a></span> were called multiple times.</p>
|
|
930
998
|
</div>
|
|
931
999
|
|
|
932
1000
|
</li>
|
|
933
1001
|
|
|
934
1002
|
</ul>
|
|
935
1003
|
|
|
936
|
-
|
|
937
|
-
<ul class="yield">
|
|
938
|
-
|
|
939
|
-
<li>
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
<span class='type'></span>
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
<div class='inline'>
|
|
948
|
-
<p>optional block to be evaluated in the context of the mock object instance,
|
|
949
|
-
giving an alternative way to setup stubbed methods.</p>
|
|
1004
|
+
|
|
950
1005
|
</div>
|
|
1006
|
+
</li>
|
|
1007
|
+
|
|
951
1008
|
|
|
952
|
-
|
|
1009
|
+
<li class="overload_item">
|
|
1010
|
+
<span class="signature">#<strong>stub_everything</strong>(name, stubbed_methods_vs_return_values = {}) ⇒ <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
|
|
1011
|
+
<div class="docstring">
|
|
1012
|
+
<div class="discussion">
|
|
1013
|
+
|
|
1014
|
+
|
|
1015
|
+
</div>
|
|
1016
|
+
</div>
|
|
1017
|
+
<div class="tags">
|
|
1018
|
+
<p class="tag_title">Parameters:</p>
|
|
1019
|
+
<ul class="param">
|
|
953
1020
|
|
|
954
1021
|
<li>
|
|
955
1022
|
|
|
1023
|
+
<span class='name'>name</span>
|
|
1024
|
+
|
|
956
1025
|
|
|
957
|
-
<span class='type'
|
|
1026
|
+
<span class='type'>(<tt>String</tt>, <tt>Symbol</tt>)</span>
|
|
958
1027
|
|
|
959
1028
|
|
|
960
1029
|
|
|
961
|
-
|
|
1030
|
+
—
|
|
962
1031
|
<div class='inline'>
|
|
963
|
-
<p>
|
|
964
|
-
things like instance variables declared in the test will not be available
|
|
965
|
-
within the block.</p>
|
|
1032
|
+
<p>identifies mock object in error messages.</p>
|
|
966
1033
|
</div>
|
|
967
1034
|
|
|
968
1035
|
</li>
|
|
969
1036
|
|
|
970
1037
|
<li>
|
|
971
1038
|
|
|
1039
|
+
<span class='name'>stubbed_methods_vs_return_values</span>
|
|
972
1040
|
|
|
973
|
-
<span class='type'></span>
|
|
974
1041
|
|
|
1042
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
|
1043
|
+
|
|
1044
|
+
|
|
1045
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
|
975
1046
|
|
|
976
1047
|
|
|
977
|
-
|
|
1048
|
+
—
|
|
978
1049
|
<div class='inline'>
|
|
979
|
-
<p>
|
|
980
|
-
receiver instead.</p>
|
|
1050
|
+
<p>stubbed method name symbols as keys and corresponding return values as values - these stubbed methods are setup as if <span class='object_link'><a href="Mock.html#stubs-instance_method" title="Mocha::Mock#stubs (method)">Mock#stubs</a></span> were called multiple times.</p>
|
|
981
1051
|
</div>
|
|
982
1052
|
|
|
983
1053
|
</li>
|
|
984
1054
|
|
|
985
1055
|
</ul>
|
|
1056
|
+
|
|
1057
|
+
|
|
1058
|
+
</div>
|
|
1059
|
+
</li>
|
|
1060
|
+
|
|
1061
|
+
</ul>
|
|
1062
|
+
|
|
986
1063
|
<p class="tag_title">Returns:</p>
|
|
987
1064
|
<ul class="return">
|
|
988
1065
|
|
|
@@ -1008,25 +1085,21 @@ receiver instead.</p>
|
|
|
1008
1085
|
<pre class="lines">
|
|
1009
1086
|
|
|
1010
1087
|
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
125
|
|
1018
|
-
126</pre>
|
|
1088
|
+
107
|
|
1089
|
+
108
|
|
1090
|
+
109
|
|
1091
|
+
110
|
|
1092
|
+
111
|
|
1093
|
+
112</pre>
|
|
1019
1094
|
</td>
|
|
1020
1095
|
<td>
|
|
1021
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/api.rb', line
|
|
1022
|
-
|
|
1023
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_stub_everything'>stub_everything</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_arguments'>arguments</span><span class='
|
|
1024
|
-
<span class='id identifier
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
<span class='
|
|
1028
|
-
<span class='id identifier rubyid_stub'>stub</span><span class='period'>.</span><span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='id identifier rubyid_expectations'>expectations</span><span class='rparen'>)</span>
|
|
1029
|
-
<span class='id identifier rubyid_stub'>stub</span>
|
|
1096
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/api.rb', line 107</span>
|
|
1097
|
+
|
|
1098
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_stub_everything'>stub_everything</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_arguments'>arguments</span><span class='rparen'>)</span>
|
|
1099
|
+
<span class='id identifier rubyid_create_mock'>create_mock</span><span class='lparen'>(</span><span class='id identifier rubyid_arguments'>arguments</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_stub'>stub</span><span class='comma'>,</span> <span class='id identifier rubyid_expectations'>expectations</span><span class='op'>|</span>
|
|
1100
|
+
<span class='id identifier rubyid_stub'>stub</span><span class='period'>.</span><span class='id identifier rubyid_stub_everything'>stub_everything</span>
|
|
1101
|
+
<span class='id identifier rubyid_stub'>stub</span><span class='period'>.</span><span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='id identifier rubyid_expectations'>expectations</span><span class='rparen'>)</span>
|
|
1102
|
+
<span class='kw'>end</span>
|
|
1030
1103
|
<span class='kw'>end</span></pre>
|
|
1031
1104
|
</td>
|
|
1032
1105
|
</tr>
|
|
@@ -1046,9 +1119,9 @@ receiver instead.</p>
|
|
|
1046
1119
|
</div>
|
|
1047
1120
|
|
|
1048
1121
|
<div id="footer">
|
|
1049
|
-
Generated on
|
|
1122
|
+
Generated on Sun Nov 24 15:26:49 2019 by
|
|
1050
1123
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
1051
|
-
0.9.
|
|
1124
|
+
0.9.20 (ruby-2.6.5).
|
|
1052
1125
|
</div>
|
|
1053
1126
|
|
|
1054
1127
|
</div>
|