Skip to content

Commit

Permalink
Add documentation for the new matchers for result
Browse files Browse the repository at this point in the history
  • Loading branch information
younata committed Mar 29, 2024
1 parent fd62670 commit f7c9922
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,14 @@ expect(aResult).to(beSuccess { value in
expect(value).to(equal("Hooray"))
})

// passes if the result value is .success and if the Success value matches
// the passed-in matcher (in this case, `equal`)
expect(aResult).to(beSuccess(equal("Hooray")))

// passes if the result value is .success and if the Success value equals
// the passed-in value (only available when the Success value is Equatable)
expect(aResult).to(beSuccess("Hooray"))


enum AnError: Error {
case somethingHappened
Expand All @@ -1529,6 +1537,10 @@ expect(otherResult).to(beFailure())
expect(otherResult).to(beFailure { error in
expect(error).to(matchError(AnError.somethingHappened))
})

// passes if the result value is .failure and if the Failure value matches
// the passed-in matcher (in this case, `matchError`)
expect(otherResult).to(beFailure(matchError(AnError.somethingHappened)))
```

> This matcher is only available in Swift.
Expand Down

0 comments on commit f7c9922

Please sign in to comment.