-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support to RxTest as an alternative to RxBlocking
Users of RxNimble may now opt between RxBlocking and RxTest (mutually or exclusively). In order to keep compability with previous versions, the `default_subspec` is "RxBlocking", but "RxNimble/RxTest" can be added to clients' Podfiles, or replace "RxNimble" entirely in order to remove the dependency on `RxBlocking`.
- Loading branch information
Showing
7 changed files
with
65 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import Nimble | ||
import RxSwift | ||
@testable import RxTest | ||
|
||
public func equal<T: Equatable>(_ expectedEvents: RecordedEvents<T>) -> Predicate<RecordedEvents<T>> { | ||
return Predicate.define { actualEvents in | ||
let actualEquatableEvents = try actualEvents.evaluate()?.map { AnyEquatable(target: $0, comparer: ==) } | ||
let expectedEquatableEvents = expectedEvents.map { AnyEquatable(target: $0, comparer: ==) } | ||
|
||
let matches = (actualEquatableEvents == expectedEquatableEvents) | ||
return PredicateResult(bool: matches, | ||
message: .expectedActualValueTo( | ||
"emit <\(stringify(expectedEquatableEvents))>") | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Nimble | ||
import RxSwift | ||
import RxTest | ||
|
||
public typealias RecordedEvents<E> = [Recorded<Event<E>>] | ||
|
||
public extension Expectation where T: ObservableType { | ||
func events(scheduler: TestScheduler, | ||
disposeBag: DisposeBag, | ||
startAt initialTime: Int = 0) -> Expectation<RecordedEvents<T.E>> { | ||
return transform { source in | ||
let results = scheduler.createObserver(T.E.self) | ||
|
||
scheduler.scheduleAt(initialTime) { | ||
source?.subscribe(results).disposed(by: disposeBag) | ||
} | ||
scheduler.start() | ||
|
||
return results.events | ||
} | ||
} | ||
} |