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 +4 -4
- data/README.md +10 -0
- data/lib/flexmock/argument_matchers.rb +17 -0
- data/lib/flexmock/composite_expectation.rb +2 -1
- data/lib/flexmock/expectation.rb +6 -1
- data/lib/flexmock/expectation_recorder.rb +1 -1
- data/lib/flexmock/partial_mock.rb +7 -2
- data/lib/flexmock/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f04cd2c32c9722b6cd8562aa1633c2efaf994483e5863b16a2ca219717585cb2
|
4
|
+
data.tar.gz: b7f4b1bfd22b0c5dfff930334708e3a3c93d958d1ca0b4c3c1e84823eeee5d25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/flexmock/expectation.rb
CHANGED
@@ -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 =
|
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
|
|
@@ -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
|
-
|
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
|
data/lib/flexmock/version.rb
CHANGED
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.
|
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:
|
12
|
+
date: 2025-08-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|