Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,23 @@ class ResponseBodyProxy private constructor(val body: Path) : ShouldBeString, Sh
}

// FIXME need more explained
override fun shouldBe(expected: String): TestResult =
if (body.toFile().readText(Charsets.UTF_8) == expected) {
override fun shouldBe(expected: String): TestResult {
val actual = body.toFile().readText(Charsets.UTF_8)
return if (actual == expected) {
Ok
} else {
Failed { simpleExplain(expected, body) }
Failed { simpleExplain(expected, actual) }
}
}

override fun shouldContain(expected: String): TestResult =
if (body.toFile().readText(Charsets.UTF_8).contains(expected)) {
override fun shouldContain(expected: String): TestResult {
val actual = body.toFile().readText(Charsets.UTF_8)
return if (actual.contains(expected)) {
Ok
} else {
Failed { simpleExplain(expected, body) }
Failed { simpleExplain(expected, actual) }
}
}

override fun toJsonPathProxy(path: String): JsonPathProxy =
body.toFile().readText(Charsets.UTF_8)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class ResponseBodyProxyTest : FunSpec({
| value: Hello, world!!
| class: kotlin.String
|Actual:
| value: [^\s]+/com/uzabase/playtest2/http/proxy/response-body.txt
| class: sun.nio.fs.UnixPath
| value: Hello, world
| class: kotlin.String
""".trimMargin()
)
}
Expand All @@ -50,9 +50,19 @@ class ResponseBodyProxyTest : FunSpec({
}

test("should not contain") {
fromClasspathToResponseBodyProxy("com/uzabase/playtest2/http/proxy/response-body.txt")
val result = fromClasspathToResponseBodyProxy("com/uzabase/playtest2/http/proxy/response-body.txt")
.shouldContain("world!!")
.shouldBeInstanceOf<Failed>()
result.shouldBeInstanceOf<Failed>()
result.explain().shouldMatch(
"""
|Expected:
| value: world!!
| class: kotlin.String
|Actual:
| value: Hello, world
| class: kotlin.String
""".trimMargin()
)
}
}

Expand Down