rspec-expectations 3.13.1 → 3.13.3
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 +20 -1
- data/lib/rspec/expectations/block_snippet_extractor.rb +2 -0
- data/lib/rspec/expectations/configuration.rb +5 -0
- data/lib/rspec/expectations/failure_aggregator.rb +7 -0
- data/lib/rspec/expectations/handler.rb +4 -5
- data/lib/rspec/expectations/version.rb +1 -1
- data/lib/rspec/matchers/built_in/base_matcher.rb +4 -18
- data/lib/rspec/matchers/built_in/change.rb +2 -0
- data/lib/rspec/matchers/built_in/compound.rb +4 -1
- data/lib/rspec/matchers/built_in/contain_exactly.rb +2 -0
- data/lib/rspec/matchers/built_in/count_expectation.rb +2 -0
- data/lib/rspec/matchers/built_in/has.rb +29 -2
- data/lib/rspec/matchers/built_in/include.rb +5 -0
- data/lib/rspec/matchers/built_in/match.rb +2 -0
- data/lib/rspec/matchers/built_in/satisfy.rb +2 -0
- data/lib/rspec/matchers/english_phrasing.rb +2 -0
- data/lib/rspec/matchers.rb +2 -0
- 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: 2326091f61f5fccf3b86b2275c850340614475381f32a9f22417cb9f59b80ab3
|
4
|
+
data.tar.gz: 7602b8b98d0dc9fecc754156a01686a131fedd6d43fe1b8ce8f689f0fba3b469
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21d9a95f4e9cb3fa1b7fb99419861bc90a39ee33b4fa183a1018ab351d830168bd93fb02e00452344e1c8d9824bc3d0543b988e42288396c8a3091b9fc5d6f9c
|
7
|
+
data.tar.gz: ec4864365250340370d370af68dee725f3d018e414e57506d21d173e9d0a69a9df258f7d7a11e8f2ff583f4060348a76bb3251aa09a29add0ddee6fb2b0d4192
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/Changelog.md
CHANGED
@@ -1,5 +1,24 @@
|
|
1
1
|
### Development
|
2
|
-
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.13.
|
2
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.13.3...3-13-maintenance)
|
3
|
+
|
4
|
+
### 3.13.3 / 2024-09-07
|
5
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.13.2...v3.13.3)
|
6
|
+
|
7
|
+
Bug Fixes:
|
8
|
+
|
9
|
+
* Fix passing a regular expression to the `include` matcher without a count constraint.
|
10
|
+
(Jon Rowe, #1485)
|
11
|
+
|
12
|
+
### 3.13.2 / 2024-08-20
|
13
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.13.1...v3.13.2)
|
14
|
+
|
15
|
+
Bug Fixes:
|
16
|
+
|
17
|
+
* When using null object doubles, prevent typos triggering dynamic matchers.
|
18
|
+
(Eric Mueller, #1455)
|
19
|
+
* Use `RSpec.warning` for an expectation warning rather than `Kernel.warn`. (Jon Rowe, #1472)
|
20
|
+
* Prevent mismatched use of block and value matchers in compound expectations. (Phil Pirozhkov, #1476)
|
21
|
+
* Raise an error when passing no arguments to the `include` matcher. (Eric Mueller, #1479)
|
3
22
|
|
4
23
|
### 3.13.1 / 2024-06-13
|
5
24
|
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.13.0...v3.13.1)
|
@@ -46,11 +46,13 @@ module RSpec
|
|
46
46
|
RSpec.world.source_from_file(file_path)
|
47
47
|
end
|
48
48
|
else
|
49
|
+
# :nocov:
|
49
50
|
RSpec::Support.require_rspec_support 'source'
|
50
51
|
def source
|
51
52
|
raise TargetNotFoundError unless File.exist?(file_path)
|
52
53
|
@source ||= RSpec::Support::Source.from_file(file_path)
|
53
54
|
end
|
55
|
+
# :nocov:
|
54
56
|
end
|
55
57
|
|
56
58
|
def file_path
|
@@ -89,6 +89,7 @@ module RSpec
|
|
89
89
|
::RSpec.configuration.color_enabled?
|
90
90
|
end
|
91
91
|
else
|
92
|
+
# :nocov:
|
92
93
|
# Indicates whether or not diffs should be colored.
|
93
94
|
# Delegates to rspec-core's color option if rspec-core
|
94
95
|
# is loaded; otherwise you can set it here.
|
@@ -100,8 +101,11 @@ module RSpec
|
|
100
101
|
def color?
|
101
102
|
defined?(@color) && @color
|
102
103
|
end
|
104
|
+
# :nocov:
|
103
105
|
end
|
104
106
|
|
107
|
+
# :nocov: Because this is only really _useful_ on 1.8, and hard to test elsewhere.
|
108
|
+
#
|
105
109
|
# Adds `should` and `should_not` to the given classes
|
106
110
|
# or modules. This can be used to ensure `should` works
|
107
111
|
# properly on things like proxy objects (particular
|
@@ -114,6 +118,7 @@ module RSpec
|
|
114
118
|
Expectations::Syntax.enable_should(mod)
|
115
119
|
end
|
116
120
|
end
|
121
|
+
# :nocov:
|
117
122
|
|
118
123
|
# Sets or gets the backtrace formatter. The backtrace formatter should
|
119
124
|
# implement `#format_backtrace(Array<String>)`. This is used
|
@@ -6,6 +6,10 @@ module RSpec
|
|
6
6
|
|
7
7
|
# @private
|
8
8
|
class AggregatedFailure
|
9
|
+
# :nocov:
|
10
|
+
# `inspect` was apparently used by some versions early in ruby 3 while constructing
|
11
|
+
# NoMethodError, but seems to be no longer.
|
12
|
+
#
|
9
13
|
# @private
|
10
14
|
MESSAGE =
|
11
15
|
'AggregatedFailure: This method caused a failure which has been ' \
|
@@ -15,6 +19,7 @@ module RSpec
|
|
15
19
|
def inspect
|
16
20
|
MESSAGE
|
17
21
|
end
|
22
|
+
# :nocov:
|
18
23
|
end
|
19
24
|
|
20
25
|
AGGREGATED_FAILURE = AggregatedFailure.new
|
@@ -75,11 +80,13 @@ module RSpec
|
|
75
80
|
# a backtrace that has a continuous common section with the raised `MultipleExpectationsNotMetError`,
|
76
81
|
# so that rspec-core's truncation logic can work properly on it to list the backtrace
|
77
82
|
# relative to the `aggregate_failures` block.
|
83
|
+
# :nocov:
|
78
84
|
def assign_backtrace(failure)
|
79
85
|
raise failure
|
80
86
|
rescue failure.class => e
|
81
87
|
failure.set_backtrace(e.backtrace)
|
82
88
|
end
|
89
|
+
# :nocov:
|
83
90
|
else
|
84
91
|
# Using `caller` performs better (and is simpler) than `raise` on most Rubies.
|
85
92
|
def assign_backtrace(failure)
|
@@ -4,11 +4,10 @@ module RSpec
|
|
4
4
|
module ExpectationHelper
|
5
5
|
def self.check_message(msg)
|
6
6
|
unless msg.nil? || msg.respond_to?(:to_str) || msg.respond_to?(:call)
|
7
|
-
|
8
|
-
"
|
9
|
-
msg.inspect
|
10
|
-
|
11
|
-
].join
|
7
|
+
RSpec.warning(
|
8
|
+
"ignoring the provided expectation message argument" \
|
9
|
+
"(#{ msg.inspect }) since it is not a string or a proc"
|
10
|
+
)
|
12
11
|
end
|
13
12
|
end
|
14
13
|
|
@@ -124,24 +124,6 @@ module RSpec
|
|
124
124
|
end
|
125
125
|
private_class_method :underscore
|
126
126
|
|
127
|
-
private
|
128
|
-
|
129
|
-
def assert_ivars(*expected_ivars)
|
130
|
-
return unless (expected_ivars - present_ivars).any?
|
131
|
-
ivar_list = EnglishPhrasing.list(expected_ivars)
|
132
|
-
raise "#{self.class.name} needs to supply#{ivar_list}"
|
133
|
-
end
|
134
|
-
|
135
|
-
if RUBY_VERSION.to_f < 1.9
|
136
|
-
# :nocov:
|
137
|
-
def present_ivars
|
138
|
-
instance_variables.map(&:to_sym)
|
139
|
-
end
|
140
|
-
# :nocov:
|
141
|
-
else
|
142
|
-
alias present_ivars instance_variables
|
143
|
-
end
|
144
|
-
|
145
127
|
# @private
|
146
128
|
module HashFormatting
|
147
129
|
# `{ :a => 5, :b => 2 }.inspect` produces:
|
@@ -174,9 +156,11 @@ module RSpec
|
|
174
156
|
else
|
175
157
|
# @api private
|
176
158
|
# @return [Boolean] False always as the curent Ruby version does not support String encoding
|
159
|
+
# :nocov:
|
177
160
|
def string_encoding_differs?
|
178
161
|
false
|
179
162
|
end
|
163
|
+
# :nocov:
|
180
164
|
end
|
181
165
|
module_function :string_encoding_differs?
|
182
166
|
|
@@ -193,9 +177,11 @@ module RSpec
|
|
193
177
|
# Formats a String's encoding as a human readable string
|
194
178
|
# @param _value [String]
|
195
179
|
# @return [nil] nil as the curent Ruby version does not support String encoding
|
180
|
+
# :nocov:
|
196
181
|
def format_encoding(_value)
|
197
182
|
nil
|
198
183
|
end
|
184
|
+
# :nocov:
|
199
185
|
end
|
200
186
|
module_function :format_encoding
|
201
187
|
end
|
@@ -77,8 +77,11 @@ module RSpec
|
|
77
77
|
def match(_expected, actual)
|
78
78
|
evaluator_klass = if supports_block_expectations? && Proc === actual
|
79
79
|
NestedEvaluator
|
80
|
-
|
80
|
+
elsif supports_value_expectations?
|
81
81
|
SequentialEvaluator
|
82
|
+
else
|
83
|
+
# Can't raise an ArgumentError in this context, as it's rescued
|
84
|
+
raise "Block and value matchers can't be combined in a compound expectation (#{matcher_1.description}, #{matcher_2.description})"
|
82
85
|
end
|
83
86
|
|
84
87
|
@evaluator = evaluator_klass.new(actual, matcher_1, matcher_2)
|
@@ -108,12 +108,14 @@ module RSpec
|
|
108
108
|
end
|
109
109
|
|
110
110
|
if RUBY_VERSION == "1.8.7"
|
111
|
+
# :nocov:
|
111
112
|
def to_a_disallowed?(object)
|
112
113
|
case object
|
113
114
|
when NilClass, String then true
|
114
115
|
else Kernel == RSpec::Support.method_handle_for(object, :to_a).owner
|
115
116
|
end
|
116
117
|
end
|
118
|
+
# :nocov:
|
117
119
|
else
|
118
120
|
def to_a_disallowed?(object)
|
119
121
|
NilClass === object
|
@@ -46,8 +46,27 @@ module RSpec
|
|
46
46
|
|
47
47
|
private
|
48
48
|
|
49
|
+
# Catch a semi-frequent typo - if you have strict_predicate_matchers disabled and
|
50
|
+
# expect(spy).to have_receieveddd(:foo) it would be evergreen - the dynamic matcher
|
51
|
+
# queries `has_receiveddd?`, the spy _fakes_ the method, returning its (truthy) self.
|
52
|
+
if defined?(RSpec::Mocks::Double)
|
53
|
+
def really_responds_to?(method)
|
54
|
+
if RSpec::Mocks::Double === @actual
|
55
|
+
@actual.respond_to?(method) && methods_include?(method)
|
56
|
+
else
|
57
|
+
@actual.respond_to?(method)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
else
|
61
|
+
# :nocov:
|
62
|
+
def really_responds_to?(method)
|
63
|
+
@actual.respond_to?(method)
|
64
|
+
end
|
65
|
+
# :nocov:
|
66
|
+
end
|
67
|
+
|
49
68
|
def predicate_accessible?
|
50
|
-
|
69
|
+
really_responds_to?(predicate)
|
51
70
|
end
|
52
71
|
|
53
72
|
# support 1.8.7, evaluate once at load time for performance
|
@@ -56,11 +75,19 @@ module RSpec
|
|
56
75
|
def private_predicate?
|
57
76
|
@actual.private_methods.include? predicate.to_s
|
58
77
|
end
|
78
|
+
|
79
|
+
def methods_include?(method)
|
80
|
+
@actual.methods.include?(method.to_s)
|
81
|
+
end
|
59
82
|
# :nocov:
|
60
83
|
else
|
61
84
|
def private_predicate?
|
62
85
|
@actual.private_methods.include? predicate
|
63
86
|
end
|
87
|
+
|
88
|
+
def methods_include?(method)
|
89
|
+
@actual.methods.include?(method)
|
90
|
+
end
|
64
91
|
end
|
65
92
|
|
66
93
|
def predicate_result
|
@@ -155,7 +182,7 @@ module RSpec
|
|
155
182
|
end
|
156
183
|
|
157
184
|
def predicate_accessible?
|
158
|
-
super ||
|
185
|
+
super || really_responds_to?(present_tense_predicate)
|
159
186
|
end
|
160
187
|
|
161
188
|
def present_tense_predicate
|
@@ -13,6 +13,7 @@ module RSpec
|
|
13
13
|
|
14
14
|
# @api private
|
15
15
|
def initialize(*expecteds)
|
16
|
+
raise(ArgumentError, 'include() is not supported, please supply an argument') if expecteds.empty?
|
16
17
|
@expecteds = expecteds
|
17
18
|
end
|
18
19
|
|
@@ -165,6 +166,7 @@ module RSpec
|
|
165
166
|
end
|
166
167
|
|
167
168
|
def actual_collection_includes?(expected_item)
|
169
|
+
return actual.scan(expected_item).size > 0 if Regexp === expected_item && String === actual
|
168
170
|
return true if actual.include?(expected_item)
|
169
171
|
|
170
172
|
# String lacks an `any?` method...
|
@@ -174,9 +176,11 @@ module RSpec
|
|
174
176
|
end
|
175
177
|
|
176
178
|
if RUBY_VERSION < '1.9'
|
179
|
+
# :nocov:
|
177
180
|
def count_enumerable(expected_item)
|
178
181
|
actual.select { |value| values_match?(expected_item, value) }.size
|
179
182
|
end
|
183
|
+
# :nocov:
|
180
184
|
else
|
181
185
|
def count_enumerable(expected_item)
|
182
186
|
actual.count { |value| values_match?(expected_item, value) }
|
@@ -197,6 +201,7 @@ module RSpec
|
|
197
201
|
|
198
202
|
def diff_would_wrongly_highlight_matched_item?
|
199
203
|
return false unless actual.is_a?(String) && expected.is_a?(Array)
|
204
|
+
return false if Regexp === expecteds.first
|
200
205
|
|
201
206
|
lines = actual.split("\n")
|
202
207
|
expected.any? do |str|
|
@@ -45,12 +45,14 @@ module RSpec
|
|
45
45
|
# So here we replace `Kernel#Array` with our own warning-free implementation for 1.8.7.
|
46
46
|
# @private
|
47
47
|
# rubocop:disable Naming/MethodName
|
48
|
+
# :nocov:
|
48
49
|
def self.Array(obj)
|
49
50
|
case obj
|
50
51
|
when Array then obj
|
51
52
|
else [obj]
|
52
53
|
end
|
53
54
|
end
|
55
|
+
# :nocov:
|
54
56
|
# rubocop:enable Naming/MethodName
|
55
57
|
end
|
56
58
|
end
|
data/lib/rspec/matchers.rb
CHANGED
@@ -1018,6 +1018,7 @@ module RSpec
|
|
1018
1018
|
# than _before_, like `append_features`. It's important we check this before
|
1019
1019
|
# in order to find the cases where it was already previously included.
|
1020
1020
|
# @api private
|
1021
|
+
# :nocov:
|
1021
1022
|
def append_features(mod)
|
1022
1023
|
return super if mod < self # `mod < self` indicates a re-inclusion.
|
1023
1024
|
|
@@ -1038,6 +1039,7 @@ module RSpec
|
|
1038
1039
|
|
1039
1040
|
super
|
1040
1041
|
end
|
1042
|
+
# :nocov:
|
1041
1043
|
end
|
1042
1044
|
end
|
1043
1045
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-expectations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.13.
|
4
|
+
version: 3.13.3
|
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: 2024-
|
48
|
+
date: 2024-09-07 00:00:00.000000000 Z
|
49
49
|
dependencies:
|
50
50
|
- !ruby/object:Gem::Dependency
|
51
51
|
name: rspec-support
|
@@ -203,7 +203,7 @@ licenses:
|
|
203
203
|
- MIT
|
204
204
|
metadata:
|
205
205
|
bug_tracker_uri: https://github.com/rspec/rspec-expectations/issues
|
206
|
-
changelog_uri: https://github.com/rspec/rspec-expectations/blob/v3.13.
|
206
|
+
changelog_uri: https://github.com/rspec/rspec-expectations/blob/v3.13.3/Changelog.md
|
207
207
|
documentation_uri: https://rspec.info/documentation/
|
208
208
|
mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
|
209
209
|
source_code_uri: https://github.com/rspec/rspec-expectations
|
@@ -223,8 +223,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
223
|
- !ruby/object:Gem::Version
|
224
224
|
version: '0'
|
225
225
|
requirements: []
|
226
|
-
rubygems_version: 3.
|
226
|
+
rubygems_version: 3.4.19
|
227
227
|
signing_key:
|
228
228
|
specification_version: 4
|
229
|
-
summary: rspec-expectations-3.13.
|
229
|
+
summary: rspec-expectations-3.13.3
|
230
230
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|