aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authoradamw <adam@warski.org>2018-01-29 14:18:56 +0100
committeradamw <adam@warski.org>2018-01-29 14:18:56 +0100
commit10620d432ff20d1bfed7cf184d8042acf95eb9d7 (patch)
treeece446a63aed2c5870f645e9ff7c54df3ab4e15b /docs
parent88a3a820c8233d335242e51936bc22723c391cd3 (diff)
downloadsttp-10620d432ff20d1bfed7cf184d8042acf95eb9d7.tar.gz
sttp-10620d432ff20d1bfed7cf184d8042acf95eb9d7.tar.bz2
sttp-10620d432ff20d1bfed7cf184d8042acf95eb9d7.zip
Renaming the new stub method
Diffstat (limited to 'docs')
-rw-r--r--docs/testing.rst11
1 files changed, 5 insertions, 6 deletions
diff --git a/docs/testing.rst b/docs/testing.rst
index ead722b..9afcd0e 100644
--- a/docs/testing.rst
+++ b/docs/testing.rst
@@ -49,17 +49,16 @@ It is also possible to match requests by partial function, returning a response.
This approach to testing has one caveat: the responses are not type-safe. That is, the stub backend cannot match on or verify that the type of the response body matches the response body type requested.
-Another way to specify the behaviour is passing a response monad to Stub. It is useful if you need to test scenario with slow server, when response should be not returned immediately but after some time.
-Example with Futures: ::
+Another way to specify the behaviour is passing response wrapped in the result monad to the stub. It is useful if you need to test a scenario with a slow server, when the response should be not returned immediately, but after some time. Example with Futures: ::
- implicit val testingBackend = SttpBackendStub(new FutureMonad()).whenAnyRequest
- .thenRespondWithMonad(Future {
+ implicit val testingBackend = SttpBackendStub.asynchronousFuture.whenAnyRequest
+ .thenRespondWrapped(Future {
Thread.sleep(5000)
Response(Right("OK"), 200, "", Nil, Nil)
})
- val respFuture = sttp.get(uri"http://example.org").send()
- // responseFuture will complete after 10 seconds with "OK" response
+ val responseFuture = sttp.get(uri"http://example.org").send()
+ // responseFuture will complete after 5 seconds with "OK" response
Simulating exceptions
---------------------