-
-
Notifications
You must be signed in to change notification settings - Fork 603
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
Fixes expectation regression & failure bugs. #428
Conversation
@@ -15,8 +15,8 @@ func failsWithErrorMessage(_ messages: [String], file: FileString = #file, line: | |||
var foundFailureMessage = false | |||
|
|||
for assertion in recorder.assertions { | |||
lastFailure = assertion | |||
if assertion.message.stringValue == msg { | |||
if assertion.message.stringValue == msg && !assertion.success { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Where Violation: where
clauses are preferred over a single if
inside a for
. (for_where)
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vertical Whitespace Violation: Limit vertical whitespace to a single empty line. Currently 2. (vertical_whitespace)
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vertical Whitespace Violation: Limit vertical whitespace to a single empty line. Currently 2. (vertical_whitespace)
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vertical Whitespace Violation: Limit vertical whitespace to a single empty line. Currently 2. (vertical_whitespace)
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vertical Whitespace Violation: Limit vertical whitespace to a single empty line. Currently 2. (vertical_whitespace)
}.requireNonNil | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vertical Whitespace Violation: Limit vertical whitespace to a single empty line. Currently 2. (vertical_whitespace)
/// error of the specified type | ||
public func matchError<T: Error>(_ errorType: T.Type) -> Predicate<Error> { | ||
return Predicate.fromDeprecatedClosure { actualExpression, failureMessage in | ||
let actualError: Error? = try actualExpression.evaluate() | ||
|
||
setFailureMessageForError(failureMessage, postfixMessageVerb: "match", actualError: actualError, errorType: errorType) | ||
return errorMatchesNonNilFieldsOrClosure(actualError, errorType: errorType) | ||
var matches = false | ||
if let _ = actualError as? T { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused Optional Binding Violation: Prefer != nil
over let _ =
(unused_optional_binding)
let location = actualExpression.location | ||
let actualValue = try! actualExpression.evaluate() | ||
failureMessage.postfixMessage = "be empty" | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vertical Whitespace Violation: Limit vertical whitespace to a single empty line. Currently 2. (vertical_whitespace)
- Fix regression where `expect(nil as [String]?).toEventuallyNot(beNil())` fails. (Closes Quick#424) - Fix bug in Nimble's internal failure checker: `failsWithErrorMessage`. (Closes Quick#425). Shout out to @chamander for finding the bug. - Fix `Error` failing to dispatch to `Equatable` equality checking (instead of `NSError`). What's left: Fix the failure cases that the `failsWithErrorMessage` fix reveals in `NMBObjCMatcher`. `NMBObjCMatcher` will need the same trinary behavior that `Predicate` has.
546c32a
to
e3726f7
Compare
Fixes expectation regression & failure bugs.
expect(nil as [String]?).toEventuallyNot(beNil())
fails. (ClosestoEventuallyNot
passes when it should not on Nimble 7.0.0 #424)failsWithErrorMessage
. (Closes Expectations are not behaving as expected! #425). Shout out to @chamander for finding the bug.Error
failing to dispatch toEquatable
equality checking (instead ofNSError
).What's left:
Fix the failure cases that the
failsWithErrorMessage
fix reveals inNMBObjCMatcher
.NMBObjCMatcher
will need the same trinary behavior thatPredicate
has.