-
-
Notifications
You must be signed in to change notification settings - Fork 600
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
Yet another introduction of Protocol extension-based matchers #480
Conversation
|
||
/// Expectation extension to test the actual value using a matcher to not match by checking continously at pollInterval until the timeout is reached. | ||
public func toEventuallyNot(timeout: TimeInterval, pollInterval: TimeInterval) -> ExtensibleExpecation<T> { | ||
return ExtensibleExpecation(base: self, style: .toNotMatch, isAsync: true, timeout: timeout, pollInterval: pollInterval) |
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.
Line Length Violation: Line should be 120 characters or less: currently 128 characters (line_length)
|
||
/// Expectation extension to test the actual value using a matcher to match by checking continously at pollInterval until the timeout is reached. | ||
public func toEventually(timeout: TimeInterval, pollInterval: TimeInterval) -> ExtensibleExpecation<T> { | ||
return ExtensibleExpecation(base: self, style: .toMatch, isAsync: true, timeout: timeout, pollInterval: pollInterval) |
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.
Line Length Violation: Line should be 120 characters or less: currently 125 characters (line_length)
|
||
public func match(description: String? = nil, _ predicateFactory: @escaping () -> Predicate<T>) { | ||
if isAsync { | ||
nimblePrecondition(base.expression.isClosure, "NimbleInternalError", toEventuallyRequiresClosureError.stringValue) |
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.
Line Length Violation: Line should be 120 characters or less: currently 126 characters (line_length)
} | ||
} | ||
|
||
//MARK: Async Expectation Extensions |
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.
Mark Violation: MARK comment should be in valid format. e.g. '// MARK: ...' or '// MARK: - ...' (mark)
} | ||
} | ||
|
||
//MARK: Expectation extensions |
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.
Mark Violation: MARK comment should be in valid format. e.g. '// MARK: ...' or '// MARK: - ...' (mark)
public var to: ExtensibleExpecation<T> { | ||
return ExtensibleExpecation(base: self, style: .toMatch) | ||
} | ||
|
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.
Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)
timeout: timeout, | ||
poll: pollInterval, | ||
fnName: style == .toMatch ? "toEventually" : "toEventuallyNot") | ||
|
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.
Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)
if isAsync { | ||
nimblePrecondition(base.expression.isClosure, "NimbleInternalError", toEventuallyRequiresClosureError.stringValue) | ||
} | ||
|
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.
Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)
self.timeout = timeout | ||
self.pollInterval = pollInterval | ||
} | ||
|
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.
Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)
) { | ||
self.base = base | ||
self.style = style | ||
|
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.
Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)
@jeffh any chance this could be reviewed anytime soon? |
Hey @mosamer, I haven’t had much free time to do any development for awhile (computer and apt issues). Is there a reason to introduce a new extensible matched type over extending predicate (or even expectation)? Also, could you please add tests, thanks! |
Closing as this is stale. |
This PR is another attempt for #217, which is much less ambitious compared to #218
This PR introduces protocol extension-based matchers for
Expectation
. It only provides an infrastructure for the technique and would allow users to write their own custom matchers using it. Nimble matchers can be gradually migrated on later pull requests.It allows the following code;
Future Work:
ExtensibleExpectation
ExtensibleExpectation
¯_(ツ)_/¯