Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Sources/Nimble/Matchers/RaisesException.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import Foundation
///
/// nil arguments indicates that the matcher should not attempt to match against
/// that parameter.
public func raiseException(
public func raiseException<Out>(
named: String? = nil,
reason: String? = nil,
userInfo: NSDictionary? = nil,
closure: ((NSException) -> Void)? = nil) -> Predicate<Any> {
closure: ((NSException) -> Void)? = nil) -> Predicate<Out> {
return Predicate { actualExpression in
var exception: NSException?
let capture = NMBExceptionCapture(handler: ({ e in
Expand Down Expand Up @@ -141,7 +141,7 @@ public class NMBObjCRaiseExceptionMatcher: NSObject, NMBMatcher {
let expr = Expression(expression: block, location: location)

do {
let predicate = raiseException(
let predicate: Predicate<Any> = raiseException(
named: _name,
reason: _reason,
userInfo: _userInfo,
Expand Down
12 changes: 12 additions & 0 deletions Tests/NimbleTests/Matchers/RaisesExceptionTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,17 @@ final class RaisesExceptionTest: XCTestCase {
})
}
}

func testNonVoidClosure() {
expect { return 1 }.toNot(raiseException())
expect { return 2 }.toNot(raiseException(named: "laugh"))
expect { return 3 }.toNot(raiseException(named: "laugh", reason: "Lulz"))
expect { return 4 }.toNot(raiseException(named: "laugh", reason: "Lulz", userInfo: ["key": "value"]))
expect { return 5 }.toNot(raiseException(named: "laugh", reason: "Lulz", userInfo: ["key": "value"]) { _ in })
}

func testChainOnRaiseException() {
expect { () -> Int in return 5 }.toNot(raiseException()).to(equal(5))
}
}
#endif