infix fun <T : Path> Expect<T>.resolve(other: String): Expect<Path>
(source)
Expects that other resolves against this Path and creates an Expect for the resolved Path so that further fluent calls are assertions about it.
val dir = tempDir.newDirectory("test_dir")
val fileInDir = dir.newFile("test_file.txt")
expect(dir) resolve "test_file.txt" toEqual fileInDir toEndWith Paths.get("test_file.txt")
// | subject changes to `test_dir/test_file.txt`
fails {
expect(dir) resolve "test_file.ttt" toEqual fileInDir toEndWith Paths.get("ttt")
// | | | not reported toEqual already fails
// | | | use `resolve path(other) { ... }` if you want that all expectations are evaluated
// | | fails because resolve returns *test_file.ttt and fileInDir equals *test_file.txt
}
Return
The newly created Expect for the extracted feature.
Since
0.12.0
infix fun <T : Path> Expect<T>.resolve(path: PathWithCreator<Path>): Expect<T>
(source)
Expects that PathWithCreator.path resolves against this Path, that the resolved Path holds all assertions the
given PathWithCreator.assertionCreator creates for it and
returns an Expect for the current subject of this
expectation.
Use the function path(String) { ... }
to create a PathWithCreator.
val dir = tempDir.newDirectory("test_dir")
val fileInDir = dir.newFile("test_file.txt")
expect(dir) resolve path("test_file.txt") { // subject inside this block refers to `test_dir/test_file.txt`
it toEqual fileInDir
it toBe existing
} // subject here is back to `test_dir`
fails {
expect(dir) resolve path("test_file.ttt") {
it toEqual fileInDir // fails
it toBe existing // still evaluated even though `toEqual(fileInDir)` already fails
// use `.resolve other` if you want a fail fast behaviour
}
}
Return
The newly created Expect for the extracted feature.
Since
0.12.0