aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Stawicki <pawelstawicki@gmail.com>2018-01-29 12:48:52 +0100
committerPaweł Stawicki <pawelstawicki@gmail.com>2018-01-29 12:48:52 +0100
commit2f2c6b66adf8f2157f7c3cdf47d7d784ed105e87 (patch)
tree6d04b38547450f09041cdfe10d50fad5f2212836
parent2cd4df4de975c45d566bc1304abc699b80023533 (diff)
downloadsttp-then-respond-future.tar.gz
sttp-then-respond-future.tar.bz2
sttp-then-respond-future.zip
Added test for respondWithMonad happy paththen-respond-future
-rw-r--r--core/src/test/scala/com/softwaremill/sttp/testing/SttpBackendStubTests.scala10
1 files changed, 10 insertions, 0 deletions
diff --git a/core/src/test/scala/com/softwaremill/sttp/testing/SttpBackendStubTests.scala b/core/src/test/scala/com/softwaremill/sttp/testing/SttpBackendStubTests.scala
index 9a435b2..8a4eeb2 100644
--- a/core/src/test/scala/com/softwaremill/sttp/testing/SttpBackendStubTests.scala
+++ b/core/src/test/scala/com/softwaremill/sttp/testing/SttpBackendStubTests.scala
@@ -28,6 +28,8 @@ class SttpBackendStubTests extends FlatSpec with Matchers with ScalaFutures {
List("partialAda")) =>
Response(Right("Ada"), 200, "OK", Nil, Nil)
})
+ .whenRequestMatches(_.uri.port.exists(_ == 8080))
+ .thenRespondWithMonad(Response(Right("OK from monad"), 200, "OK", Nil, Nil))
"backend stub" should "use the first rule if it matches" in {
implicit val b = testingStub
@@ -52,6 +54,14 @@ class SttpBackendStubTests extends FlatSpec with Matchers with ScalaFutures {
r.body should be('right)
}
+ it should "respond with monad with set response" in {
+ implicit val b = testingStub
+ val r = sttp.post(uri"http://example.org:8080").send()
+ r.is200 should be(true)
+ r.body should be('right)
+ r.body.right.get should be("OK from monad")
+ }
+
it should "use the default response if no rule matches" in {
implicit val b = testingStub
val r = sttp.put(uri"http://example.org/d").send()