Assert absence of keys using `=in=>` assertions
- Dominant language
- Clojure
- Stars
- 45
- Forks
- 6
- PR merge metrics
- No merged PRs in 30d
Description
Hi! Thanks for this beautiful library!
While adopting this library I found a minor pain point with checking if something is absent using `=in=>`. For example, I want to assert that key `:b` is absent from map:
```clj
(testit/fact
":b is absent"
{:a 1} =in=> {:a pos? :b nil})
;; =>
;; :b is absent:
;; in [:b]:
;; actual is missing key :b
;; expected: nil
;; actual: nil
;; expected: {:a pos?, :b nil}
;; actual: {:a 1}
```
Currently for these kinds of assertions I have to use `=>` with extracting value on the left side, which may be okay on smaller examples, but not very expressive if checked key is deep inside.
It would be great to I be able to assert key absence in `=in=>` assertions, maybe, like that:
```clj
(testit/fact
{:a 1} =in=> {:a pos? :b absent?})
```
Contributor guide
Research direction
Start by locating the implementation and tests for the `=in=>` assertion, then read how nested map keys and predicate expectations are currently handled. Define the expected behavior for an `absent?` expectation using the issue's nested-map example, and add coverage showing that a missing key is accepted while existing keys continue to use their normal expectations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100