rspec-mocks 3.12.0 → 3.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/Changelog.md +73 -1
- data/README.md +2 -0
- data/lib/rspec/mocks/any_instance/message_chains.rb +1 -1
- data/lib/rspec/mocks/any_instance/proxy.rb +12 -3
- data/lib/rspec/mocks/any_instance/recorder.rb +11 -9
- data/lib/rspec/mocks/argument_list_matcher.rb +3 -1
- data/lib/rspec/mocks/argument_matchers.rb +51 -7
- data/lib/rspec/mocks/error_generator.rb +14 -4
- data/lib/rspec/mocks/matchers/have_received.rb +1 -1
- data/lib/rspec/mocks/matchers/receive.rb +3 -2
- data/lib/rspec/mocks/matchers/receive_message_chain.rb +1 -1
- data/lib/rspec/mocks/matchers/receive_messages.rb +1 -1
- data/lib/rspec/mocks/method_double.rb +30 -5
- data/lib/rspec/mocks/minitest_integration.rb +1 -1
- data/lib/rspec/mocks/mutate_const.rb +1 -1
- data/lib/rspec/mocks/proxy.rb +3 -8
- data/lib/rspec/mocks/space.rb +1 -1
- data/lib/rspec/mocks/targets.rb +1 -1
- data/lib/rspec/mocks/verifying_double.rb +2 -0
- data/lib/rspec/mocks/verifying_proxy.rb +4 -3
- data/lib/rspec/mocks/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +19 -13
- 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: 71211650b0472cd386136d98bc36d04f66c9944aa4ef5da7bf72541c6847b0d3
|
4
|
+
data.tar.gz: e0fe8ffaa23df6885b6be3b11a1ed53a65ab750c7e969d0477a3a0af6ef343a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d389141c0abec2c4bae1008f96b34978b6d576d2ed229f96ca1eff3af1bf47a78d95d37f30630e7dbd0346483b140982d2a3aa2b80663058e61b7ba4fe4fec5
|
7
|
+
data.tar.gz: 21c8cab0cf3ec3ea8dcc485dcd36301bea5dba1f4828c0f924d0e32f028870f3b3e793adb4553dc09931ec33bd0990189c5c36b24bb7cb166fd0635bdff4b2e7
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/Changelog.md
CHANGED
@@ -1,5 +1,77 @@
|
|
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.0...main)
|
3
|
+
|
4
|
+
### 3.13.0 / 2024-02-04
|
5
|
+
[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.12.7...v3.13.0)
|
6
|
+
|
7
|
+
Enhancements:
|
8
|
+
|
9
|
+
* Add an `array_excluding` matcher for arguments. (Zane Wolfgang Pickett, #1528)
|
10
|
+
|
11
|
+
### 3.12.7 / 2024-02-04
|
12
|
+
[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.12.6...v3.12.7)
|
13
|
+
|
14
|
+
Bug Fixes:
|
15
|
+
|
16
|
+
* Reduce allocations from "any_instance" style mocks. (Carlos Palhares, #1479)
|
17
|
+
|
18
|
+
### 3.12.6 / 2023-07-11
|
19
|
+
[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.12.5...v3.12.6)
|
20
|
+
|
21
|
+
Bug Fixes:
|
22
|
+
|
23
|
+
* Fix an issue with `and_call_original` when using the `method_missing` fallback
|
24
|
+
with keyword arguments. (Igor Drozdov, #1552)
|
25
|
+
|
26
|
+
### 3.12.5 / 2023-03-30
|
27
|
+
[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.12.4...v3.12.5)
|
28
|
+
|
29
|
+
Bug Fixes:
|
30
|
+
|
31
|
+
* Fix compatibility issue with Rails where active_support monkey patches `with`
|
32
|
+
when using any instance. (Lachlan Sylvester, #1540)
|
33
|
+
|
34
|
+
### 3.12.4 / 2023-03-12
|
35
|
+
[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.12.3...v3.12.4)
|
36
|
+
|
37
|
+
Bug Fixes:
|
38
|
+
|
39
|
+
* Fix an issue with asserting that Array#reverse is never called. (Brad Trick, #1533)
|
40
|
+
* Fix compatibility issue with Rails where active_support monkey patches `with`.
|
41
|
+
(Jean Boussier, #1531, #1534)
|
42
|
+
|
43
|
+
### 3.12.3 / 2023-01-17
|
44
|
+
[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.12.2...v3.12.3)
|
45
|
+
|
46
|
+
Bug Fixes:
|
47
|
+
|
48
|
+
* Fix keyword delegation in `send` for verifying doubles on Ruby 3.
|
49
|
+
(Charlie Honig, #1485)
|
50
|
+
|
51
|
+
### 3.12.2 / 2023-01-07
|
52
|
+
[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.12.1...v3.12.2)
|
53
|
+
|
54
|
+
Bug Fixes:
|
55
|
+
|
56
|
+
* Fix implementation blocks for mocks using keyword arguments on Ruby 3.2.0.
|
57
|
+
(Adam Steel, #1508)
|
58
|
+
* Fix keyword argument assertions when mocking using `with` on Ruby 3.2.0.
|
59
|
+
(Slava Kardakov, Benoit Tigeot, Phil Pirozhkov, Benoit Daloze, #1514)
|
60
|
+
|
61
|
+
### 3.12.1 / 2022-12-10
|
62
|
+
[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.12.0...v3.12.1)
|
63
|
+
|
64
|
+
Bug Fixes:
|
65
|
+
|
66
|
+
* Remove empty diff marker when a diff only contains console codes. (Jon Rowe, #1506)
|
67
|
+
* Show keyword vs hash diff marker when arguments are not `==` (Jon Rowe, #1506)
|
68
|
+
* Change check to detect frozen objects to rescue errors rather than
|
69
|
+
pre-empting by checking `frozen?` due to some objects mis-behaving.
|
70
|
+
(Keegan Roth, #1401)
|
71
|
+
* Prevent unfulfilled expectations using `expect_any_instance_of` across a class
|
72
|
+
inheritance boundary from raising rather than failing. (Jon Rowe, #1496)
|
73
|
+
* Prevent a misleading error message when using `allow(...).not_to` with
|
74
|
+
unsupported matchers. (Phil Pirozhkov, #1503)
|
3
75
|
|
4
76
|
### 3.12.0 / 2022-10-26
|
5
77
|
[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.11.2...v3.12.0)
|
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
|
@@ -49,7 +49,7 @@ module RSpec
|
|
49
49
|
# @private
|
50
50
|
def unfulfilled_expectations
|
51
51
|
@chains_by_method_name.map do |method_name, chains|
|
52
|
-
method_name.to_s if ExpectationChain === chains.last
|
52
|
+
method_name.to_s if ExpectationChain === chains.last && !chains.last.expectation_fulfilled?
|
53
53
|
end.compact
|
54
54
|
end
|
55
55
|
|
@@ -10,7 +10,7 @@ module RSpec
|
|
10
10
|
#
|
11
11
|
# This proxy sits in front of the recorder and delegates both to it
|
12
12
|
# and to the `RSpec::Mocks::Proxy` for each already mocked or stubbed
|
13
|
-
# instance of the class, in order to
|
13
|
+
# instance of the class, in order to propagates changes to the instances.
|
14
14
|
#
|
15
15
|
# Note that unlike `RSpec::Mocks::Proxy`, this proxy class is stateless
|
16
16
|
# and is not persisted in `RSpec::Mocks.space`.
|
@@ -83,6 +83,15 @@ module RSpec
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
+
unless defined?(BasicObject)
|
87
|
+
class BasicObject
|
88
|
+
# Remove all methods except those expected to be defined on BasicObject
|
89
|
+
(instance_methods.map(&:to_sym) - [:__send__, :"!", :instance_eval, :==, :instance_exec, :"!=", :equal?, :__id__, :__binding__, :object_id]).each do |method|
|
90
|
+
undef_method method
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
86
95
|
# @private
|
87
96
|
# Delegates messages to each of the given targets in order to
|
88
97
|
# provide the fluent interface that is available off of message
|
@@ -91,12 +100,12 @@ module RSpec
|
|
91
100
|
# `targets` will typically contain 1 of the `AnyInstance::Recorder`
|
92
101
|
# return values and N `MessageExpectation` instances (one per instance
|
93
102
|
# of the `any_instance` klass).
|
94
|
-
class FluentInterfaceProxy
|
103
|
+
class FluentInterfaceProxy < BasicObject
|
95
104
|
def initialize(targets)
|
96
105
|
@targets = targets
|
97
106
|
end
|
98
107
|
|
99
|
-
if RUBY_VERSION.to_f > 1.8
|
108
|
+
if ::RUBY_VERSION.to_f > 1.8
|
100
109
|
def respond_to_missing?(method_name, include_private=false)
|
101
110
|
super || @targets.first.respond_to?(method_name, include_private)
|
102
111
|
end
|
@@ -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)
|
@@ -61,7 +61,9 @@ module RSpec
|
|
61
61
|
return false if expected_args.size != actual_args.size
|
62
62
|
|
63
63
|
if RUBY_VERSION >= "3"
|
64
|
-
#
|
64
|
+
# If the expectation was set with keywords, while the actual method was called with a positional hash argument, they don't match.
|
65
|
+
# If the expectation was set without keywords, e.g., with({a: 1}), then it fine to call it with either foo(a: 1) or foo({a: 1}).
|
66
|
+
# This corresponds to Ruby semantics, as if the method was def foo(options).
|
65
67
|
if Hash === expected_args.last && Hash === actual_args.last
|
66
68
|
if !Hash.ruby2_keywords_hash?(actual_args.last) && Hash.ruby2_keywords_hash?(expected_args.last)
|
67
69
|
return false
|
@@ -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
|
@@ -269,13 +269,19 @@ module RSpec
|
|
269
269
|
expected_args = format_args(expectation.expected_args)
|
270
270
|
actual_args = format_received_args(args_for_multiple_calls)
|
271
271
|
|
272
|
-
if RSpec::Support::RubyFeatures.distincts_kw_args_from_positional_hash?
|
272
|
+
if RSpec::Support::RubyFeatures.distincts_kw_args_from_positional_hash?
|
273
273
|
expected_hash = expectation.expected_args.last
|
274
274
|
actual_hash = args_for_multiple_calls.last.last
|
275
275
|
if Hash === expected_hash && Hash === actual_hash &&
|
276
276
|
(Hash.ruby2_keywords_hash?(expected_hash) != Hash.ruby2_keywords_hash?(actual_hash))
|
277
|
-
|
278
|
-
|
277
|
+
|
278
|
+
actual_description = Hash.ruby2_keywords_hash?(actual_hash) ? " (keyword arguments)" : " (options hash)"
|
279
|
+
expected_description = Hash.ruby2_keywords_hash?(expected_hash) ? " (keyword arguments)" : " (options hash)"
|
280
|
+
|
281
|
+
if actual_description != expected_description
|
282
|
+
actual_args += actual_description
|
283
|
+
expected_args += expected_description
|
284
|
+
end
|
279
285
|
end
|
280
286
|
end
|
281
287
|
|
@@ -283,7 +289,11 @@ module RSpec
|
|
283
289
|
|
284
290
|
if args_for_multiple_calls.one?
|
285
291
|
diff = diff_message(expectation.expected_args, args_for_multiple_calls.first)
|
286
|
-
|
292
|
+
if RSpec::Mocks.configuration.color?
|
293
|
+
message << "\nDiff:#{diff}" unless diff.gsub(/\e\[\d+m/, '').strip.empty?
|
294
|
+
else
|
295
|
+
message << "\nDiff:#{diff}" unless diff.strip.empty?
|
296
|
+
end
|
287
297
|
end
|
288
298
|
|
289
299
|
message
|
@@ -13,7 +13,7 @@ module RSpec
|
|
13
13
|
@recorded_customizations = []
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
16
|
+
def matcher_name
|
17
17
|
"receive"
|
18
18
|
end
|
19
19
|
|
@@ -55,8 +55,9 @@ module RSpec
|
|
55
55
|
setup_any_instance_method_substitute(subject, :stub, block)
|
56
56
|
end
|
57
57
|
|
58
|
+
own_methods = (instance_methods - superclass.instance_methods)
|
58
59
|
MessageExpectation.public_instance_methods(false).each do |method|
|
59
|
-
next if
|
60
|
+
next if own_methods.include?(method)
|
60
61
|
|
61
62
|
define_method(method) do |*args, &block|
|
62
63
|
@recorded_customizations << ExpectationCustomization.new(method, args, block)
|
@@ -2,6 +2,9 @@ module RSpec
|
|
2
2
|
module Mocks
|
3
3
|
# @private
|
4
4
|
class MethodDouble
|
5
|
+
# @private TODO: drop in favor of FrozenError in ruby 2.5+
|
6
|
+
FROZEN_ERROR_MSG = /can't modify frozen/
|
7
|
+
|
5
8
|
# @private
|
6
9
|
attr_reader :method_name, :object, :expectations, :stubs, :method_stasher
|
7
10
|
|
@@ -23,10 +26,7 @@ module RSpec
|
|
23
26
|
# handler of the object. This accounts for cases where the user has not
|
24
27
|
# correctly defined `respond_to?`, and also 1.8 which does not provide
|
25
28
|
# method handles for missing methods even if `respond_to?` is correct.
|
26
|
-
@original_implementation_callable ||= original_method ||
|
27
|
-
Proc.new do |*args, &block|
|
28
|
-
@object.__send__(:method_missing, @method_name, *args, &block)
|
29
|
-
end
|
29
|
+
@original_implementation_callable ||= original_method || method_missing_block
|
30
30
|
end
|
31
31
|
|
32
32
|
alias_method :save_original_implementation_callable!, :original_implementation_callable
|
@@ -37,6 +37,16 @@ module RSpec
|
|
37
37
|
@proxy.original_method_handle_for(method_name)
|
38
38
|
end
|
39
39
|
|
40
|
+
# @private
|
41
|
+
def method_missing_block
|
42
|
+
block = Proc.new do |*args, &b|
|
43
|
+
@object.__send__(:method_missing, @method_name, *args, &b)
|
44
|
+
end
|
45
|
+
block.ruby2_keywords if block.respond_to?(:ruby2_keywords)
|
46
|
+
|
47
|
+
block
|
48
|
+
end
|
49
|
+
|
40
50
|
# @private
|
41
51
|
def visibility
|
42
52
|
@proxy.visibility_for(@method_name)
|
@@ -70,6 +80,14 @@ module RSpec
|
|
70
80
|
end
|
71
81
|
|
72
82
|
@method_is_proxied = true
|
83
|
+
rescue RuntimeError, TypeError => e
|
84
|
+
# TODO: drop in favor of FrozenError in ruby 2.5+
|
85
|
+
# RuntimeError (and FrozenError) for ruby 2.x
|
86
|
+
# TypeError for ruby 1.x
|
87
|
+
if (defined?(FrozenError) && e.is_a?(FrozenError)) || FROZEN_ERROR_MSG === e.message
|
88
|
+
raise ArgumentError, "Cannot proxy frozen objects, rspec-mocks relies on proxies for method stubbing and expectations."
|
89
|
+
end
|
90
|
+
raise
|
73
91
|
end
|
74
92
|
|
75
93
|
# The implementation of the proxied method. Subclasses may override this
|
@@ -83,7 +101,6 @@ module RSpec
|
|
83
101
|
|
84
102
|
# @private
|
85
103
|
def restore_original_method
|
86
|
-
return show_frozen_warning if object_singleton_class.frozen?
|
87
104
|
return unless @method_is_proxied
|
88
105
|
|
89
106
|
remove_method_from_definition_target
|
@@ -91,6 +108,14 @@ module RSpec
|
|
91
108
|
restore_original_visibility
|
92
109
|
|
93
110
|
@method_is_proxied = false
|
111
|
+
rescue RuntimeError, TypeError => e
|
112
|
+
# TODO: drop in favor of FrozenError in ruby 2.5+
|
113
|
+
# RuntimeError (and FrozenError) for ruby 2.x
|
114
|
+
# TypeError for ruby 1.x
|
115
|
+
if (defined?(FrozenError) && e.is_a?(FrozenError)) || FROZEN_ERROR_MSG === e.message
|
116
|
+
return show_frozen_warning
|
117
|
+
end
|
118
|
+
raise
|
94
119
|
end
|
95
120
|
|
96
121
|
# @private
|
@@ -37,7 +37,7 @@ if defined?(::Minitest::Expectation)
|
|
37
37
|
# not want to here (or else we would interfere with rspec-expectations' definition).
|
38
38
|
else
|
39
39
|
# ...otherwise, define those methods now. If `rspec/expectations/minitest_integration`
|
40
|
-
# is loaded after this file, it'll
|
40
|
+
# is loaded after this file, it'll override the definition here.
|
41
41
|
Minitest::Expectation.class_eval do
|
42
42
|
include RSpec::Mocks::ExpectationTargetMethods
|
43
43
|
|
@@ -81,7 +81,7 @@ module RSpec
|
|
81
81
|
# Queries rspec-mocks to find out information about the named constant.
|
82
82
|
#
|
83
83
|
# @param [String] name the name of the constant
|
84
|
-
# @return [Constant] an object
|
84
|
+
# @return [Constant] an object containing information about the named
|
85
85
|
# constant.
|
86
86
|
def self.original(name)
|
87
87
|
mutator = ::RSpec::Mocks.space.constant_mutator_for(name)
|
data/lib/rspec/mocks/proxy.rb
CHANGED
@@ -35,15 +35,9 @@ module RSpec
|
|
35
35
|
|
36
36
|
# @private
|
37
37
|
def ensure_can_be_proxied!(object)
|
38
|
-
return unless object.is_a?(Symbol)
|
39
|
-
return if object.nil?
|
38
|
+
return unless object.is_a?(Symbol)
|
40
39
|
|
41
|
-
msg = "Cannot proxy frozen objects"
|
42
|
-
if Symbol === object
|
43
|
-
msg << ". Symbols such as #{object} cannot be mocked or stubbed."
|
44
|
-
else
|
45
|
-
msg << ", rspec-mocks relies on proxies for method stubbing and expectations."
|
46
|
-
end
|
40
|
+
msg = "Cannot proxy frozen objects. Symbols such as #{object} cannot be mocked or stubbed."
|
47
41
|
raise ArgumentError, msg
|
48
42
|
end
|
49
43
|
|
@@ -198,6 +192,7 @@ module RSpec
|
|
198
192
|
@messages_received << [message, args, block]
|
199
193
|
end
|
200
194
|
end
|
195
|
+
ruby2_keywords :record_message_received if respond_to?(:ruby2_keywords, true)
|
201
196
|
|
202
197
|
# @private
|
203
198
|
def message_received(message, *args, &block)
|
data/lib/rspec/mocks/space.rb
CHANGED
@@ -77,9 +77,9 @@ module RSpec
|
|
77
77
|
|
78
78
|
def reset_all
|
79
79
|
proxies.each_value { |proxy| proxy.reset }
|
80
|
-
@constant_mutators.reverse.each { |mut| mut.idempotently_reset }
|
81
80
|
any_instance_recorders.each_value { |recorder| recorder.stop_all_observation! }
|
82
81
|
any_instance_recorders.clear
|
82
|
+
@constant_mutators.reverse.each { |mut| mut.idempotently_reset }
|
83
83
|
end
|
84
84
|
|
85
85
|
def register_constant_mutator(mutator)
|
data/lib/rspec/mocks/targets.rb
CHANGED
@@ -54,7 +54,7 @@ module RSpec
|
|
54
54
|
|
55
55
|
def raise_negation_unsupported(method_name, matcher)
|
56
56
|
raise NegationUnsupportedError,
|
57
|
-
"`#{expression}(...).#{method_name} #{matcher.
|
57
|
+
"`#{expression}(...).#{method_name} #{matcher.matcher_name}` is not supported since it " \
|
58
58
|
"doesn't really make sense. What would it even mean?"
|
59
59
|
end
|
60
60
|
end
|
@@ -42,11 +42,13 @@ module RSpec
|
|
42
42
|
ensure
|
43
43
|
@__sending_message = nil
|
44
44
|
end
|
45
|
+
ruby2_keywords :__send__ if respond_to?(:ruby2_keywords, true)
|
45
46
|
$VERBOSE = old
|
46
47
|
|
47
48
|
def send(name, *args, &block)
|
48
49
|
__send__(name, *args, &block)
|
49
50
|
end
|
51
|
+
ruby2_keywords :send if respond_to?(:ruby2_keywords, true)
|
50
52
|
|
51
53
|
def initialize(doubled_module, *args)
|
52
54
|
@doubled_module = doubled_module
|
@@ -57,7 +57,7 @@ module RSpec
|
|
57
57
|
# A verifying proxy mostly acts like a normal proxy, except that it
|
58
58
|
# contains extra logic to try and determine the validity of any expectation
|
59
59
|
# set on it. This includes whether or not methods have been defined and the
|
60
|
-
#
|
60
|
+
# validity of arguments on method calls.
|
61
61
|
#
|
62
62
|
# In all other ways this behaves like a normal proxy. It only adds the
|
63
63
|
# verification behaviour to specific methods then delegates to the parent
|
@@ -147,12 +147,12 @@ module RSpec
|
|
147
147
|
end
|
148
148
|
|
149
149
|
def add_expectation(*args, &block)
|
150
|
-
#
|
150
|
+
# explicit params necessary for 1.8.7 see #626
|
151
151
|
super(*args, &block).tap { |x| x.method_reference = @method_reference }
|
152
152
|
end
|
153
153
|
|
154
154
|
def add_stub(*args, &block)
|
155
|
-
#
|
155
|
+
# explicit params necessary for 1.8.7 see #626
|
156
156
|
super(*args, &block).tap { |x| x.method_reference = @method_reference }
|
157
157
|
end
|
158
158
|
|
@@ -160,6 +160,7 @@ module RSpec
|
|
160
160
|
validate_arguments!(args)
|
161
161
|
super
|
162
162
|
end
|
163
|
+
ruby2_keywords :proxy_method_invoked if respond_to?(:ruby2_keywords, true)
|
163
164
|
|
164
165
|
def validate_arguments!(actual_args)
|
165
166
|
@method_reference.with_signature do |signature|
|
data/lib/rspec/mocks/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
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.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Baker
|
8
8
|
- David Chelimsky
|
9
9
|
- Myron Marston
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain:
|
13
13
|
- |
|
@@ -45,7 +45,7 @@ cert_chain:
|
|
45
45
|
ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
|
46
46
|
F3MdtaDehhjC
|
47
47
|
-----END CERTIFICATE-----
|
48
|
-
date:
|
48
|
+
date: 2024-02-04 00:00:00.000000000 Z
|
49
49
|
dependencies:
|
50
50
|
- !ruby/object:Gem::Dependency
|
51
51
|
name: rspec-support
|
@@ -53,14 +53,14 @@ dependencies:
|
|
53
53
|
requirements:
|
54
54
|
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: 3.
|
56
|
+
version: 3.13.0
|
57
57
|
type: :runtime
|
58
58
|
prerelease: false
|
59
59
|
version_requirements: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
61
|
- - "~>"
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: 3.
|
63
|
+
version: 3.13.0
|
64
64
|
- !ruby/object:Gem::Dependency
|
65
65
|
name: diff-lcs
|
66
66
|
requirement: !ruby/object:Gem::Requirement
|
@@ -113,16 +113,22 @@ dependencies:
|
|
113
113
|
name: aruba
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
|
-
- - "
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 1.1.0
|
119
|
+
- - "<"
|
117
120
|
- !ruby/object:Gem::Version
|
118
|
-
version: 0.
|
121
|
+
version: 3.0.0
|
119
122
|
type: :development
|
120
123
|
prerelease: false
|
121
124
|
version_requirements: !ruby/object:Gem::Requirement
|
122
125
|
requirements:
|
123
|
-
- - "
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: 1.1.0
|
129
|
+
- - "<"
|
124
130
|
- !ruby/object:Gem::Version
|
125
|
-
version: 0.
|
131
|
+
version: 3.0.0
|
126
132
|
- !ruby/object:Gem::Dependency
|
127
133
|
name: minitest
|
128
134
|
requirement: !ruby/object:Gem::Requirement
|
@@ -194,11 +200,11 @@ licenses:
|
|
194
200
|
- MIT
|
195
201
|
metadata:
|
196
202
|
bug_tracker_uri: https://github.com/rspec/rspec-mocks/issues
|
197
|
-
changelog_uri: https://github.com/rspec/rspec-mocks/blob/v3.
|
203
|
+
changelog_uri: https://github.com/rspec/rspec-mocks/blob/v3.13.0/Changelog.md
|
198
204
|
documentation_uri: https://rspec.info/documentation/
|
199
205
|
mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
|
200
206
|
source_code_uri: https://github.com/rspec/rspec-mocks
|
201
|
-
post_install_message:
|
207
|
+
post_install_message:
|
202
208
|
rdoc_options:
|
203
209
|
- "--charset=UTF-8"
|
204
210
|
require_paths:
|
@@ -215,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
215
221
|
version: '0'
|
216
222
|
requirements: []
|
217
223
|
rubygems_version: 3.1.6
|
218
|
-
signing_key:
|
224
|
+
signing_key:
|
219
225
|
specification_version: 4
|
220
|
-
summary: rspec-mocks-3.
|
226
|
+
summary: rspec-mocks-3.13.0
|
221
227
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|