Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds matchers for Swift 5 Result type #643

Merged
merged 4 commits into from
May 17, 2021
Merged

Conversation

xzeror
Copy link
Contributor

@xzeror xzeror commented Apr 2, 2019

Swift 5 adds common Result type. It's useful to have matchers out of the box in Nimble.
This PR adds matchers beSuccess and beFailure. This is purely additive changes with full test coverage. Also added some code samples into Readme.

  • [✅ ] Does this have tests?
  • [✅ ] Does this have documentation?
  • [ ❌] Does this break the public API (Requires major version bump)?
  • [✅ ] Is this a new feature (Requires minor version bump)?

@xzeror xzeror force-pushed the result_matchers branch from bc500e0 to f07e7ad Compare April 3, 2019 11:49
@dtrenz
Copy link

dtrenz commented Aug 16, 2019

For what it's worth, I'm using these as my local custom Result type matchers, in case someone wants to steal them:

func beFailure<Success, Failure>() -> Predicate<Result<Success, Failure>> {
    return Predicate.simple("be failure") { actualExpression in
        guard let actual = try actualExpression.evaluate(), case .failure = actual else {
            return .doesNotMatch
        }
        return .matches
    }
}

func beSuccess<Success, Failure>() -> Predicate<Result<Success, Failure>> {
    return Predicate.simple("be success") { actualExpression in
        guard let actual = try actualExpression.evaluate(), case .success = actual else {
            return .doesNotMatch
        }
        return .matches
    }
}

@ikesyo ikesyo self-assigned this May 17, 2020
@ikesyo ikesyo self-requested a review May 17, 2020 01:25
@ikesyo ikesyo force-pushed the result_matchers branch from 0095278 to 99ee2a8 Compare May 17, 2020 01:25
@ikesyo
Copy link
Member

ikesyo commented May 17, 2020

Sorry for the late, I'm rebooting this now for Nimble v9.

@ikesyo ikesyo force-pushed the result_matchers branch 2 times, most recently from d6e0345 to 01de2ed Compare May 23, 2020 07:28
@ikesyo ikesyo force-pushed the result_matchers branch from 01de2ed to fea0e1e Compare May 30, 2020 13:28
@ikesyo ikesyo force-pushed the result_matchers branch from fea0e1e to c742243 Compare June 9, 2020 15:49
Copy link
Member

@ikesyo ikesyo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll tackle the feedbacks myself.

@ikesyo ikesyo force-pushed the result_matchers branch from c742243 to 494cf56 Compare May 14, 2021 13:54
@ikesyo ikesyo force-pushed the result_matchers branch 2 times, most recently from 44a1eec to 564811c Compare May 14, 2021 15:11
@ikesyo ikesyo force-pushed the result_matchers branch from 564811c to 277b564 Compare May 14, 2021 20:52
@ikesyo ikesyo merged commit c69d8cb into Quick:master May 17, 2021
@jessesquires jessesquires added this to the v10.0.0 milestone Apr 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants