Skip to content
This repository has been archived by the owner on Aug 4, 2018. It is now read-only.

Comcast/pre-canned

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pre-canned

Build Status

Mocking HTTP services on spray can for integration testing

Introduction

Pre-canned helps you to mock out the HTTP services your application depends on. This can be especially useful for your integration testing.

For SBT add the dependency "com.netaporter" %% "pre-canned" % "0.0.7" % "test"

DSLs

Pre-canned currently comes in two flavours:

  • basic - Simple, but many parentheses
  • fancy - Few parentheses, but quite wordy

Help make Pre-canned better and submit a new improved flavour via a PR, or ideas for one in an issue.

There are a basic set of expectations and canned responses. Feel free to contribute more via a PR.

basic

import com.netaporter.precanned.dsl.basic._

val animalApi = httpServerMock(system).bind(8765).block

animalApi.expect(get, path("/animals"), query("name" -> "giraffe"))
         .andRespondWith(resource("/responses/giraffe.json"))

resource("example.json") will look for files in src/main/resources/example.json or src/test/resources/example.json

fancy

import com.netaporter.precanned.dsl.fancy._

val animalApi = httpServerMock(system).bind(8766).block

animalApi expect
  get and path("/animals") and query("name" -> "giraffe") and
respond using
  resource("/responses/giraffe.json") end()

About

Mocking HTTP services on spray-can for integration testing

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Scala 100.0%