Skip to content

Commit 8b34ac9

Browse files
authored
Merge pull request MakeAWishFoundation#257 from MakeAWishFoundation/argument-captor-filter
add optional filter for values captured by ArgumentCaptor
2 parents 8c9e761 + cec6c0c commit 8b34ac9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Sources/SwiftyMocky/ArgumentCaptor.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,15 @@ public class ArgumentCaptor<Type> {
99
public init() {}
1010

1111
/// Return parameter matcher which captures the argument.
12-
public func capture() -> Parameter<Type> {
12+
public func capture(where matches: ((Type) -> Bool)? = nil) -> Parameter<Type> {
1313
return .matching({ (value: Type) -> Bool in
14+
if let matchFunction = matches {
15+
let match = matchFunction(value)
16+
if match {
17+
self.allValues.append(value)
18+
}
19+
return match
20+
}
1421
self.allValues.append(value)
1522
return true
1623
})

0 commit comments

Comments
 (0)