From 575b5c95c7f338d3b1ef718606c9094200d1c9c8 Mon Sep 17 00:00:00 2001 From: Joseph Cooper Date: Mon, 20 May 2024 16:42:50 +0100 Subject: [PATCH] Rename JVM Path helper functions --- .../jvmMain/kotlin/assertk/assertions/path.kt | 18 ++++++++++++++++-- .../kotlin/test/assertk/assertions/PathTest.kt | 4 ++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/assertk/src/jvmMain/kotlin/assertk/assertions/path.kt b/assertk/src/jvmMain/kotlin/assertk/assertions/path.kt index d7335397..bdf9880b 100644 --- a/assertk/src/jvmMain/kotlin/assertk/assertions/path.kt +++ b/assertk/src/jvmMain/kotlin/assertk/assertions/path.kt @@ -13,13 +13,27 @@ import java.nio.file.Path * * @param charset charset to use when reading file */ -fun Assert.lines(charset: Charset = Charsets.UTF_8): Assert> = +fun Assert.havingLines(charset: Charset = Charsets.UTF_8): Assert> = transform { actual -> Files.readAllLines(actual, charset) } +@Deprecated( + message = "Function lines has been renamed to havingLines", + replaceWith = ReplaceWith("havingLines()"), + level = DeprecationLevel.WARNING +) +fun Assert.lines(charset: Charset = Charsets.UTF_8): Assert> = havingLines() + /** Assert on file bytes */ -fun Assert.bytes(): Assert = +fun Assert.havingBytes(): Assert = transform { actual -> Files.readAllBytes(actual) } +@Deprecated( + message = "Function bytes has been renamed to havingBytes", + replaceWith = ReplaceWith("havingBytes()"), + level = DeprecationLevel.WARNING +) +fun Assert.bytes(): Assert = havingBytes() + /** Assert that the path is a regular file. * * @param options indicating how symbolic links are handled diff --git a/assertk/src/jvmTest/kotlin/test/assertk/assertions/PathTest.kt b/assertk/src/jvmTest/kotlin/test/assertk/assertions/PathTest.kt index 86a92368..e5e77bcd 100644 --- a/assertk/src/jvmTest/kotlin/test/assertk/assertions/PathTest.kt +++ b/assertk/src/jvmTest/kotlin/test/assertk/assertions/PathTest.kt @@ -164,14 +164,14 @@ class PathTest { //region lines @Test fun lines_correct_string_passes() { - assertThat(regularFileWithText!!).lines().containsExactly("a", "b") + assertThat(regularFileWithText!!).havingLines().containsExactly("a", "b") } //endregion //region bytes @Test fun bytes_value_correct_byte_array_passes() { - assertThat(regularFile!!).bytes().containsExactly(*ByteArray(10)) + assertThat(regularFile!!).havingBytes().containsExactly(*ByteArray(10)) } //endregion }