Skip to content

Commit 575b5c9

Browse files
author
Joseph Cooper
committed
Rename JVM Path helper functions
1 parent 0521af0 commit 575b5c9

File tree

2 files changed

+18
-4
lines changed
  • assertk/src

2 files changed

+18
-4
lines changed

assertk/src/jvmMain/kotlin/assertk/assertions/path.kt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,27 @@ import java.nio.file.Path
1313
*
1414
* @param charset charset to use when reading file
1515
*/
16-
fun Assert<Path>.lines(charset: Charset = Charsets.UTF_8): Assert<List<String>> =
16+
fun Assert<Path>.havingLines(charset: Charset = Charsets.UTF_8): Assert<List<String>> =
1717
transform { actual -> Files.readAllLines(actual, charset) }
1818

19+
@Deprecated(
20+
message = "Function lines has been renamed to havingLines",
21+
replaceWith = ReplaceWith("havingLines()"),
22+
level = DeprecationLevel.WARNING
23+
)
24+
fun Assert<Path>.lines(charset: Charset = Charsets.UTF_8): Assert<List<String>> = havingLines()
25+
1926
/** Assert on file bytes */
20-
fun Assert<Path>.bytes(): Assert<ByteArray> =
27+
fun Assert<Path>.havingBytes(): Assert<ByteArray> =
2128
transform { actual -> Files.readAllBytes(actual) }
2229

30+
@Deprecated(
31+
message = "Function bytes has been renamed to havingBytes",
32+
replaceWith = ReplaceWith("havingBytes()"),
33+
level = DeprecationLevel.WARNING
34+
)
35+
fun Assert<Path>.bytes(): Assert<ByteArray> = havingBytes()
36+
2337
/** Assert that the path is a regular file.
2438
*
2539
* @param options indicating how symbolic links are handled

assertk/src/jvmTest/kotlin/test/assertk/assertions/PathTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,14 @@ class PathTest {
164164
//region lines
165165
@Test
166166
fun lines_correct_string_passes() {
167-
assertThat(regularFileWithText!!).lines().containsExactly("a", "b")
167+
assertThat(regularFileWithText!!).havingLines().containsExactly("a", "b")
168168
}
169169
//endregion
170170

171171
//region bytes
172172
@Test
173173
fun bytes_value_correct_byte_array_passes() {
174-
assertThat(regularFile!!).bytes().containsExactly(*ByteArray(10))
174+
assertThat(regularFile!!).havingBytes().containsExactly(*ByteArray(10))
175175
}
176176
//endregion
177177
}

0 commit comments

Comments
 (0)