rspec-mocks 3.12.7 → 3.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9cf01a58b4af1af87a64bb57139b8bb7010349ffb208980bca4b8d851c7c64d7
4
- data.tar.gz: b5b7ddbcd488edf6bc693dee88de4de2ff7a3ebcb8fb067bf8374726dfef869d
3
+ metadata.gz: 71211650b0472cd386136d98bc36d04f66c9944aa4ef5da7bf72541c6847b0d3
4
+ data.tar.gz: e0fe8ffaa23df6885b6be3b11a1ed53a65ab750c7e969d0477a3a0af6ef343a0
5
5
  SHA512:
6
- metadata.gz: f3b1ec29a54f045fefd91e58c55667e0b805d1996abd54d6024f8fe74f5584697ba9365e091f19179cb3ea0e75e1ae1125def0719232600ee0afaa879c1fd805
7
- data.tar.gz: ac8be23c660534d3d33078405d8d035b8812b5e4b54df413e6249768ad30eab0c9125741558ece3a29c985e9d520edd2b346e606104f5cd840b780b2fc43b82b
6
+ metadata.gz: 3d389141c0abec2c4bae1008f96b34978b6d576d2ed229f96ca1eff3af1bf47a78d95d37f30630e7dbd0346483b140982d2a3aa2b80663058e61b7ba4fe4fec5
7
+ data.tar.gz: 21c8cab0cf3ec3ea8dcc485dcd36301bea5dba1f4828c0f924d0e32f028870f3b3e793adb4553dc09931ec33bd0990189c5c36b24bb7cb166fd0635bdff4b2e7
checksums.yaml.gz.sig CHANGED
Binary file
data/Changelog.md CHANGED
@@ -1,5 +1,12 @@
1
1
  ### Development
2
- [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.12.7...3-12-maintenance)
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)
3
10
 
4
11
  ### 3.12.7 / 2024-02-04
5
12
  [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.12.6...v3.12.7)
@@ -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 a hash that doesn't include the specified key(s) or key/value.
95
+ # Matches an array that excludes the specified items.
86
96
  #
87
97
  # @example
88
- # expect(object).to receive(:message).with(hash_excluding(:key => val))
89
- # expect(object).to receive(:message).with(hash_excluding(:key))
90
- # expect(object).to receive(:message).with(hash_excluding(:key, :key2 => :val2))
91
- def hash_excluding(*args)
92
- HashExcludingMatcher.new(ArgumentMatchers.anythingize_lonely_keys(*args))
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)
@@ -3,7 +3,7 @@ module RSpec
3
3
  # Version information for RSpec mocks.
4
4
  module Version
5
5
  # Version of RSpec mocks currently in use in SemVer format.
6
- STRING = '3.12.7'
6
+ STRING = '3.13.0'
7
7
  end
8
8
  end
9
9
  end
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.12.7
4
+ version: 3.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Baker
@@ -53,14 +53,14 @@ dependencies:
53
53
  requirements:
54
54
  - - "~>"
55
55
  - !ruby/object:Gem::Version
56
- version: 3.12.0
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.12.0
63
+ version: 3.13.0
64
64
  - !ruby/object:Gem::Dependency
65
65
  name: diff-lcs
66
66
  requirement: !ruby/object:Gem::Requirement
@@ -200,7 +200,7 @@ licenses:
200
200
  - MIT
201
201
  metadata:
202
202
  bug_tracker_uri: https://github.com/rspec/rspec-mocks/issues
203
- changelog_uri: https://github.com/rspec/rspec-mocks/blob/v3.12.7/Changelog.md
203
+ changelog_uri: https://github.com/rspec/rspec-mocks/blob/v3.13.0/Changelog.md
204
204
  documentation_uri: https://rspec.info/documentation/
205
205
  mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
206
206
  source_code_uri: https://github.com/rspec/rspec-mocks
@@ -223,5 +223,5 @@ requirements: []
223
223
  rubygems_version: 3.1.6
224
224
  signing_key:
225
225
  specification_version: 4
226
- summary: rspec-mocks-3.12.7
226
+ summary: rspec-mocks-3.13.0
227
227
  test_files: []
metadata.gz.sig CHANGED
Binary file