Skip to content

Commit

Permalink
Merge pull request Quick#512 from Quick/waitUntil
Browse files Browse the repository at this point in the history
Fix `waitUntil` ignore `AsyncDefaults.Timeout` value
  • Loading branch information
ikesyo authored Apr 9, 2018
2 parents 2fdf282 + 16904a5 commit b380263
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/Nimble/DSL+Wait.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,6 @@ internal func blockedRunLoopErrorMessageFor(_ fnName: String, leeway: TimeInterv
///
/// This function manages the main run loop (`NSRunLoop.mainRunLoop()`) while this function
/// is executing. Any attempts to touch the run loop may cause non-deterministic behavior.
public func waitUntil(timeout: TimeInterval = 1, file: FileString = #file, line: UInt = #line, action: @escaping (@escaping () -> Void) -> Void) {
public func waitUntil(timeout: TimeInterval = AsyncDefaults.Timeout, file: FileString = #file, line: UInt = #line, action: @escaping (@escaping () -> Void) -> Void) {
NMBWait.until(timeout: timeout, file: file, line: line, action: action)
}
12 changes: 12 additions & 0 deletions Tests/NimbleTests/AsynchronousTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ final class AsyncTest: XCTestCase, XCTestCaseProvider {
return [
("testToEventuallyPositiveMatches", testToEventuallyPositiveMatches),
("testToEventuallyNegativeMatches", testToEventuallyNegativeMatches),
("testWaitUntilWithCustomDefaultsTimeout", testWaitUntilWithCustomDefaultsTimeout),
("testWaitUntilPositiveMatches", testWaitUntilPositiveMatches),
("testToEventuallyWithCustomDefaultTimeout", testToEventuallyWithCustomDefaultTimeout),
("testWaitUntilTimesOutIfNotCalled", testWaitUntilTimesOutIfNotCalled),
Expand Down Expand Up @@ -86,6 +87,17 @@ final class AsyncTest: XCTestCase, XCTestCaseProvider {
expect { value }.toEventuallyNot(equal(1))
}

func testWaitUntilWithCustomDefaultsTimeout() {
AsyncDefaults.Timeout = 5
defer {
AsyncDefaults.Timeout = 1
}
waitUntil { done in
Thread.sleep(forTimeInterval: 4.8)
done()
}
}

func testWaitUntilPositiveMatches() {
waitUntil { done in
done()
Expand Down

0 comments on commit b380263

Please sign in to comment.