Comments (4)
Hmm! Sounds like you may have found a bug. We recently refactored the internals to support RxTest in #35, maybe this is a limitation we've hit? I'm not sure. The docs for Nimble's custom matchers are here: https://github.com/Quick/Nimble#writing-your-own-matchers Not sure about RxTest but I'd start in our Nimble implementation: https://github.com/RxSwiftCommunity/RxNimble/blob/master/Source/RxTest/Expectation%2BRxTest.swift A PR would be very welcome, thanks 🙇
from rxnimble.
Hey @SunDog thank you for reporting this.
I don't think, it's an issue with RxNimble. It's just the way it was implemented
expect(subject).first
resolves as Expectation<Int>
, so we can't check its type. Because we know it for sure.
RxTest has another API, which extends ObservableConvertibleType
type. So it doesn't change behaviour of expect
method.
if you want to get such behaviour, you can use:
let driverObject: Driver<Any> = Driver.just(Int())
// will compile
expect(driverObject.asObservable()).first.to(beAnInstanceOf(Int.self))
The only way to resolve this issue - fully rethink API of RxNimble. first
shouldn't be in extension of Expectation
, but in ObservableConvertibleType
. Like this:
public extension ObservableConvertibleType {
var first: Element {
return try! self.toBlocking().first()! // dirty version with force unwrap
}
}
...
expect(o.first).to(beAnInstanceOf(Int.self)) // compiles
If maintainers are ok with that, i will create PR @gobetti
from rxnimble.
Hi @ashfurrow @MortyMerr !
You guys mentioned RxTest, so just making sure we're on the same page: I think grabbing the first
only makes sense when using RxBlocking
, because the idea with RxTest
is to test a sequence instead of specific events (we would need to block it until the first one is received if we want one event, right?). So @MortyMerr your proposed solution makes sense to me, as long as it's part of the RxBlocking subspec only.
Please feel free to correct me if I'm wrong! 🙏
from rxnimble.
@gobetti these declarations will conflict with first()
from Observable
I think it's better to just ignore beAnInstanceOf
or use the approach with explicit type
from rxnimble.
Related Issues (20)
- Move to RxSwiftCommunity Org HOT 1
- Won't build on device when bitcode generation is enabled
- Carthage support HOT 3
- Nimble 6.0 support HOT 4
- Nimble comparators seem to broken on Xcode 8.3.2 & Swift 3.1 HOT 1
- Nimble 7.x.x Support HOT 1
- Including actual along with expected values in expectation message
- Visibility issue in Expectation extension HOT 1
- Expectation not supporting all traits HOT 1
- Not working with Xcode 10.0 and Swift 4.2 HOT 2
- pod install fail with message "CocoaPods could not find compatible versions for pod RxNimble/RxTest" HOT 9
- Xcode 10.2 / swift 5 Compatability HOT 3
- Remove equalFirst HOT 3
- throwError only works with Any HOT 1
- Feature request: SPM support
- Auto linking library fails with Swift version 5.2 HOT 1
- (XCode 11.4) Could not find or use auto-linked library 'XCTestSwiftSupport' HOT 1
- Package.swift need modify iOS deploy version 8 to 9 HOT 2
- Xcode 15 Nimble & Foundation naming conflict HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rxnimble.