brian-watkins/elm-spec/1.0.1

NOTE: the latest version is 3.3.2

Spec.Http.Stub

Define and set up stubs for HTTP requests made during a spec.

Set Up Stubs

Represents the stubbed response for a particular HTTP request.

serve : List HttpResponseStub -> Setup model msg -> Setup model msg

Set up a fake HTTP server to serve a stubbed response when a matching request is made.

Define Stubs

for : HttpRoute -> HttpResponseStub

Build a stubbed response for requests made to the given route.

By default, the stubbed response has:

  • 200 status code
  • no headers
  • no body

Supply a body for the stubbed response.

Supply a status code for the stubbed response.

withHeader : ( String, String ) -> HttpResponseStub -> HttpResponseStub

Supple a header (key, value) for the stubbed response.

Set the stubbed response to trigger a network error.

Set the stubbed response to trigger a timeout error.

Abstain from responding to requests to the route defined for the given HttpResponseStub.

It can be useful to abstain from responding if you want to describe the behavior of your program while waiting for a response.