Skip to content

Commit 5647f19

Browse files
committed
docs(32): Added documentation for assertions on the Raise type
1 parent b91af37 commit 5647f19

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,26 @@ Use the `in.rcard.assertj.arrowcore.EitherAssert` class as an entry point to ass
6767
| `asRight` | Verifies that the actual `Either` is not `null` and contains a right-sided value and returns an `Object` assertion that allows chaining (object) assertions on the value. |
6868
| `containsOnLeft` | Verifies that the actual `Either` is `Either.Left` and contains the given value. |
6969
| `containsLeftInstanceOf` | Verifies that the actual left-sided `Either` contains a value that is an instance of the argument. |
70-
| `asLeft` | Verifies that the actual `Either` is not `null` and contains a left-sided value and returns an `Object` assertion that allows chaining (object) assertions on the value. |
70+
| `asLeft` | Verifies that the actual `Either` is not `null` and contains a left-sided value and returns an `Object` assertion that allows chaining (object) assertions on the value. |
71+
72+
### `Raise<E>.() -> A`
73+
74+
Use the `in.rcard.assertj.arrowcore.RaiseAssert` class as an entry point to assert `Raise<E>.() -> A` instances. There
75+
are many different entry points, all of them available boh for regular and `suspend` functions:
76+
77+
| Entry Point | Description |
78+
|----------------------|-----------------------------------------------------------------------------------------------------------------------------|
79+
| `assertThat` | Entry point to assert a `Raise<E>.() -> A` instance. |
80+
| `assertThatThrownBy` | Verifies that the function in the `Raise` context throws an exception and let chaining assertion on the thrown exception |
81+
| `assertThatRaisedBy` | Verifies that the function in the `Raise` context raises a logic-typed error and let chaining assertion on the raised error |
82+
83+
The available assertions are:
84+
85+
| Assertions | Description |
86+
|----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
87+
| `succeedsWith` | Verifies that the function in the `Raise` context succeeds with the given value. |
88+
| `succeeds` | Verifies that the function in the `Raise` context succeeded. No check on the value returned by the function is performed. |
89+
| `raises` | Verifies that the function in the Raise context fails with the given error. |
90+
| `fails` | Verifies that the function in the Raise context fails, no matter the type of the logical error. |
91+
| `result` | Verifies that the actual function in the `Raise` context succeeds and returns an `Object` assertion that allows chaining (object) assertions on the returned value. |
92+
| `error` | Verifies that the actual function in the Raise context fails and returns an Object assertion that allows chaining (object) assertions on the raised error. |

src/main/kotlin/in/rcard/assertj/arrowcore/RaiseAssert.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ class RaiseAssert<ERROR : Any, VALUE : Any>(
6161
.failure(Assertions.assertThat(throwable).writableAssertionInfo, shouldThrowAnException())
6262
}
6363

64+
/**
65+
* Verifies that the function in the [Raise] context raises an error.
66+
* @param shouldRaiseError the function to be executed in the [Raise] context.
67+
* @return the [AbstractObjectAssert] to be used to verify the error.
68+
*/
6469
inline fun <ERROR : Any, VALUE : Any> assertThatRaisedBy(
6570
@BuilderInference shouldRaiseError: Raise<ERROR>.() -> VALUE,
6671
): AbstractObjectAssert<*, out ERROR> {

0 commit comments

Comments
 (0)