rspec-mocks 3.13.8 → 3.13.9
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 +17 -3
- data/lib/rspec/mocks/any_instance/recorder.rb +4 -2
- data/lib/rspec/mocks/message_expectation.rb +4 -1
- data/lib/rspec/mocks/method_double.rb +13 -2
- data/lib/rspec/mocks/mutate_const.rb +30 -2
- data/lib/rspec/mocks/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +5 -5
- 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: 248d178f464f62318dd2ff83cc4c0ee1e80fc3532d58f7445192c0f2351b0b46
|
|
4
|
+
data.tar.gz: 050be6eda3da951a581556cb2947f38fe2b15dc1e62d0f35c585575817934edf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3c8ba9d5b95e54f6e3a86f170c557fb8c526c2d14f382964158f5d4d14a7e750f05377ed8971fa481206bd8752fc5707058d2871eba602b9eeda85c612d840bf
|
|
7
|
+
data.tar.gz: 0e33be8185ab494705cbfc0ae901442299e3c5776f0caa93043556d76b12956a039fab6dd2c7a4d4b901bc53c9f6b8d8b654843c86385824a061b9ef9908ee8c
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/Changelog.md
CHANGED
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
### Development
|
|
2
|
-
[Full Changelog](https://github.com/rspec/rspec/compare/rspec-mocks-v3.13.
|
|
2
|
+
[Full Changelog](https://github.com/rspec/rspec/compare/rspec-mocks-v3.13.9...3-13-maintenance)
|
|
3
|
+
|
|
4
|
+
### 3.13.9 / 2026-11-06
|
|
5
|
+
[Full Changelog](https://github.com/rspec/rspec/compare/rspec-mocks-v3.13.8...rspec-mocks-v3.13.9)
|
|
6
|
+
|
|
7
|
+
Bug Fixes:
|
|
8
|
+
|
|
9
|
+
* Prevent infinite loops when stubbing `:respond_to?` on later Rubies. (Jon Rowe, rspec/rspec#282)
|
|
10
|
+
* Declare unused block arguments to prevent a warning being issued. (Jon Rowe, rspec/rspec#349)
|
|
11
|
+
* When creating an 'any instance' mock, prevent the check of that classes ancestors from
|
|
12
|
+
creating new unused recorders. (Igor Drozdov, rspec/rspec#347)
|
|
13
|
+
* Restore the original `const_source_location` of a constant after `stub_const` or
|
|
14
|
+
`hide_const` is reset, rather than leaving it pointing at rspec-mocks. (Ngan Pham, rspec/rspec#350)
|
|
15
|
+
* Fix passing `cause` to `and_raise`, it was previously erroneously treated as a hash argument and
|
|
16
|
+
not a keyword. (Takeshi Komiya, rspec/rspec#352)
|
|
3
17
|
|
|
4
18
|
### 3.13.8 / 2026-02-27
|
|
5
19
|
[Full Changelog](https://github.com/rspec/rspec/compare/rspec-mocks-v3.13.7...rspec-mocks-v3.13.8)
|
|
6
20
|
|
|
7
21
|
Bug Fixes:
|
|
8
22
|
|
|
9
|
-
* Improve thread safety of mocks invocation recording. (Chad Wilson, #286)
|
|
10
|
-
* Expand `any_instance` warning about prepended methods to private/protected methods. (Alex Dean, #297)
|
|
23
|
+
* Improve thread safety of mocks invocation recording. (Chad Wilson, rspec/rspec#286)
|
|
24
|
+
* Expand `any_instance` warning about prepended methods to private/protected methods. (Alex Dean, rspec/rspec#297)
|
|
11
25
|
|
|
12
26
|
### 3.13.7 / 2025-10-31
|
|
13
27
|
[Full Changelog](https://github.com/rspec/rspec/compare/rspec-mocks-v3.13.6...rspec-mocks-v3.13.7)
|
|
@@ -159,8 +159,10 @@ module RSpec
|
|
|
159
159
|
def ancestor_is_an_observer?(ancestor, method_name)
|
|
160
160
|
return if ancestor == @klass
|
|
161
161
|
|
|
162
|
-
::RSpec::Mocks.space.
|
|
163
|
-
|
|
162
|
+
recorder = ::RSpec::Mocks.space.any_instance_recorder_for(ancestor, true)
|
|
163
|
+
return false unless recorder
|
|
164
|
+
|
|
165
|
+
recorder.already_observing?(method_name)
|
|
164
166
|
end
|
|
165
167
|
|
|
166
168
|
def super_class_observers_for(method_name)
|
|
@@ -14,7 +14,7 @@ module RSpec
|
|
|
14
14
|
@received = false
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
def invoke(*
|
|
17
|
+
def invoke(*_args, &_block)
|
|
18
18
|
@received = true
|
|
19
19
|
@response
|
|
20
20
|
end
|
|
@@ -167,6 +167,7 @@ module RSpec
|
|
|
167
167
|
# @overload and_raise(ExceptionClass)
|
|
168
168
|
# @overload and_raise(ExceptionClass, message)
|
|
169
169
|
# @overload and_raise(exception_instance)
|
|
170
|
+
# @overload and_raise(ExceptionClass, cause: exception)
|
|
170
171
|
#
|
|
171
172
|
# Tells the object to raise an exception when the message is received.
|
|
172
173
|
#
|
|
@@ -183,11 +184,13 @@ module RSpec
|
|
|
183
184
|
# allow(car).to receive(:go).and_raise(OutOfGas)
|
|
184
185
|
# allow(car).to receive(:go).and_raise(OutOfGas, "At least 2 oz of gas needed to drive")
|
|
185
186
|
# allow(car).to receive(:go).and_raise(OutOfGas.new(2, :oz))
|
|
187
|
+
# allow(car).to receive(:go).and_raise(OutOfGas, cause: EmptyTank.new)
|
|
186
188
|
def and_raise(*args)
|
|
187
189
|
raise_already_invoked_error_if_necessary(__method__)
|
|
188
190
|
self.terminal_implementation_action = Proc.new { raise(*args) }
|
|
189
191
|
nil
|
|
190
192
|
end
|
|
193
|
+
ruby2_keywords(:and_raise) if respond_to?(:ruby2_keywords, true)
|
|
191
194
|
|
|
192
195
|
# @overload and_throw(symbol)
|
|
193
196
|
# @overload and_throw(symbol, object)
|
|
@@ -70,8 +70,19 @@ module RSpec
|
|
|
70
70
|
|
|
71
71
|
save_original_implementation_callable!
|
|
72
72
|
definition_target.class_exec(self, method_name, @original_visibility || visibility) do |method_double, method_name, visibility|
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
if RUBY_VERSION.to_f > 3 && method_name == :respond_to?
|
|
74
|
+
define_method(method_name) do |*args, &block|
|
|
75
|
+
# This is a work around for a respond_to? check within kernel_inspect
|
|
76
|
+
if caller_locations[0].label == "Kernel#inspect"
|
|
77
|
+
super(*args, &block)
|
|
78
|
+
else
|
|
79
|
+
method_double.proxy_method_invoked(self, *args, &block)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
else
|
|
83
|
+
define_method(method_name) do |*args, &block|
|
|
84
|
+
method_double.proxy_method_invoked(self, *args, &block)
|
|
85
|
+
end
|
|
75
86
|
end
|
|
76
87
|
# This can't be `if respond_to?(:ruby2_keywords, true)`,
|
|
77
88
|
# see https://github.com/rspec/rspec-mocks/pull/1385#issuecomment-755340298
|
|
@@ -139,6 +139,9 @@ module RSpec
|
|
|
139
139
|
class BaseMutator
|
|
140
140
|
include Support::RecursiveConstMethods
|
|
141
141
|
|
|
142
|
+
CONST_SETTER_SOURCE = "lambda { |name, value| const_set(name, value) }".freeze
|
|
143
|
+
private_constant :CONST_SETTER_SOURCE if respond_to?(:private_constant)
|
|
144
|
+
|
|
142
145
|
attr_reader :original_value, :full_constant_name
|
|
143
146
|
|
|
144
147
|
def initialize(full_constant_name, mutated_value, transfer_nested_constants)
|
|
@@ -161,6 +164,29 @@ module RSpec
|
|
|
161
164
|
reset unless @reset_performed
|
|
162
165
|
@reset_performed = true
|
|
163
166
|
end
|
|
167
|
+
|
|
168
|
+
private
|
|
169
|
+
|
|
170
|
+
if RUBY_VERSION.to_f > 2.6
|
|
171
|
+
def record_original_source_location
|
|
172
|
+
@original_source_location = @context.const_source_location(@const_name, false)
|
|
173
|
+
end
|
|
174
|
+
else
|
|
175
|
+
def record_original_source_location
|
|
176
|
+
@original_source_location = nil
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def restore_original_value
|
|
181
|
+
file, line = @original_source_location
|
|
182
|
+
|
|
183
|
+
if file
|
|
184
|
+
setter = @context.module_eval(CONST_SETTER_SOURCE, file, line)
|
|
185
|
+
setter.call(@const_name, @original_value)
|
|
186
|
+
else
|
|
187
|
+
@context.const_set(@const_name, @original_value)
|
|
188
|
+
end
|
|
189
|
+
end
|
|
164
190
|
end
|
|
165
191
|
|
|
166
192
|
# Hides a defined constant for the duration of an example.
|
|
@@ -171,6 +197,7 @@ module RSpec
|
|
|
171
197
|
return unless (@defined = recursive_const_defined?(full_constant_name))
|
|
172
198
|
@context = recursive_const_get(@context_parts.join('::'))
|
|
173
199
|
@original_value = get_const_defined_on(@context, @const_name)
|
|
200
|
+
record_original_source_location
|
|
174
201
|
|
|
175
202
|
@context.__send__(:remove_const, @const_name)
|
|
176
203
|
end
|
|
@@ -187,7 +214,7 @@ module RSpec
|
|
|
187
214
|
|
|
188
215
|
def reset
|
|
189
216
|
return unless @defined
|
|
190
|
-
|
|
217
|
+
restore_original_value
|
|
191
218
|
end
|
|
192
219
|
end
|
|
193
220
|
|
|
@@ -203,6 +230,7 @@ module RSpec
|
|
|
203
230
|
def mutate
|
|
204
231
|
@context = recursive_const_get(@context_parts.join('::'))
|
|
205
232
|
@original_value = get_const_defined_on(@context, @const_name)
|
|
233
|
+
record_original_source_location
|
|
206
234
|
|
|
207
235
|
@constants_to_transfer = verify_constants_to_transfer!
|
|
208
236
|
|
|
@@ -226,7 +254,7 @@ module RSpec
|
|
|
226
254
|
end
|
|
227
255
|
|
|
228
256
|
@context.__send__(:remove_const, @const_name)
|
|
229
|
-
|
|
257
|
+
restore_original_value
|
|
230
258
|
end
|
|
231
259
|
|
|
232
260
|
def transfer_nested_constants
|
data/lib/rspec/mocks/version.rb
CHANGED
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rspec-mocks
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.13.
|
|
4
|
+
version: 3.13.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Steven Baker
|
|
@@ -136,11 +136,11 @@ licenses:
|
|
|
136
136
|
- MIT
|
|
137
137
|
metadata:
|
|
138
138
|
bug_tracker_uri: https://github.com/rspec/rspec/issues
|
|
139
|
-
changelog_uri: https://github.com/rspec/rspec/blob/rspec-mocks-v3.13.
|
|
139
|
+
changelog_uri: https://github.com/rspec/rspec/blob/rspec-mocks-v3.13.9/rspec-mocks/Changelog.md
|
|
140
140
|
documentation_uri: https://rspec.info/documentation/
|
|
141
141
|
mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
|
|
142
142
|
rubygems_mfa_required: 'true'
|
|
143
|
-
source_code_uri: https://github.com/rspec/rspec/blob/rspec-mocks-v3.13.
|
|
143
|
+
source_code_uri: https://github.com/rspec/rspec/blob/rspec-mocks-v3.13.9/rspec-mocks
|
|
144
144
|
rdoc_options:
|
|
145
145
|
- "--charset=UTF-8"
|
|
146
146
|
require_paths:
|
|
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
156
156
|
- !ruby/object:Gem::Version
|
|
157
157
|
version: '0'
|
|
158
158
|
requirements: []
|
|
159
|
-
rubygems_version: 4.0.
|
|
159
|
+
rubygems_version: 4.0.20
|
|
160
160
|
specification_version: 4
|
|
161
|
-
summary: rspec-mocks-3.13.
|
|
161
|
+
summary: rspec-mocks-3.13.9
|
|
162
162
|
test_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|