Giter Site home page Giter Site logo

Comments (4)

ashfurrow avatar ashfurrow commented on June 16, 2024 1

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.

M0rtyMerr avatar M0rtyMerr commented on June 16, 2024 1

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.

gobetti avatar gobetti commented on June 16, 2024

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.

M0rtyMerr avatar M0rtyMerr commented on June 16, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.