-
Notifications
You must be signed in to change notification settings - Fork 23
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
Missing a "roughly" matcher for dates #112
Comments
I guess we could create a |
some examples of how to do this in user land: (defn roughly-same-time [expected]
(matcher-combinators.core/->PredMatcher
(fn [actual]
(and (instance? java.time.Instant actual)
(.isAfter expected (.plus actual -5 java.time.temporal.ChronoUnit/SECONDS))
(.isBefore expected (.plus actual 5 java.time.temporal.ChronoUnit/SECONDS))))
(str "similar-time " expected " (+/- 5 seconds)")))
(is (match? {:scheduled-for-datetime (roughly-same-time this-month)}
(some-expr))) which gives mismatch info like this
or (require '[matcher-combinators.matchers :as m])
(is (match? (m/via #(.toEpochMilli %)
(m/within-delta 100 (.toEpochMilli (Instant/now))))
(some-expr))) which gives mismatch info like this
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No description provided.
The text was updated successfully, but these errors were encountered: