rspec-mocks 3.12.6 → 3.13.2
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
- checksums.yaml.gz.sig +0 -0
- data/Changelog.md +30 -1
- data/README.md +2 -0
- data/lib/rspec/mocks/any_instance/recorder.rb +11 -9
- data/lib/rspec/mocks/argument_matchers.rb +51 -7
- data/lib/rspec/mocks/configuration.rb +1 -1
- data/lib/rspec/mocks/message_expectation.rb +4 -3
- data/lib/rspec/mocks/proxy.rb +3 -6
- data/lib/rspec/mocks/syntax.rb +1 -1
- data/lib/rspec/mocks/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +17 -14
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 560dd3294f2da199bebf87e99715e41d9a5859b2a47408121fe449b8614008e1
|
4
|
+
data.tar.gz: 0baffd51e9e653573998948c8057918b0e133caa13435026ad30a30848e15094
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ec16d16de43a63521e1e89111df5b26b009e1dfa6738e802fb79c485a3894a4bdf60b63f08a5420c7a37934f367c93250f112d630f727a552c9ac86ece41b7a
|
7
|
+
data.tar.gz: 7a8e8e5b56dd7e362b7109bce4137c4f77a95eb50d1904fef38c2ff5cb28d605398b653ba9801ca8eab28b6c894d8f787275132d34193f031d7d10c305791e95
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/Changelog.md
CHANGED
@@ -1,5 +1,34 @@
|
|
1
1
|
### Development
|
2
|
-
[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.
|
2
|
+
[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.13.2...3-13-maintennace)
|
3
|
+
|
4
|
+
### 3.13.2 / 2024-10-02
|
5
|
+
[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.13.1...v3.13.2)
|
6
|
+
|
7
|
+
Bug Fixes:
|
8
|
+
|
9
|
+
* Support keyword arguments in callables passed to `and_invoke`. (Jon Rowe, #1595)
|
10
|
+
|
11
|
+
### 3.13.1 / 2024-05-08
|
12
|
+
[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.13.0...v3.13.1)
|
13
|
+
|
14
|
+
Bug Fixes:
|
15
|
+
|
16
|
+
* Use `RSpec::Support::Mutex` in `RSpec::Mocks::Proxy` to avoid issues from
|
17
|
+
stubbing `::Mutex#new`. (Eric Mueller, #1575)
|
18
|
+
|
19
|
+
### 3.13.0 / 2024-02-04
|
20
|
+
[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.12.7...v3.13.0)
|
21
|
+
|
22
|
+
Enhancements:
|
23
|
+
|
24
|
+
* Add an `array_excluding` matcher for arguments. (Zane Wolfgang Pickett, #1528)
|
25
|
+
|
26
|
+
### 3.12.7 / 2024-02-04
|
27
|
+
[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.12.6...v3.12.7)
|
28
|
+
|
29
|
+
Bug Fixes:
|
30
|
+
|
31
|
+
* Reduce allocations from "any_instance" style mocks. (Carlos Palhares, #1479)
|
3
32
|
|
4
33
|
### 3.12.6 / 2023-07-11
|
5
34
|
[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.12.5...v3.12.6)
|
data/README.md
CHANGED
@@ -278,6 +278,8 @@ expect(double).to receive(:msg).with(1, duck_type(:abs, :div), "b") #2nd argumen
|
|
278
278
|
expect(double).to receive(:msg).with(hash_including(:a => 5)) # first arg is a hash with a: 5 as one of the key-values
|
279
279
|
expect(double).to receive(:msg).with(array_including(5)) # first arg is an array with 5 as one of the key-values
|
280
280
|
expect(double).to receive(:msg).with(hash_excluding(:a => 5)) # first arg is a hash without a: 5 as one of the key-values
|
281
|
+
expect(double).to receive(:msg).with(start_with('a')) # any matcher, custom or from rspec-expectations
|
282
|
+
expect(double).to receive(:msg).with(satisfy { |data| data.dig(:a, :b, :c) == 5 }) # assert anything you want
|
281
283
|
```
|
282
284
|
|
283
285
|
## Receive Counts
|
@@ -156,21 +156,23 @@ module RSpec
|
|
156
156
|
|
157
157
|
private
|
158
158
|
|
159
|
-
def ancestor_is_an_observer?(method_name)
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
end
|
165
|
-
end
|
159
|
+
def ancestor_is_an_observer?(ancestor, method_name)
|
160
|
+
return if ancestor == @klass
|
161
|
+
|
162
|
+
::RSpec::Mocks.space.
|
163
|
+
any_instance_recorder_for(ancestor).already_observing?(method_name)
|
166
164
|
end
|
167
165
|
|
168
166
|
def super_class_observers_for(method_name)
|
169
|
-
@klass.ancestors.select
|
167
|
+
@klass.ancestors.select do |ancestor|
|
168
|
+
ancestor_is_an_observer?(ancestor, method_name)
|
169
|
+
end
|
170
170
|
end
|
171
171
|
|
172
172
|
def super_class_observing?(method_name)
|
173
|
-
@klass.ancestors.any?
|
173
|
+
@klass.ancestors.any? do |ancestor|
|
174
|
+
ancestor_is_an_observer?(ancestor, method_name)
|
175
|
+
end
|
174
176
|
end
|
175
177
|
|
176
178
|
def normalize_chain(*args)
|
@@ -71,6 +71,16 @@ module RSpec
|
|
71
71
|
HashIncludingMatcher.new(ArgumentMatchers.anythingize_lonely_keys(*args))
|
72
72
|
end
|
73
73
|
|
74
|
+
# Matches a hash that doesn't include the specified key(s) or key/value.
|
75
|
+
#
|
76
|
+
# @example
|
77
|
+
# expect(object).to receive(:message).with(hash_excluding(:key => val))
|
78
|
+
# expect(object).to receive(:message).with(hash_excluding(:key))
|
79
|
+
# expect(object).to receive(:message).with(hash_excluding(:key, :key2 => :val2))
|
80
|
+
def hash_excluding(*args)
|
81
|
+
HashExcludingMatcher.new(ArgumentMatchers.anythingize_lonely_keys(*args))
|
82
|
+
end
|
83
|
+
|
74
84
|
# Matches an array that includes the specified items at least once.
|
75
85
|
# Ignores duplicates and additional values
|
76
86
|
#
|
@@ -82,14 +92,14 @@ module RSpec
|
|
82
92
|
ArrayIncludingMatcher.new(actually_an_array)
|
83
93
|
end
|
84
94
|
|
85
|
-
# Matches
|
95
|
+
# Matches an array that excludes the specified items.
|
86
96
|
#
|
87
97
|
# @example
|
88
|
-
# expect(object).to receive(:message).with(
|
89
|
-
# expect(object).to receive(:message).with(
|
90
|
-
|
91
|
-
|
92
|
-
|
98
|
+
# expect(object).to receive(:message).with(array_excluding(1,2,3))
|
99
|
+
# expect(object).to receive(:message).with(array_excluding([1,2,3]))
|
100
|
+
def array_excluding(*args)
|
101
|
+
actually_an_array = Array === args.first && args.count == 1 ? args.first : args
|
102
|
+
ArrayExcludingMatcher.new(actually_an_array)
|
93
103
|
end
|
94
104
|
|
95
105
|
alias_method :hash_not_including, :hash_excluding
|
@@ -236,6 +246,8 @@ module RSpec
|
|
236
246
|
|
237
247
|
def ===(actual)
|
238
248
|
actual = actual.uniq
|
249
|
+
return true if (actual & @expected).count >= @expected.count
|
250
|
+
|
239
251
|
@expected.uniq.all? do |expected_element|
|
240
252
|
actual.any? do |actual_element|
|
241
253
|
RSpec::Support::FuzzyMatcher.values_match?(expected_element, actual_element)
|
@@ -258,6 +270,38 @@ module RSpec
|
|
258
270
|
end
|
259
271
|
end
|
260
272
|
|
273
|
+
# @private
|
274
|
+
class ArrayExcludingMatcher
|
275
|
+
def initialize(unexpected)
|
276
|
+
@unexpected = unexpected.uniq
|
277
|
+
end
|
278
|
+
|
279
|
+
def ===(actual)
|
280
|
+
actual = actual.uniq
|
281
|
+
return false unless (actual & @unexpected).empty?
|
282
|
+
|
283
|
+
actual.none? do |actual_element|
|
284
|
+
@unexpected.any? do |unexpected_element|
|
285
|
+
RSpec::Support::FuzzyMatcher.values_match?(unexpected_element, actual_element)
|
286
|
+
end
|
287
|
+
end
|
288
|
+
rescue NoMethodError
|
289
|
+
false
|
290
|
+
end
|
291
|
+
|
292
|
+
def description
|
293
|
+
"array_excluding(#{formatted_unexpected_values})"
|
294
|
+
end
|
295
|
+
|
296
|
+
private
|
297
|
+
|
298
|
+
def formatted_unexpected_values
|
299
|
+
@unexpected.map do |x|
|
300
|
+
RSpec::Support.rspec_description_for_object(x)
|
301
|
+
end.join(", ")
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
261
305
|
# @private
|
262
306
|
class DuckTypeMatcher
|
263
307
|
def initialize(*methods_to_respond_to)
|
@@ -312,7 +356,7 @@ module RSpec
|
|
312
356
|
begin
|
313
357
|
object.class.name.include?(matcher_namespace)
|
314
358
|
rescue NoMethodError
|
315
|
-
# Some objects, like BasicObject, don't
|
359
|
+
# Some objects, like BasicObject, don't implement standard
|
316
360
|
# reflection methods.
|
317
361
|
false
|
318
362
|
end
|
@@ -156,7 +156,7 @@ module RSpec
|
|
156
156
|
end
|
157
157
|
|
158
158
|
# @private
|
159
|
-
# Used to track
|
159
|
+
# Used to track whether we are temporarily suppressing verifying partial
|
160
160
|
# doubles with `without_partial_double_verification { ... }`
|
161
161
|
attr_accessor :temporarily_suppress_partial_double_verification
|
162
162
|
|
@@ -68,7 +68,7 @@ module RSpec
|
|
68
68
|
# counter.count # => 3
|
69
69
|
# counter.count # => 3
|
70
70
|
# # etc
|
71
|
-
def and_return(first_value, *values)
|
71
|
+
def and_return(first_value, *values, &_block)
|
72
72
|
raise_already_invoked_error_if_necessary(__method__)
|
73
73
|
if negative?
|
74
74
|
raise "`and_return` is not supported with negative message expectations"
|
@@ -101,12 +101,12 @@ module RSpec
|
|
101
101
|
#
|
102
102
|
# allow(api).to receive(:get_foo).and_invoke(-> { raise ApiTimeout }, -> { raise ApiTimeout }, -> { :a_foo })
|
103
103
|
# api.get_foo # => raises ApiTimeout
|
104
|
-
# api.get_foo # =>
|
104
|
+
# api.get_foo # => raises ApiTimeout
|
105
105
|
# api.get_foo # => :a_foo
|
106
106
|
# api.get_foo # => :a_foo
|
107
107
|
# api.get_foo # => :a_foo
|
108
108
|
# # etc
|
109
|
-
def and_invoke(first_proc, *procs)
|
109
|
+
def and_invoke(first_proc, *procs, &_block)
|
110
110
|
raise_already_invoked_error_if_necessary(__method__)
|
111
111
|
if negative?
|
112
112
|
raise "`and_invoke` is not supported with negative message expectations"
|
@@ -748,6 +748,7 @@ module RSpec
|
|
748
748
|
|
749
749
|
proc.call(*args, &block)
|
750
750
|
end
|
751
|
+
ruby2_keywords(:call) if respond_to?(:ruby2_keywords, true)
|
751
752
|
end
|
752
753
|
|
753
754
|
# Represents a configured implementation. Takes into account
|
data/lib/rspec/mocks/proxy.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
RSpec::Support.require_rspec_support 'mutex'
|
2
|
+
|
1
3
|
module RSpec
|
2
4
|
module Mocks
|
3
5
|
# @private
|
@@ -9,11 +11,6 @@ module RSpec
|
|
9
11
|
end
|
10
12
|
end
|
11
13
|
|
12
|
-
unless defined?(Mutex)
|
13
|
-
Support.require_rspec_support 'mutex'
|
14
|
-
Mutex = Support::Mutex
|
15
|
-
end
|
16
|
-
|
17
14
|
# @private
|
18
15
|
def ensure_implemented(*_args)
|
19
16
|
# noop for basic proxies, see VerifyingProxy for behaviour.
|
@@ -27,7 +24,7 @@ module RSpec
|
|
27
24
|
@order_group = order_group
|
28
25
|
@error_generator = ErrorGenerator.new(object)
|
29
26
|
@messages_received = []
|
30
|
-
@messages_received_mutex = Mutex.new
|
27
|
+
@messages_received_mutex = Support::Mutex.new
|
31
28
|
@options = options
|
32
29
|
@null_object = false
|
33
30
|
@method_doubles = Hash.new { |h, k| h[k] = MethodDouble.new(@object, k, self) }
|
data/lib/rspec/mocks/syntax.rb
CHANGED
@@ -115,7 +115,7 @@ module RSpec
|
|
115
115
|
Matchers::Receive.new(method_name, block)
|
116
116
|
end
|
117
117
|
|
118
|
-
def receive_messages(message_return_value_hash)
|
118
|
+
def receive_messages(message_return_value_hash, &_block)
|
119
119
|
matcher = Matchers::ReceiveMessages.new(message_return_value_hash)
|
120
120
|
matcher.warn_about_block if block_given?
|
121
121
|
matcher
|
data/lib/rspec/mocks/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-mocks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.13.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Baker
|
8
8
|
- David Chelimsky
|
9
9
|
- Myron Marston
|
10
|
-
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain:
|
13
12
|
- |
|
@@ -45,7 +44,7 @@ cert_chain:
|
|
45
44
|
ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
|
46
45
|
F3MdtaDehhjC
|
47
46
|
-----END CERTIFICATE-----
|
48
|
-
date:
|
47
|
+
date: 2024-10-02 00:00:00.000000000 Z
|
49
48
|
dependencies:
|
50
49
|
- !ruby/object:Gem::Dependency
|
51
50
|
name: rspec-support
|
@@ -53,14 +52,14 @@ dependencies:
|
|
53
52
|
requirements:
|
54
53
|
- - "~>"
|
55
54
|
- !ruby/object:Gem::Version
|
56
|
-
version: 3.
|
55
|
+
version: 3.13.0
|
57
56
|
type: :runtime
|
58
57
|
prerelease: false
|
59
58
|
version_requirements: !ruby/object:Gem::Requirement
|
60
59
|
requirements:
|
61
60
|
- - "~>"
|
62
61
|
- !ruby/object:Gem::Version
|
63
|
-
version: 3.
|
62
|
+
version: 3.13.0
|
64
63
|
- !ruby/object:Gem::Dependency
|
65
64
|
name: diff-lcs
|
66
65
|
requirement: !ruby/object:Gem::Requirement
|
@@ -113,16 +112,22 @@ dependencies:
|
|
113
112
|
name: aruba
|
114
113
|
requirement: !ruby/object:Gem::Requirement
|
115
114
|
requirements:
|
116
|
-
- - "
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 1.1.0
|
118
|
+
- - "<"
|
117
119
|
- !ruby/object:Gem::Version
|
118
|
-
version:
|
120
|
+
version: 3.0.0
|
119
121
|
type: :development
|
120
122
|
prerelease: false
|
121
123
|
version_requirements: !ruby/object:Gem::Requirement
|
122
124
|
requirements:
|
123
|
-
- - "
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: 1.1.0
|
128
|
+
- - "<"
|
124
129
|
- !ruby/object:Gem::Version
|
125
|
-
version:
|
130
|
+
version: 3.0.0
|
126
131
|
- !ruby/object:Gem::Dependency
|
127
132
|
name: minitest
|
128
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -194,11 +199,10 @@ licenses:
|
|
194
199
|
- MIT
|
195
200
|
metadata:
|
196
201
|
bug_tracker_uri: https://github.com/rspec/rspec-mocks/issues
|
197
|
-
changelog_uri: https://github.com/rspec/rspec-mocks/blob/v3.
|
202
|
+
changelog_uri: https://github.com/rspec/rspec-mocks/blob/v3.13.2/Changelog.md
|
198
203
|
documentation_uri: https://rspec.info/documentation/
|
199
204
|
mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
|
200
205
|
source_code_uri: https://github.com/rspec/rspec-mocks
|
201
|
-
post_install_message:
|
202
206
|
rdoc_options:
|
203
207
|
- "--charset=UTF-8"
|
204
208
|
require_paths:
|
@@ -214,8 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
218
|
- !ruby/object:Gem::Version
|
215
219
|
version: '0'
|
216
220
|
requirements: []
|
217
|
-
rubygems_version: 3.
|
218
|
-
signing_key:
|
221
|
+
rubygems_version: 3.6.0.dev
|
219
222
|
specification_version: 4
|
220
|
-
summary: rspec-mocks-3.
|
223
|
+
summary: rspec-mocks-3.13.2
|
221
224
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|