mocha 2.7.1 → 2.8.1
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/RELEASE.md +26 -0
- data/lib/mocha/api.rb +1 -1
- data/lib/mocha/configuration.rb +1 -1
- data/lib/mocha/expectation.rb +2 -2
- data/lib/mocha/integration/minitest/adapter.rb +3 -1
- data/lib/mocha/parameter_matchers/all_of.rb +30 -21
- data/lib/mocha/parameter_matchers/any_of.rb +36 -27
- data/lib/mocha/parameter_matchers/any_parameters.rb +28 -19
- data/lib/mocha/parameter_matchers/anything.rb +25 -16
- data/lib/mocha/parameter_matchers/base.rb +24 -4
- data/lib/mocha/parameter_matchers/deprecations.rb +44 -0
- data/lib/mocha/parameter_matchers/equals.rb +31 -22
- data/lib/mocha/parameter_matchers/equivalent_uri.rb +30 -21
- data/lib/mocha/parameter_matchers/has_entries.rb +31 -22
- data/lib/mocha/parameter_matchers/has_entry.rb +72 -65
- data/lib/mocha/parameter_matchers/has_key.rb +31 -22
- data/lib/mocha/parameter_matchers/has_keys.rb +31 -22
- data/lib/mocha/parameter_matchers/has_value.rb +31 -22
- data/lib/mocha/parameter_matchers/includes.rb +69 -60
- data/lib/mocha/parameter_matchers/instance_methods.rb +1 -1
- data/lib/mocha/parameter_matchers/instance_of.rb +31 -22
- data/lib/mocha/parameter_matchers/is_a.rb +32 -23
- data/lib/mocha/parameter_matchers/kind_of.rb +31 -22
- data/lib/mocha/parameter_matchers/not.rb +31 -22
- data/lib/mocha/parameter_matchers/optionally.rb +43 -33
- data/lib/mocha/parameter_matchers/positional_or_keyword_hash.rb +6 -1
- data/lib/mocha/parameter_matchers/regexp_matches.rb +31 -22
- data/lib/mocha/parameter_matchers/responds_with.rb +55 -46
- data/lib/mocha/parameter_matchers/yaml_equivalent.rb +30 -21
- data/lib/mocha/parameter_matchers.rb +6 -2
- data/lib/mocha/version.rb +1 -1
- metadata +4 -3
|
@@ -1,32 +1,39 @@
|
|
|
1
1
|
require 'mocha/parameter_matchers/base'
|
|
2
|
+
require 'mocha/parameter_matchers/deprecations'
|
|
2
3
|
require 'yaml'
|
|
3
4
|
|
|
4
5
|
module Mocha
|
|
5
6
|
module ParameterMatchers
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
7
|
+
module Methods
|
|
8
|
+
# Matches any YAML that represents the specified +object+
|
|
9
|
+
#
|
|
10
|
+
# @param [Object] object object whose YAML to compare.
|
|
11
|
+
# @return [YamlEquivalent] parameter matcher.
|
|
12
|
+
#
|
|
13
|
+
# @see Expectation#with
|
|
14
|
+
#
|
|
15
|
+
# @example Actual parameter is YAML equivalent of specified +object+.
|
|
16
|
+
# object = mock()
|
|
17
|
+
# object.expects(:method_1).with(yaml_equivalent(1, 2, 3))
|
|
18
|
+
# object.method_1("--- \n- 1\n- 2\n- 3\n")
|
|
19
|
+
# # no error raised
|
|
20
|
+
#
|
|
21
|
+
# @example Actual parameter is not YAML equivalent of specified +object+.
|
|
22
|
+
# object = mock()
|
|
23
|
+
# object.expects(:method_1).with(yaml_equivalent(1, 2, 3))
|
|
24
|
+
# object.method_1("--- \n- 1\n- 2\n")
|
|
25
|
+
# # error raised, because method_1 was not called with YAML representing the specified Array
|
|
26
|
+
def yaml_equivalent(object)
|
|
27
|
+
YamlEquivalent.new(object)
|
|
28
|
+
end
|
|
26
29
|
end
|
|
27
30
|
|
|
31
|
+
define_deprecated_matcher_method(:yaml_equivalent)
|
|
32
|
+
|
|
28
33
|
# Parameter matcher which matches if actual parameter is YAML equivalent of specified object.
|
|
29
|
-
class YamlEquivalent
|
|
34
|
+
class YamlEquivalent
|
|
35
|
+
include BaseMethods
|
|
36
|
+
|
|
30
37
|
# @private
|
|
31
38
|
def initialize(object)
|
|
32
39
|
@object = object
|
|
@@ -45,5 +52,7 @@ module Mocha
|
|
|
45
52
|
"yaml_equivalent(#{@object.mocha_inspect})"
|
|
46
53
|
end
|
|
47
54
|
end
|
|
55
|
+
|
|
56
|
+
provide_deprecated_access_to(:YamlEquivalent)
|
|
48
57
|
end
|
|
49
58
|
end
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
module Mocha
|
|
2
|
-
#
|
|
3
|
-
module ParameterMatchers
|
|
2
|
+
# Matcher classes used as parameters for {Expectation#with} to restrict the parameter values which will match the expectation. Can be nested. Build matcher instances in tests using methods in {Methods}, e.g. {Methods#includes}.
|
|
3
|
+
module ParameterMatchers
|
|
4
|
+
# These methods build instances of the {ParameterMatchers} classes which are used with {Expectation#with} to restrict the parameter values. Can be nested, e.g. see {Methods#all_of} examples.
|
|
5
|
+
module Methods; end
|
|
6
|
+
end
|
|
4
7
|
end
|
|
5
8
|
|
|
9
|
+
require 'mocha/parameter_matchers/deprecations'
|
|
6
10
|
require 'mocha/parameter_matchers/instance_methods'
|
|
7
11
|
|
|
8
12
|
require 'mocha/parameter_matchers/all_of'
|
data/lib/mocha/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mocha
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.8.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- James Mead
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2025-11-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: ruby2_keywords
|
|
@@ -94,6 +94,7 @@ files:
|
|
|
94
94
|
- lib/mocha/parameter_matchers/any_parameters.rb
|
|
95
95
|
- lib/mocha/parameter_matchers/anything.rb
|
|
96
96
|
- lib/mocha/parameter_matchers/base.rb
|
|
97
|
+
- lib/mocha/parameter_matchers/deprecations.rb
|
|
97
98
|
- lib/mocha/parameter_matchers/equals.rb
|
|
98
99
|
- lib/mocha/parameter_matchers/equivalent_uri.rb
|
|
99
100
|
- lib/mocha/parameter_matchers/has_entries.rb
|
|
@@ -154,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
154
155
|
- !ruby/object:Gem::Version
|
|
155
156
|
version: '0'
|
|
156
157
|
requirements: []
|
|
157
|
-
rubygems_version: 3.5.
|
|
158
|
+
rubygems_version: 3.5.3
|
|
158
159
|
signing_key:
|
|
159
160
|
specification_version: 4
|
|
160
161
|
summary: Mocking and stubbing library
|