flexmock 2.4.2 → 2.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 55630790b40e21c94d842f9b5a173f0a3e2535aa40c4cc23c00aaaedaeaeb31a
4
- data.tar.gz: 2afc06542cbe3ef561fb51239ccdfd646e677ee5508038d7532fe427049713f8
3
+ metadata.gz: f04cd2c32c9722b6cd8562aa1633c2efaf994483e5863b16a2ca219717585cb2
4
+ data.tar.gz: b7f4b1bfd22b0c5dfff930334708e3a3c93d958d1ca0b4c3c1e84823eeee5d25
5
5
  SHA512:
6
- metadata.gz: e41731de6baa727d4580e5033180becda98c24a9b0522bf41a802f133023e20d6052c2d4a812ee435204cc8159bfdab32d3ddc66922ba8a69b8bf4427e89e13e
7
- data.tar.gz: fc31b71f78372d05cc3e44e7648d9a5c8c9f7499ac56a4713e63eb1a3db4ba4f9b2107ae989cf967d44e0206e0f8e134ec675821c3710248952835daa8e1b457
6
+ metadata.gz: 82d5fda980c7e96508b9c8cb980b3ed3ef5c06593108e8da2a68b3a781ecc2a03d850929518467d4bf5acc8237e622dbf785f9d29aad07f20be06ef501fbe22d
7
+ data.tar.gz: 030b1c944ad32aaff455e94bba48212c5849b4ae88248fded4af037a43e9e83fd518520ebc46486e7493267ffdd6101184f60e31ce444cf553aac32e82220e38
data/README.md CHANGED
@@ -22,6 +22,16 @@ Only significant changes (new APIs, deprecated APIs or backward-compatible
22
22
  changes) are documented here, a.k.a. minor or major version bumps. If you want a
23
23
  detailed changelog, go over the commit log in github (it's pretty low-traffic)
24
24
 
25
+ 2.4.0:
26
+ - forward-compatible implementation of `with_kw_args`, `with_any_kw_args`,
27
+ `with_block` and `with_no_block`. The objective of this release is to ensure
28
+ that any test changes needed to handle Ruby 3 (along with flexmock 3) can run
29
+ on ruby 2.7 and flexmock 2.4
30
+ - the default behavior of flexmock 2 regarding proc matching, that is that one
31
+ needs to match them explicitly, is unchanged. Use `with_optional_block` instead
32
+ of passing `optional_proc` to `with`, to match optionally (IMPORTANT
33
+ the explicit `with` methods that match blocks are called `block`, not `proc`)
34
+
25
35
  2.3.0:
26
36
  - implemented validation of call arity for partial mocks. By setting
27
37
  FlexMock.partials_verify_signatures = true
@@ -67,6 +67,23 @@ class FlexMock
67
67
  end
68
68
  end
69
69
 
70
+ ####################################################################
71
+ # Match hashes that match all the fields of +hash+.
72
+ class KwArgsMatcher
73
+ def initialize(expected)
74
+ @expected = expected
75
+ end
76
+ def ===(target)
77
+ return false unless target.kind_of?(Hash)
78
+ return false unless @expected.all? { |k, v| v === target[k] }
79
+
80
+ @expected.size == target.size
81
+ end
82
+ def inspect
83
+ "kw(#{@expected.inspect})"
84
+ end
85
+ end
86
+
70
87
  ####################################################################
71
88
  # Match objects that implement all the methods in +methods+.
72
89
  class DuckMatcher
@@ -3,7 +3,8 @@ class FlexMock
3
3
  # A composite expectation allows several expectations to be grouped into a
4
4
  # single composite and then apply the same constraints to all expectations
5
5
  # in the group.
6
- class CompositeExpectation
6
+ class CompositeExpectation < BasicObject
7
+ attr_reader :expectations
7
8
 
8
9
  # Initialize the composite expectation.
9
10
  def initialize
@@ -241,7 +241,12 @@ class FlexMock
241
241
  # Declare that the method can be called with any number of
242
242
  # arguments of any type.
243
243
  def with_kw_args(matcher)
244
- @expected_kw_args = matcher
244
+ @expected_kw_args =
245
+ if matcher.kind_of?(Hash)
246
+ KwArgsMatcher.new(matcher)
247
+ else
248
+ matcher
249
+ end
245
250
  self
246
251
  end
247
252
 
@@ -34,7 +34,7 @@ class FlexMock
34
34
  def apply(mock)
35
35
  obj = mock
36
36
  @expectations.each do |sym, args, block|
37
- obj = obj.send(sym, *args, &block)
37
+ obj = obj.__send__(sym, *args, &block)
38
38
  end
39
39
  end
40
40
  end
@@ -276,7 +276,7 @@ class FlexMock
276
276
  expectation_blocks = @initialize_expectation_blocks = Array.new
277
277
  expectation_recorders = @initialize_expectation_recorders = Array.new
278
278
  @initialize_override = Module.new do
279
- define_method :initialize do |*args, &block|
279
+ define_method :initialize do |*args, **kw, &block|
280
280
  if self.class.respond_to?(:__flexmock_proxy) && (mock = self.class.__flexmock_proxy)
281
281
  container = mock.flexmock_container
282
282
  mock = container.flexmock(self)
@@ -287,7 +287,12 @@ class FlexMock
287
287
  r.apply(mock)
288
288
  end
289
289
  end
290
- super(*args, &block)
290
+ if kw.empty?
291
+ # Workaround kw arg support for ruby < 2.7
292
+ super(*args, &block)
293
+ else
294
+ super(*args, **kw, &block)
295
+ end
291
296
  end
292
297
  end
293
298
  override = @initialize_override
@@ -1,3 +1,3 @@
1
1
  class FlexMock
2
- VERSION = "2.4.2"
2
+ VERSION = "2.4.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flexmock
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.2
4
+ version: 2.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Weirich
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-09-16 00:00:00.000000000 Z
12
+ date: 2025-08-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest