Is it expected that `shouldBeAFile()` passes on mi...
# kotest
m
Is it expected that
shouldBeAFile()
passes on missing files?
Copy code
// This seems to pass
"nonExistent".toPath().shouldBeAFile()
There is also
shouldExist()
but I find this surprising that
shouldBeAFile()
doesn't check for existence of the file
l
I don't think it should. Could you open a ticket on GitHub?
👍 2
m
l
The only check that is made is if the file is not a directory:
Copy code
fun aFile(): Matcher<Path> = object : Matcher<Path> {
   override fun test(value: Path): MatcherResult = MatcherResult(
      !Files.isDirectory(value),
      { "File $value should be a directory" },
      { "File $value should not be a directory" })
}
🎯 1
m
There is
Path.isRegularFile()
, maybe it's just a matter of using this one?
l