Skip to content

Instantly share code, notes, and snippets.

@canergulgec
Created January 24, 2021 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save canergulgec/ec19eaace43d5351f64d34f02be2311d to your computer and use it in GitHub Desktop.
Save canergulgec/ec19eaace43d5351f64d34f02be2311d to your computer and use it in GitHub Desktop.
fun dispatcherWithCustomBody() = object : Dispatcher() {
override fun dispatch(request: RecordedRequest): MockResponse {
with(request.path) {
val response = MockResponse().setResponseCode(200)
return when {
this?.contains("/images") == true -> response
.setBody(FileReader.readTestResourceFile("movie_images_response.json"))
else -> response
.setBody(FileReader.readTestResourceFile("success_response.json"))
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment