aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/scala
diff options
context:
space:
mode:
authorPaweł Stawicki <pawelstawicki@gmail.com>2018-01-28 09:42:58 +0100
committerPaweł Stawicki <pawelstawicki@gmail.com>2018-01-28 09:46:19 +0100
commit2cd4df4de975c45d566bc1304abc699b80023533 (patch)
tree2758f152b267eac6b240ba99b8e172ddd6acb308 /core/src/main/scala
parent9da3ff4fd8fc76772b365b1368d335d1722f007b (diff)
downloadsttp-2cd4df4de975c45d566bc1304abc699b80023533.tar.gz
sttp-2cd4df4de975c45d566bc1304abc699b80023533.tar.bz2
sttp-2cd4df4de975c45d566bc1304abc699b80023533.zip
Added back the thenRespond(resp: => Response) method
Diffstat (limited to 'core/src/main/scala')
-rw-r--r--core/src/main/scala/com/softwaremill/sttp/testing/SttpBackendStub.scala11
1 files changed, 8 insertions, 3 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 9e52505..a603894 100644
--- a/core/src/main/scala/com/softwaremill/sttp/testing/SttpBackendStub.scala
+++ b/core/src/main/scala/com/softwaremill/sttp/testing/SttpBackendStub.scala
@@ -103,11 +103,16 @@ class SttpBackendStub[R[_], S] private (
def thenRespondWithCode(code: Int,
msg: String = ""): SttpBackendStub[R, S] = {
val body = if (code >= 200 && code < 300) Right(msg) else Left(msg)
- thenRespondWithMonad(rm.unit(Response(body, code, msg, Nil, Nil)))
+ thenRespond(Response(body, code, msg, Nil, Nil))
}
def thenRespond[T](body: T): SttpBackendStub[R, S] =
- thenRespondWithMonad(
- rm.unit(Response[T](Right(body), 200, "OK", Nil, Nil)))
+ thenRespond(Response[T](Right(body), 200, "OK", Nil, Nil))
+ def thenRespond[T](resp: => Response[T]): SttpBackendStub[R, S] = {
+ val m: PartialFunction[Request[_, _], R[Response[_]]] = {
+ case r if p(r) => rm.unit(resp)
+ }
+ new SttpBackendStub(rm, matchers.orElse(m), fallback)
+ }
def thenRespondWithMonad(resp: => R[Response[_]]): SttpBackendStub[R, S] = {
val m: PartialFunction[Request[_, _], R[Response[_]]] = {
case r if p(r) => resp