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

Custom Validation code sample in readme appears incorrect #963

Closed
1 task done
nekno opened this issue Feb 18, 2022 · 2 comments · Fixed by #965
Closed
1 task done

Custom Validation code sample in readme appears incorrect #963

nekno opened this issue Feb 18, 2022 · 2 comments · Fixed by #965
Assignees

Comments

@nekno
Copy link

nekno commented Feb 18, 2022

  • I have read CONTRIBUTING and have done my best to follow them.

What did you do?

I attempted to use Custom Validation.

What did you expect to happen?

I expected the code sample provided in Custom Validation to provide working code.

What actually happened instead?

This code as written does not compile:

expect {
    guard case .enumCaseWithAssociatedValueThatIDontCareAbout = actual else {
        return .failed(reason: "wrong enum case")
    }

    return .succeeded
}.to(succeed())

The return statements produce the errors:

Type '(() -> ToSucceedResult)?' has no member 'succeeded' 
Type '(() -> ToSucceedResult)?' has no member 'failed'

Instead, each case needed to be wrapped in a closure:

expect {
    guard case .enumCaseWithAssociatedValueThatIDontCareAbout = actual else {
        return { .failed(reason: "wrong enum case") }
    }

    return { .succeeded }
}.to(succeed())

Environment

List the software versions you're using:

  • Quick: 4.0.0
  • Nimble: 9.1.0
  • Xcode Version: 13.2.1 (13C100)
  • Swift Version: Xcode Default

Please also mention which package manager you used and its version. Delete the
other package managers in this list:

  • Bazel http_archive tool

Sample project:

@ikesyo
Copy link
Member

ikesyo commented Feb 25, 2022

Thanks for the issue & pull request. This should be related to #824 and returning a closure (like return { .succeeded }) is not expected. I'll revisit the succeed() implementation.

@ikesyo ikesyo self-assigned this Feb 25, 2022
@ikesyo
Copy link
Member

ikesyo commented Feb 25, 2022

ref: #914

@ikesyo ikesyo modified the milestone: v10 Mar 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants