Skip to content

Commit b91af37

Browse files
committed
docs(32): Added documentation for assertions on the Option and Either type
1 parent 1cb84fa commit b91af37

File tree

1 file changed

+47
-6
lines changed

1 file changed

+47
-6
lines changed

README.md

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,64 @@
77

88
# assertj-arrow-core
99

10-
This project provides a set of [AssertJ](https://assertj.github.io/doc/) assertions for the [Arrow](https://arrow-kt.io/) library. In detail, the project provides assertions for the following Arrow types:
10+
This project provides a set of [AssertJ](https://assertj.github.io/doc/) assertions for
11+
the [Arrow](https://arrow-kt.io/) library. In detail, the project provides assertions for the following Arrow types:
1112

1213
- [x] `Either<E, A>`
1314
- [x] `Option<A>`
1415
- [x] `Raise<E>.() -> A`
1516

16-
Maybe you're asking yourself: "Why do we need AssertJ assertions for Arrow types?". The answer is simple: We often use Kotlin and Arrow Kt inside a Java project using Spring Boot. In this case, we already have AssertJ in the classpath as an assertion library. So, why not use it to assert Arrow types?
17+
Maybe you're asking yourself: "Why do we need AssertJ assertions for Arrow types?". The answer is simple: We often use
18+
Kotlin and Arrow Kt inside a Java project using Spring Boot. In this case, we already have AssertJ in the classpath as
19+
an assertion library. So, why not use it to assert Arrow types?
1720

1821
## Usage
1922

2023
The library is available on Maven Central. To use it, add the following dependency to your `pom.xml` file:
2124

2225
```xml
26+
2327
<dependency>
24-
<groupId>in.rcard</groupId>
25-
<artifactId>assertj-arrow-core</artifactId>
26-
<version>1.1.0</version>
27-
<scope>test</scope>
28+
<groupId>in.rcard</groupId>
29+
<artifactId>assertj-arrow-core</artifactId>
30+
<version>1.1.0</version>
31+
<scope>test</scope>
2832
</dependency>
2933
```
34+
35+
Otherwise, if you're using Gradle, add the following dependency to your `build.gradle.kts` file:
36+
37+
```kotlin
38+
testImplementation("in.rcard:assertj-arrow-core:1.1.0")
39+
```
40+
41+
## Assertions Guide
42+
43+
This section describes the assertions provided by the `assertj-arrow-core` library.
44+
45+
### `Option<A>`
46+
47+
Use the `in.rcard.assertj.arrowcore.OptionAssert` class as an entry point to assert `Option<A>` instances.
48+
49+
| Assertions | Description |
50+
|----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|
51+
| `isEmpty` | Verifies that the actual `Option` is empty. |
52+
| `contains` | Verifies that the actual `Option` contains the given value. |
53+
| `containsInstanceOf` | Verifies that the actual `Option` contains a value that is an instance of the argument. |
54+
| `get` | Verifies that the actual Option is not null and not empty and returns an Object assertion that allows chaining (object) assertions on the optional value. |
55+
| `isDefined` | Verifies that there is a value present in the actual `Option`. |
56+
57+
### `Either<E, A>`
58+
59+
Use the `in.rcard.assertj.arrowcore.EitherAssert` class as an entry point to assert `Either<E, A>` instances.
60+
61+
| Assertions | Description |
62+
|---------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
63+
| `isRight` | Verifies that the actual `Either` is right. |
64+
| `isLeft` | Verifies that the actual `Either` is left. |
65+
| `containsOnRight` | Verifies that the actual `Either` is `Either.Right` and contains the given value. |
66+
| `containsRightInstanceOf` | Verifies that the actual right-sided `Either` contains a value that is an instance of the argument. |
67+
| `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. |
68+
| `containsOnLeft` | Verifies that the actual `Either` is `Either.Left` and contains the given value. |
69+
| `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. |

0 commit comments

Comments
 (0)