-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Same type for asserting occurrences of same value (#25)
* Same type for asserting occurrences of same value When you have an unknown value that needs to repeat in the expected assertion you don't have a lot of good options. You can let the result, and pull out as many values as you want to check but this quickly gets cumbersome, where the structure of actual needs to be declared twice, once to pull out the values to check and again in expected. In this case, we want to assert, that `<id1>` and `<id2> are the same across the actual value. We can do this with `=?/same` ``` (let [actual [{:id <id1> :ref [:field <id1>]} {:id <id2> :ref [:field <id1>]}] id1 (get-in actual [0 :id]) id2 (get-in actual [1 :id])] (is (=? [{:id id1 :ref [:field id1]} {:id id2 :ref [:field id2] actual))) (let [actual [{:id <id1> :ref [:field <id1>]} {:id <id2> :ref [:field <id1>]}]] (is (=? [{:id (=?/same :id1) :ref [:field (=?/same :id1)]} {:id (=?/same :id2) :ref [:field (=?/same :id2)]}] actual))) ``` * Address pr feedback
- Loading branch information
Showing
2 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters