blob: a6984c877008292a6416543280e255ce6b0d1be6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
package com.softwaremill.sttp.testing
import java.nio.file.{Files, Paths}
import java.{io, util}
import org.scalatest.matchers.{MatchResult, Matcher}
object CustomMatchers {
class FileContentsMatch(file: java.io.File) extends Matcher[java.io.File] {
override def apply(left: io.File): MatchResult = {
val inBA = Files.readAllBytes(Paths.get(left.getAbsolutePath))
val expectedBA = Files.readAllBytes(Paths.get(file.getAbsolutePath))
MatchResult(
util.Arrays.equals(inBA, expectedBA),
"The files' contents are not the same",
"The files' contents are the same"
)
}
}
def haveSameContentAs(file: io.File) = new FileContentsMatch(file)
}
|