aboutsummaryrefslogtreecommitdiff
path: root/core/src/test/scala/com/softwaremill/sttp/testing/CustomMatchers.scala
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/test/scala/com/softwaremill/sttp/testing/CustomMatchers.scala')
-rw-r--r--core/src/test/scala/com/softwaremill/sttp/testing/CustomMatchers.scala22
1 files changed, 22 insertions, 0 deletions
diff --git a/core/src/test/scala/com/softwaremill/sttp/testing/CustomMatchers.scala b/core/src/test/scala/com/softwaremill/sttp/testing/CustomMatchers.scala
new file mode 100644
index 0000000..a6984c8
--- /dev/null
+++ b/core/src/test/scala/com/softwaremill/sttp/testing/CustomMatchers.scala
@@ -0,0 +1,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)
+}