Skip to content

Instantly share code, notes, and snippets.

@eicnix
Created July 14, 2015 07:50
Show Gist options
  • Save eicnix/44b073726bea9eda50ce to your computer and use it in GitHub Desktop.
Save eicnix/44b073726bea9eda50ce to your computer and use it in GitHub Desktop.
Simple response mocking for dispatch using scalamock
// Example for lukaseichler.de/how-to-test-dispatch-request/
import dispatch.{HttpExecutor, _}
import dispatch.Defaults._
val httpMock = mock[HttpExecutor]
(httpMock.apply(_: (Request, AsyncHandler[String]))(_: ExecutionContext))
.expects(*, *)
.returning(Future[String] {
"Hello World"
})
class Foo(http: HttpExecutor = Http) // Allow to override default HttpExecutor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment