Replies: 5 comments
-
I'm sorry for the really late response but this looks interesting! |
Beta Was this translation helpful? Give feedback.
-
thank you for the reply @ikesyo. This still would be useful for our projects. With the change matcher, we can be assured that tests did not pass accidentally because the value was already matching expected. Also, it will help us writing tests without storing initial values in the variable that we have to name. Currently, we are writing preconditions for tests in "before each" block, which is less readable. |
Beta Was this translation helpful? Give feedback.
-
A very simple PoC: func change(_ subject: @autoclosure @escaping () -> Int, by delta: Int) -> Predicate<Void> {
return Predicate.define { expr -> PredicateResult in
let before = subject()
try expr.evaluate()
let after = subject()
let diff = after - before
return PredicateResult(
bool: diff == delta,
message: .expectedTo("change the subject by \(delta), but did change by \(diff)")
)
}
} |
Beta Was this translation helpful? Give feedback.
-
Love it! |
Beta Was this translation helpful? Give feedback.
-
For
|
Beta Was this translation helpful? Give feedback.
-
What did you do?
Write a spec that verifies change in the collection
What did you expect to happen?
To use
What actually happened instead?
Environment
Please also mention which package manager you used and its version. Delete the
other package managers in this list:
Project that demonstrates the issue
Here is an example of change matcher from RSpec:
https://relishapp.com/rspec/rspec-expectations/docs/built-in-matchers/change-matcher
Beta Was this translation helpful? Give feedback.
All reactions