rspec-expectations 3.9.2 → 3.9.3
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.tar.gz.sig +0 -0
- data/Changelog.md +15 -2
- data/README.md +4 -4
- data/lib/rspec/expectations/version.rb +1 -1
- data/lib/rspec/matchers.rb +24 -9
- data/lib/rspec/matchers/built_in/be.rb +45 -9
- data/lib/rspec/matchers/built_in/be_within.rb +2 -2
- data/lib/rspec/matchers/built_in/has.rb +24 -4
- data/lib/rspec/matchers/english_phrasing.rb +1 -1
- metadata +8 -8
- 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: ba515bcbb264eef62d6948840e73b71ef3a68ed947d2e711df04fdf1b04fa4ec
|
4
|
+
data.tar.gz: ba8501df256831e843786ca4f78cc7825e8ad6dca125191beda504de0c1d16e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac2ff1267b689ba5daf08898a11ff97f1f2554db817f43135a6b1d96bcada94f03d728ddda4050158fcf8a483b8295644457aea810d18b37686d5aa253007917
|
7
|
+
data.tar.gz: 6527bed095e09131e0e8a50f12784d017953f073b4099d710df7fff638f632d03bedba40836adeba6aa33f51d9d4c501f795c364c6e1304ddc8c41225df2c18d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/Changelog.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
|
-
###
|
2
|
-
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.9.2...3
|
1
|
+
### 3.9.3 / 2020-10-23
|
2
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.9.2...v3.9.3)
|
3
|
+
|
4
|
+
Bug Fixes:
|
5
|
+
|
6
|
+
* Swap the comparison of the delta vs the expected for the `be_within` matcher allowing
|
7
|
+
more complicated oobjects to be compared providing they provide `abs` and other
|
8
|
+
comparison methods. (Kelly Stannard, #1182)
|
9
|
+
* Properly format expected in the description of the `be_within` matcher. (Jon Rowe, #1185)
|
10
|
+
* Remove warning when using keyword arguments with `be_` and `have_` matchers on 2.7.x
|
11
|
+
(Jon Rowe, #1187)
|
12
|
+
* Prevent formatting a single hash as a list of key value pairs in default failure messages
|
13
|
+
for custom matches (fixes formatting in `EnglishPhrasing#list`). (Robert Eshleman, #1193)
|
14
|
+
* Prevent errors from causing false positives when using `be <operator>` comparison, e.g.
|
15
|
+
`expect(1).not_to be < 'a'` will now correctly fail rather than pass. (Jon Rowe, #1208)
|
3
16
|
|
4
17
|
### 3.9.2 / 2020-05-08
|
5
18
|
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.9.1...v3.9.2)
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# RSpec Expectations [](http://travis-ci.org/rspec/rspec-expectations) [](https://codeclimate.com/github/rspec/rspec-expectations)
|
2
2
|
|
3
3
|
RSpec::Expectations lets you express expected outcomes on an object in an
|
4
4
|
example.
|
@@ -15,12 +15,12 @@ rspec-core and rspec-mocks):
|
|
15
15
|
|
16
16
|
gem install rspec
|
17
17
|
|
18
|
-
Want to run against the `
|
18
|
+
Want to run against the `main` branch? You'll need to include the dependent
|
19
19
|
RSpec repos as well. Add the following to your `Gemfile`:
|
20
20
|
|
21
21
|
```ruby
|
22
22
|
%w[rspec-core rspec-expectations rspec-mocks rspec-support].each do |lib|
|
23
|
-
gem lib, :git => "https://github.com/rspec/#{lib}.git", :branch => '
|
23
|
+
gem lib, :git => "https://github.com/rspec/#{lib}.git", :branch => 'main'
|
24
24
|
end
|
25
25
|
```
|
26
26
|
|
@@ -227,7 +227,7 @@ actual.should be > 3
|
|
227
227
|
[1, 2, 3].should_not include 4
|
228
228
|
```
|
229
229
|
|
230
|
-
See [detailed information on the `should` syntax and its usage.](https://github.com/rspec/rspec-expectations/blob/
|
230
|
+
See [detailed information on the `should` syntax and its usage.](https://github.com/rspec/rspec-expectations/blob/main/Should.md)
|
231
231
|
|
232
232
|
## Compound Matcher Expressions
|
233
233
|
|
data/lib/rspec/matchers.rb
CHANGED
@@ -238,7 +238,7 @@ module RSpec
|
|
238
238
|
# best to find a more positive name for the negated form, such as
|
239
239
|
# `avoid_changing` rather than `not_change`.
|
240
240
|
#
|
241
|
-
module Matchers
|
241
|
+
module Matchers # rubocop:disable Metrics/ModuleLength
|
242
242
|
extend ::RSpec::Matchers::DSL
|
243
243
|
|
244
244
|
# @!macro [attach] alias_matcher
|
@@ -953,14 +953,29 @@ module RSpec
|
|
953
953
|
HAS_REGEX = /^(?:have_)(.*)/
|
954
954
|
DYNAMIC_MATCHER_REGEX = Regexp.union(BE_PREDICATE_REGEX, HAS_REGEX)
|
955
955
|
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
956
|
+
if RSpec::Support::RubyFeatures.kw_args_supported?
|
957
|
+
binding.eval(<<-CODE, __FILE__, __LINE__)
|
958
|
+
def method_missing(method, *args, **kwargs, &block)
|
959
|
+
case method.to_s
|
960
|
+
when BE_PREDICATE_REGEX
|
961
|
+
BuiltIn::BePredicate.new(method, *args, **kwargs, &block)
|
962
|
+
when HAS_REGEX
|
963
|
+
BuiltIn::Has.new(method, *args, **kwargs, &block)
|
964
|
+
else
|
965
|
+
super
|
966
|
+
end
|
967
|
+
end
|
968
|
+
CODE
|
969
|
+
else
|
970
|
+
def method_missing(method, *args, &block)
|
971
|
+
case method.to_s
|
972
|
+
when BE_PREDICATE_REGEX
|
973
|
+
BuiltIn::BePredicate.new(method, *args, &block)
|
974
|
+
when HAS_REGEX
|
975
|
+
BuiltIn::Has.new(method, *args, &block)
|
976
|
+
else
|
977
|
+
super
|
978
|
+
end
|
964
979
|
end
|
965
980
|
end
|
966
981
|
|
@@ -143,8 +143,13 @@ module RSpec
|
|
143
143
|
end
|
144
144
|
|
145
145
|
def matches?(actual)
|
146
|
-
|
147
|
-
|
146
|
+
perform_match(actual)
|
147
|
+
rescue ArgumentError, NoMethodError
|
148
|
+
false
|
149
|
+
end
|
150
|
+
|
151
|
+
def does_not_match?(actual)
|
152
|
+
!perform_match(actual)
|
148
153
|
rescue ArgumentError, NoMethodError
|
149
154
|
false
|
150
155
|
end
|
@@ -173,6 +178,13 @@ module RSpec
|
|
173
178
|
def description
|
174
179
|
"be #{@operator} #{expected_to_sentence}#{args_to_sentence}"
|
175
180
|
end
|
181
|
+
|
182
|
+
private
|
183
|
+
|
184
|
+
def perform_match(actual)
|
185
|
+
@actual = actual
|
186
|
+
@actual.__send__ @operator, @expected
|
187
|
+
end
|
176
188
|
end
|
177
189
|
|
178
190
|
# @api private
|
@@ -181,10 +193,21 @@ module RSpec
|
|
181
193
|
class BePredicate < BaseMatcher
|
182
194
|
include BeHelpers
|
183
195
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
196
|
+
if RSpec::Support::RubyFeatures.kw_args_supported?
|
197
|
+
binding.eval(<<-CODE, __FILE__, __LINE__)
|
198
|
+
def initialize(*args, **kwargs, &block)
|
199
|
+
@expected = parse_expected(args.shift)
|
200
|
+
@args = args
|
201
|
+
@kwargs = kwargs
|
202
|
+
@block = block
|
203
|
+
end
|
204
|
+
CODE
|
205
|
+
else
|
206
|
+
def initialize(*args, &block)
|
207
|
+
@expected = parse_expected(args.shift)
|
208
|
+
@args = args
|
209
|
+
@block = block
|
210
|
+
end
|
188
211
|
end
|
189
212
|
|
190
213
|
def matches?(actual, &block)
|
@@ -236,9 +259,22 @@ module RSpec
|
|
236
259
|
end
|
237
260
|
end
|
238
261
|
|
239
|
-
|
240
|
-
|
241
|
-
|
262
|
+
if RSpec::Support::RubyFeatures.kw_args_supported?
|
263
|
+
binding.eval(<<-CODE, __FILE__, __LINE__)
|
264
|
+
def predicate_matches?
|
265
|
+
method_name = actual.respond_to?(predicate) ? predicate : present_tense_predicate
|
266
|
+
if @kwargs.empty?
|
267
|
+
@predicate_matches = actual.__send__(method_name, *@args, &@block)
|
268
|
+
else
|
269
|
+
@predicate_matches = actual.__send__(method_name, *@args, **@kwargs, &@block)
|
270
|
+
end
|
271
|
+
end
|
272
|
+
CODE
|
273
|
+
else
|
274
|
+
def predicate_matches?
|
275
|
+
method_name = actual.respond_to?(predicate) ? predicate : present_tense_predicate
|
276
|
+
@predicate_matches = actual.__send__(method_name, *@args, &@block)
|
277
|
+
end
|
242
278
|
end
|
243
279
|
|
244
280
|
def predicate
|
@@ -23,7 +23,7 @@ module RSpec
|
|
23
23
|
# a percent comparison.
|
24
24
|
def percent_of(expected)
|
25
25
|
@expected = expected
|
26
|
-
@tolerance = @
|
26
|
+
@tolerance = @expected.abs * @delta / 100.0
|
27
27
|
@unit = '%'
|
28
28
|
self
|
29
29
|
end
|
@@ -50,7 +50,7 @@ module RSpec
|
|
50
50
|
# @api private
|
51
51
|
# @return [String]
|
52
52
|
def description
|
53
|
-
"be within #{@delta}#{@unit} of #{
|
53
|
+
"be within #{@delta}#{@unit} of #{expected_formatted}"
|
54
54
|
end
|
55
55
|
|
56
56
|
private
|
@@ -5,8 +5,16 @@ module RSpec
|
|
5
5
|
# Provides the implementation for `has_<predicate>`.
|
6
6
|
# Not intended to be instantiated directly.
|
7
7
|
class Has < BaseMatcher
|
8
|
-
|
9
|
-
|
8
|
+
if RSpec::Support::RubyFeatures.kw_args_supported?
|
9
|
+
binding.eval(<<-CODE, __FILE__, __LINE__)
|
10
|
+
def initialize(method_name, *args, **kwargs, &block)
|
11
|
+
@method_name, @args, @kwargs, @block = method_name, args, kwargs, block
|
12
|
+
end
|
13
|
+
CODE
|
14
|
+
else
|
15
|
+
def initialize(method_name, *args, &block)
|
16
|
+
@method_name, @args, @block = method_name, args, block
|
17
|
+
end
|
10
18
|
end
|
11
19
|
|
12
20
|
# @private
|
@@ -64,8 +72,20 @@ module RSpec
|
|
64
72
|
@actual.respond_to? predicate
|
65
73
|
end
|
66
74
|
|
67
|
-
|
68
|
-
|
75
|
+
if RSpec::Support::RubyFeatures.kw_args_supported?
|
76
|
+
binding.eval(<<-CODE, __FILE__, __LINE__)
|
77
|
+
def predicate_matches?
|
78
|
+
if @kwargs.empty?
|
79
|
+
@actual.__send__(predicate, *@args, &@block)
|
80
|
+
else
|
81
|
+
@actual.__send__(predicate, *@args, **@kwargs, &@block)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
CODE
|
85
|
+
else
|
86
|
+
def predicate_matches?
|
87
|
+
@actual.__send__(predicate, *@args, &@block)
|
88
|
+
end
|
69
89
|
end
|
70
90
|
|
71
91
|
def predicate
|
@@ -24,7 +24,7 @@ module RSpec
|
|
24
24
|
# list([]) #=> ""
|
25
25
|
#
|
26
26
|
def self.list(obj)
|
27
|
-
return " #{RSpec::Support::ObjectFormatter.format(obj)}" if !obj || Struct === obj
|
27
|
+
return " #{RSpec::Support::ObjectFormatter.format(obj)}" if !obj || Struct === obj || Hash === obj
|
28
28
|
items = Array(obj).map { |w| RSpec::Support::ObjectFormatter.format(w) }
|
29
29
|
case items.length
|
30
30
|
when 0
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-expectations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.9.
|
4
|
+
version: 3.9.3
|
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: 2020-
|
48
|
+
date: 2020-10-23 00:00:00.000000000 Z
|
49
49
|
dependencies:
|
50
50
|
- !ruby/object:Gem::Dependency
|
51
51
|
name: rspec-support
|
@@ -202,11 +202,11 @@ licenses:
|
|
202
202
|
- MIT
|
203
203
|
metadata:
|
204
204
|
bug_tracker_uri: https://github.com/rspec/rspec-expectations/issues
|
205
|
-
changelog_uri: https://github.com/rspec/rspec-expectations/blob/v3.9.
|
205
|
+
changelog_uri: https://github.com/rspec/rspec-expectations/blob/v3.9.3/Changelog.md
|
206
206
|
documentation_uri: https://rspec.info/documentation/
|
207
207
|
mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
|
208
208
|
source_code_uri: https://github.com/rspec/rspec-expectations
|
209
|
-
post_install_message:
|
209
|
+
post_install_message:
|
210
210
|
rdoc_options:
|
211
211
|
- "--charset=UTF-8"
|
212
212
|
require_paths:
|
@@ -222,8 +222,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
222
222
|
- !ruby/object:Gem::Version
|
223
223
|
version: '0'
|
224
224
|
requirements: []
|
225
|
-
rubygems_version: 3.1.
|
226
|
-
signing_key:
|
225
|
+
rubygems_version: 3.1.3
|
226
|
+
signing_key:
|
227
227
|
specification_version: 4
|
228
|
-
summary: rspec-expectations-3.9.
|
228
|
+
summary: rspec-expectations-3.9.3
|
229
229
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|