Skip to content

Support throwable computed properties  #74

Open
@vadimkrutovlv

Description

@vadimkrutovlv

Currently I'm super happy to use this macro, it allows me to drop third party dependency an the fact that mocks are generated in the main target allows me to reduce a boilerplate code for view model mocks for swift ui previews.

However I already run multiple times in a situation when I could use a computed property instead of method but unfortunately I can't specify ThrowableError as for the methods. Consider following code.

@Spyable
protocol FacebookLoginRepositoryProtocol {
    var isRegistered: Bool { get async throws }
}

I would really love to have something like this:

let repositoryMock = FacebookLoginRepositoryProtocolSpy()
repositoryMock.isRegisteredThrowableError = MyError.error

As for now the only code macro generates is this:

class FacebookLoginRepositoryProtocolSpy: FacebookLoginRepositoryProtocol {
    var isRegistered: Bool {
        get {
            underlyingIsRegistered
        }
        set {
            underlyingIsRegistered = newValue
        }
    }

    var underlyingIsRegistered: (Bool)!
}

Would it be possible to implement something like I mentioned above? Sorry I didn't check source code that much and maybe there are some limitations about which I don't know.

Alternatively I still can use a method which is not a big deal, but I like to keep my codebase clean as much as possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions