diff options
Diffstat (limited to 'core/src/main/scala/com/softwaremill/sttp/testing/SttpBackendStub.scala')
-rw-r--r-- | core/src/main/scala/com/softwaremill/sttp/testing/SttpBackendStub.scala | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/core/src/main/scala/com/softwaremill/sttp/testing/SttpBackendStub.scala b/core/src/main/scala/com/softwaremill/sttp/testing/SttpBackendStub.scala index 9bd3120..fed2acc 100644 --- a/core/src/main/scala/com/softwaremill/sttp/testing/SttpBackendStub.scala +++ b/core/src/main/scala/com/softwaremill/sttp/testing/SttpBackendStub.scala @@ -91,8 +91,10 @@ class SttpBackendStub[R[_], S] private ( def thenRespondServerError(): SttpBackendStub[R, S] = thenRespondWithCode(500, "Internal server error") def thenRespondWithCode(code: Int, - msg: String = ""): SttpBackendStub[R, S] = - thenRespond(Response[Nothing](Left(msg), code, Nil, Nil)) + msg: String = ""): SttpBackendStub[R, S] = { + val body = if (code >= 200 && code < 300) Right(msg) else Left(msg) + thenRespond(Response(body, code, Nil, Nil)) + } def thenRespond[T](body: T): SttpBackendStub[R, S] = thenRespond(Response[T](Right(body), 200, Nil, Nil)) def thenRespond[T](resp: => Response[T]): SttpBackendStub[R, S] = { |