flexmock 2.4.2 → 2.4.4

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: b4a239d82da231a2f73b96aae3b7c0f5a44a28a706669970921f5035a1498eba
4
+ data.tar.gz: f55c6f5594156c9665a2b4911eadee38e4d9f439e2a6ba058b63695761a1a786
5
5
  SHA512:
6
- metadata.gz: e41731de6baa727d4580e5033180becda98c24a9b0522bf41a802f133023e20d6052c2d4a812ee435204cc8159bfdab32d3ddc66922ba8a69b8bf4427e89e13e
7
- data.tar.gz: fc31b71f78372d05cc3e44e7648d9a5c8c9f7499ac56a4713e63eb1a3db4ba4f9b2107ae989cf967d44e0206e0f8e134ec675821c3710248952835daa8e1b457
6
+ metadata.gz: cd39ba9015c63eed6a00114a49c1ca207bea0454eb8263d3d6fa8a990818daeb1c8121d726f6c03a2ff6388f01944470d1897ff1214b541e5881231052ba27a8
7
+ data.tar.gz: 708d7bfafb8e0a33fbb9f2b17a5adfc23c51d9c022c820af0a0c0c453b0b22809ea4634ba4a4090e7d595fab8590e5e16da155b3d2d7031d19228aca2b71cd76
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
@@ -287,6 +287,7 @@ class FlexMock
287
287
  r.apply(mock)
288
288
  end
289
289
  end
290
+ # Workaround kw arg support for ruby < 2.7
290
291
  super(*args, &block)
291
292
  end
292
293
  end
@@ -1,3 +1,3 @@
1
1
  class FlexMock
2
- VERSION = "2.4.2"
2
+ VERSION = "2.4.4"
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.4
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-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest