Skip to content

Instantly share code, notes, and snippets.

@mwrites
Created July 19, 2016 04:08
Show Gist options
  • Save mwrites/48c484f8748433b4f536c6d8e3147bd8 to your computer and use it in GitHub Desktop.
Save mwrites/48c484f8748433b4f536c6d8e3147bd8 to your computer and use it in GitHub Desktop.
func asyncTestWithAssertBlock(block: (XCTestExpectation)->()) {
let expectation = self.expectationWithDescription("test expectation")
block(expectation)
waitForExpectationsWithTimeout(3, handler: nil)
}
func notifTestWithAssertBlock(block: ()-> Void) {
expectationForNotification(Blurbs.BlurbsReadyNotification, object: nil) { _ in
block()
return true
}
waitForExpectationsWithTimeout(3, handler: nil)
}
usage
func testPrepareSetPrepareFlagToTrue() {
subject.prepareAndNotify()
notifTestWithAssertBlock {
XCTAssertTrue(Blurbs.didCalledPrepare)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment