Skip to content

Mocking HTTP services on spray-can for integration testing

License

Notifications You must be signed in to change notification settings

arso/pre-canned

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 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.4" % "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"))

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

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Scala 100.0%