rspec-mocks 3.11.2 → 3.12.1
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 +25 -2
- data/lib/rspec/mocks/any_instance/message_chains.rb +1 -1
- data/lib/rspec/mocks/error_generator.rb +22 -1
- data/lib/rspec/mocks/matchers/have_received.rb +1 -1
- data/lib/rspec/mocks/matchers/receive.rb +1 -1
- 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 +19 -1
- data/lib/rspec/mocks/proxy.rb +2 -8
- data/lib/rspec/mocks/targets.rb +1 -1
- data/lib/rspec/mocks/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +7 -7
- 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: 26d2a0b4b29906b9299801a379eafbad373822822ad30b769ef2bef2e9a4b22b
|
4
|
+
data.tar.gz: b2196b0f0111c48cb88398bb1071c9047fa637853da0ac684fc3d57d5ec7fc71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c96f4c1dc4c9f99e0d222c2aeb054d5aa6d18a7b18e58df7a2235644c3d91745590346cb74ef8102420e658d748ded36ce1c90727bac6158770e3625f4817aed
|
7
|
+
data.tar.gz: 7539266eec67cb3e522855f9a446b9e8a90aef2947d19ce01c69c4e2c6be033cf0e0c01f8b115d0d2f08fc7391e81e355514aeaaa3dc1364bff147bf489e1d19
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/Changelog.md
CHANGED
@@ -1,8 +1,31 @@
|
|
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.12.1...3-12-maintenance)
|
3
|
+
|
4
|
+
### 3.12.1 / 2022-12-10
|
5
|
+
[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.12.0...v3.12.1)
|
6
|
+
|
7
|
+
Bug Fixes:
|
8
|
+
|
9
|
+
* Remove empty diff marker when a diff only contains console codes. (Jon Rowe, #1506)
|
10
|
+
* Show keyword vs hash diff marker when arguments are not `==` (Jon Rowe, #1506)
|
11
|
+
* Change check to detect frozen objects to rescue errors rather than
|
12
|
+
pre-empting by checking `frozen?` due to some objects mis-behaving.
|
13
|
+
(Keegan Roth, #1401)
|
14
|
+
* Prevent unfulfilled expectations using `expect_any_instance_of` across a class
|
15
|
+
inheritance boundary from raising rather than failing. (Jon Rowe, #1496)
|
16
|
+
* Prevent a misleading error message when using `allow(...).not_to` with
|
17
|
+
unsupported matchers. (Phil Pirozhkov, #1503)
|
18
|
+
|
19
|
+
### 3.12.0 / 2022-10-26
|
20
|
+
[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.11.2...v3.12.0)
|
21
|
+
|
22
|
+
Enhancements:
|
23
|
+
|
24
|
+
* Improve diff output when diffing keyword arguments against hashes.
|
25
|
+
(Jean Boussier, #1461)
|
3
26
|
|
4
27
|
### 3.11.2 / 2022-10-25
|
5
|
-
[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.11.1...
|
28
|
+
[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.11.1...v3.11.2)
|
6
29
|
|
7
30
|
Bug Fixes:
|
8
31
|
|
@@ -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
|
|
@@ -268,11 +268,32 @@ module RSpec
|
|
268
268
|
def error_message(expectation, args_for_multiple_calls)
|
269
269
|
expected_args = format_args(expectation.expected_args)
|
270
270
|
actual_args = format_received_args(args_for_multiple_calls)
|
271
|
+
|
272
|
+
if RSpec::Support::RubyFeatures.distincts_kw_args_from_positional_hash?
|
273
|
+
expected_hash = expectation.expected_args.last
|
274
|
+
actual_hash = args_for_multiple_calls.last.last
|
275
|
+
if Hash === expected_hash && Hash === actual_hash &&
|
276
|
+
(Hash.ruby2_keywords_hash?(expected_hash) != Hash.ruby2_keywords_hash?(actual_hash))
|
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
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
271
288
|
message = default_error_message(expectation, expected_args, actual_args)
|
272
289
|
|
273
290
|
if args_for_multiple_calls.one?
|
274
291
|
diff = diff_message(expectation.expected_args, args_for_multiple_calls.first)
|
275
|
-
|
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
|
276
297
|
end
|
277
298
|
|
278
299
|
message
|
@@ -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
|
|
@@ -70,6 +73,14 @@ module RSpec
|
|
70
73
|
end
|
71
74
|
|
72
75
|
@method_is_proxied = true
|
76
|
+
rescue RuntimeError, TypeError => e
|
77
|
+
# TODO: drop in favor of FrozenError in ruby 2.5+
|
78
|
+
# RuntimeError (and FrozenError) for ruby 2.x
|
79
|
+
# TypeError for ruby 1.x
|
80
|
+
if (defined?(FrozenError) && e.is_a?(FrozenError)) || FROZEN_ERROR_MSG === e.message
|
81
|
+
raise ArgumentError, "Cannot proxy frozen objects, rspec-mocks relies on proxies for method stubbing and expectations."
|
82
|
+
end
|
83
|
+
raise
|
73
84
|
end
|
74
85
|
|
75
86
|
# The implementation of the proxied method. Subclasses may override this
|
@@ -83,7 +94,6 @@ module RSpec
|
|
83
94
|
|
84
95
|
# @private
|
85
96
|
def restore_original_method
|
86
|
-
return show_frozen_warning if object_singleton_class.frozen?
|
87
97
|
return unless @method_is_proxied
|
88
98
|
|
89
99
|
remove_method_from_definition_target
|
@@ -91,6 +101,14 @@ module RSpec
|
|
91
101
|
restore_original_visibility
|
92
102
|
|
93
103
|
@method_is_proxied = false
|
104
|
+
rescue RuntimeError, TypeError => e
|
105
|
+
# TODO: drop in favor of FrozenError in ruby 2.5+
|
106
|
+
# RuntimeError (and FrozenError) for ruby 2.x
|
107
|
+
# TypeError for ruby 1.x
|
108
|
+
if (defined?(FrozenError) && e.is_a?(FrozenError)) || FROZEN_ERROR_MSG === e.message
|
109
|
+
return show_frozen_warning
|
110
|
+
end
|
111
|
+
raise
|
94
112
|
end
|
95
113
|
|
96
114
|
# @private
|
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
|
|
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
|
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.
|
4
|
+
version: 3.12.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Baker
|
@@ -45,7 +45,7 @@ cert_chain:
|
|
45
45
|
ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
|
46
46
|
F3MdtaDehhjC
|
47
47
|
-----END CERTIFICATE-----
|
48
|
-
date: 2022-10
|
48
|
+
date: 2022-12-10 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.12.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.12.0
|
64
64
|
- !ruby/object:Gem::Dependency
|
65
65
|
name: diff-lcs
|
66
66
|
requirement: !ruby/object:Gem::Requirement
|
@@ -194,7 +194,7 @@ licenses:
|
|
194
194
|
- MIT
|
195
195
|
metadata:
|
196
196
|
bug_tracker_uri: https://github.com/rspec/rspec-mocks/issues
|
197
|
-
changelog_uri: https://github.com/rspec/rspec-mocks/blob/v3.
|
197
|
+
changelog_uri: https://github.com/rspec/rspec-mocks/blob/v3.12.1/Changelog.md
|
198
198
|
documentation_uri: https://rspec.info/documentation/
|
199
199
|
mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
|
200
200
|
source_code_uri: https://github.com/rspec/rspec-mocks
|
@@ -214,8 +214,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
214
|
- !ruby/object:Gem::Version
|
215
215
|
version: '0'
|
216
216
|
requirements: []
|
217
|
-
rubygems_version: 3.
|
217
|
+
rubygems_version: 3.3.26
|
218
218
|
signing_key:
|
219
219
|
specification_version: 4
|
220
|
-
summary: rspec-mocks-3.
|
220
|
+
summary: rspec-mocks-3.12.1
|
221
221
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|