Swiftpack.co - Package - RxSwiftCommunity/RxNimble
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.

Build Status


Nimble extensions that make unit testing with RxSwift easier :tada:

If you came here because you want to help out, please check out the contribution guide


RxSwift includes a really nifty little library called RxBlocking which provides convenience functions for peeking in on Observable instances. Check is a blocking call, hence the name.

But writing code to check an Observable's value is sooooo tedious:

let result = try! observable.toBlocking().first()
expect(result) == 42

With RxNimble, we've added Nimble extension for Observables, so the code above can be rewritten as:

expect(observable).first == 42


It's also possible to pass a timeout to the blocking operators:

expect(observable).first(timeout: 3) == 42

This extension is also available for all Traits (e.g. Single, Maybe) and other types conforming to ObservableConvertibleType.

If on the other hand you'd rather use RxTest instead of RxBlocking, you can do it by specifying RxNimble's RxTest subspec. With RxTest you can have more powerful tests, checking a stream as a whole instead of being limited to first, last and array (while the last 2 implicitly require the stream to have completed).

That means RxTest allows you to verify the occurrence of multiple next, error and completed events at specific virtual times:

expect(subject).events(scheduler: scheduler, disposeBag: disposeBag)
        Recorded.next(5, "Hello"),
        Recorded.next(10, "World"),

You may also verify specific error types:

expect(imageSubject).events(scheduler: scheduler, disposeBag: disposeBag)
        Recorded.error(5, ImageError.invalidImage)



Add to the tests target in your Podfile:

pod 'RxNimble' # same as RxNimble/RxBlocking


pod 'RxNimble/RxTest' # installs RxTest instead of RxBlocking

or even

pod 'RxNimble', subspecs: ['RxBlocking', 'RxTest'] # installs both dependencies

And pod install and that's it!


Add to your Cartfile.private:

github 'RxSwiftCommunity/RxNimble'

Run carthage update --cache-builds then drag & drop from the Carthage/Builds folder into your project either or both of:

  • RxNimbleRxBlocking.framework and RxBlocking.framework
  • RxNimbleRxTest.framework and RxTest.framework

Migration 4.5.0 -> 5.0.0

Deprecated function equalFirst was removed in favor of a more natural Nimble matcher API style.

RxNimble 4.5.0:


RxNimble 5.0.0:


Known Issues

Very very very rarely the Swift compiler gets confused about the different types and you need to use the original RxBlocking code.


MIT ofc.

Give yourself a high five


Stars: 228


4.7.2 - 2020-03-25T16:13:26

Carthage Support - 2018-11-09T16:11:14

4.3.0 - 2018-10-04T03:32:48

  • Support Xcode 10 and Swift 4.2

4.2.0 - 2018-09-08T15:03:24

4.0.0 - 2017-10-31T10:58:52

Support for Swift 4 and RxSwift 4

- 2017-06-02T17:25:59

1.0.0 - 2017-06-02T17:25:49

2.0.0 - 2017-06-02T17:25:37

3.0.0 - 2017-06-02T17:25:25

0.2.0 - 2016-05-15T15:39:27