toHaveTheSameTextualContentAs

fun <T : Path> Expect<T>.toHaveTheSameTextualContentAs(targetPath: Path, sourceCharset: Charset = Charsets.UTF_8, targetCharset: Charset = Charsets.UTF_8): Expect<T>(source)

Expects that the subject of this expectation (a Path) has the same textual content as targetPath taking the given encodings into account (UTF-8 if none given).

Return

an Expect for the subject of this expectation.

Since

0.17.0

Parameters

sourceCharset

source file encoding - UTF-8 per default.

targetCharset

target file encoding - UTF-8 per default.

Samples

val writtenTextInFile = "test_test"

val notEmptyFilePath = tempDir.newFile("test_file_1")
notEmptyFilePath.writeText(writtenTextInFile)

val expectedFilePath = tempDir.newFile("test_file_2")
expectedFilePath.writeText(writtenTextInFile)

val emptyFilePath = tempDir.newFile("test_file_3")

expect(notEmptyFilePath).toHaveTheSameTextualContentAs(expectedFilePath)

fails { // because nothing is written inside of `emptyFilePath`
    expect(emptyFilePath).toHaveTheSameTextualContentAs(expectedFilePath)
}