MockWS

mockws.MockWS
See theMockWS companion object
class MockWS(routes: Routes, shutdownHook: () => Unit)(implicit val materializer: Materializer, notFoundBehaviour: RouteNotDefined) extends WSClient

Mock implementation for the play.api.libs.ws.WSClient. Usage:

 val ws = MockWS {
   case ("GET", "/") => Action { Ok("index") }
   case ("GET", "/hi") => Action { Ok("world") }
 }

MockWS.Routes is a partial function. It is also possible to combine routes together:

 val index = MockWS.Routes {
   case ("GET", "/") => Action { Ok("index") }
 }
 val hiWorld = MockWS.Routes {
   case ("GET", "/hi") => Action { Ok("world") }
 }
 val ws = MockWS(index orElse hiWorld)

Value parameters

routes

routes defining the mock calls

Attributes

Companion
object
Graph
Supertypes
trait WSClient
trait Closeable
trait AutoCloseable
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

override def close(): Unit

Closes this client, and releases underlying resources.

Closes this client, and releases underlying resources.

Attributes

Definition Classes
WSClient -> Closeable -> AutoCloseable
override def underlying[T]: T

The underlying implementation of the client, if any. You must cast explicitly to the type you want.

The underlying implementation of the client, if any. You must cast explicitly to the type you want.

Type parameters

T

the type you are expecting (i.e. isInstanceOf)

Attributes

Returns

the backing class.

Definition Classes
WSClient
override def url(url: String): WSRequest

Generates a request.

Generates a request.

Value parameters

url

The base URL to make HTTP requests to.

Attributes

Returns

a request

Definition Classes
WSClient

Implicits

Implicits

implicit val materializer: Materializer