-
-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
3883719
commit 5f52211
Showing
2 changed files
with
51 additions
and
0 deletions.
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
47 changes: 47 additions & 0 deletions
47
...-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/FileExpectationSamples.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package ch.tutteli.atrium.api.fluent.en_GB.samples | ||
|
||
import ch.tutteli.atrium.api.fluent.en_GB.* | ||
import ch.tutteli.atrium.api.verbs.internal.expect | ||
import ch.tutteli.niok.newFile | ||
import java.nio.file.Files | ||
import kotlin.test.Test | ||
|
||
class FileExpectationSamples { | ||
|
||
private val tempDir = Files.createTempDirectory("FileAssertionSamples") | ||
|
||
@Test | ||
fun asPathFeature() { | ||
val file = tempDir.newFile("target").toFile() | ||
|
||
expect(file) | ||
.asPath() // subject is now of type Path | ||
.toBeARegularFile() | ||
|
||
fails { | ||
expect(file) | ||
.asPath() | ||
.toBeADirectory() //fails | ||
} | ||
} | ||
|
||
@Test | ||
fun asPath() { | ||
val file = tempDir.newFile("target").toFile() | ||
|
||
expect(file).asPath { // subject within this block is of type Path | ||
toBeARegularFile() | ||
toStartWith(tempDir) | ||
} // subject here is back to type File | ||
|
||
fails { | ||
// all assertions are evaluated inside an assertion group block; for more details: | ||
// https://github.com/robstoll/atrium#define-single-assertions-or-assertion-groups | ||
|
||
expect(file).asPath { | ||
toBeADirectory() // fails | ||
notToStartWith(tempDir) // still evaluated, use `.asPath().` if you want a fail fast behaviour | ||
} | ||
} | ||
} | ||
} |