Skip to content

Custom Validation code sample in readme appears incorrect #963

@nekno

Description

@nekno
  • 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:

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions