pact-jvm-consumer-specs2_2.12
· pact-jvm-consumer-specs2
========================
## Specs2 Bindings for the pact-jvm library
## Dependency
In the root folder of your project in build.sbt add the line:
```scala
libraryDependencies += "au.com.dius" %% "pact-jvm-consumer-specs2" % "3.2.11"
```
or if you are using Gradle:
```groovy
dependencies {
testCompile "au.com.dius:pact-jvm-consumer-specs2_2.11:3.2.11"
}
```
__*Note:*__ `PactSpec` requires spec2 3.x. Also, for spray users there's an incompatibility between specs2 v3.x and spray.
Follow these instructions to resolve that problem: https://groups.google.com/forum/#!msg/spray-user/2T6SBp4OJeI/AJlnJuAKPRsJ
## Usage
To author a test, mix `PactSpec` into your spec
First we define a service client called `ConsumerService`. In our example this is a simple wrapper for `dispatch`, an HTTP client. The source code can be found in the test folder alongside the `ExamplePactSpec`.
Here is a simple example:
```
import au.com.dius.pact.consumer.PactSpec
class ExamplePactSpec extends Specification with PactSpec {
val consumer = "My Consumer"
val provider = "My Provider"
override def is = uponReceiving("a request for foo")
.matching(path = "/foo")
.willRespondWith(body = "{}")
.withConsumerTest { providerConfig =>
Await.result(ConsumerService(providerConfig.url).simpleGet("/foo"), Duration(1000, MILLISECONDS)) must beEqualTo(200, Some("{}"))
}
}
```
This spec will be run along with the rest of your specs2 unit tests and will output your pact json to
```
/target/pacts/<Consumer>_<Provider>.json
```
# Forcing pact files to be overwritten (3.6.5+)
By default, when the pact file is written, it will be merged with any existing pact file. To force the file to be
overwritten, set the Java system property `pact.writer.overwrite` to `true`.
Choose a version of au.com.dius : pact-jvm-consumer-specs2_2.12 to add to Maven or Gradle - Latest Versions:
Latest Stable: 3.6.15
Latest Release Candidate: 3.6.0-rc.1
Latest Beta: 4.0.0-beta.6
All Versions
Choose a version of au.com.dius : pact-jvm-consumer-specs2_2.12 to add to Maven or Gradle - All Versions:
Version
Vulnerabilities
Updated
4.0.x
pact-jvm-consumer-specs2_2.12-4.0.10
pact-jvm-consumer-specs2_2.12-4.0.9
pact-jvm-consumer-specs2_2.12-4.0.8
pact-jvm-consumer-specs2_2.12-4.0.7
pact-jvm-consumer-specs2_2.12-4.0.6
pact-jvm-consumer-specs2_2.12-4.0.5
pact-jvm-consumer-specs2_2.12-4.0.4
pact-jvm-consumer-specs2_2.12-4.0.3
pact-jvm-consumer-specs2_2.12-4.0.2
pact-jvm-consumer-specs2_2.12-4.0.1
pact-jvm-consumer-specs2_2.12-4.0.0
pact-jvm-consumer-specs2_2.12-4.0.0-beta.6
pact-jvm-consumer-specs2_2.12-4.0.0-beta.5
pact-jvm-consumer-specs2_2.12-4.0.0-beta.4
pact-jvm-consumer-specs2_2.12-4.0.0-beta.3
pact-jvm-consumer-specs2_2.12-4.0.0-beta.2
3.6.x
pact-jvm-consumer-specs2_2.12-3.6.15
pact-jvm-consumer-specs2_2.12-3.6.14
pact-jvm-consumer-specs2_2.12-3.6.13
pact-jvm-consumer-specs2_2.12-3.6.12
pact-jvm-consumer-specs2_2.12-3.6.11
pact-jvm-consumer-specs2_2.12-3.6.10
pact-jvm-consumer-specs2_2.12-3.6.9
pact-jvm-consumer-specs2_2.12-3.6.8
pact-jvm-consumer-specs2_2.12-3.6.7
pact-jvm-consumer-specs2_2.12-3.6.6
pact-jvm-consumer-specs2_2.12-3.6.5
pact-jvm-consumer-specs2_2.12-3.6.4
pact-jvm-consumer-specs2_2.12-3.6.3
pact-jvm-consumer-specs2_2.12-3.6.2
pact-jvm-consumer-specs2_2.12-3.6.1
pact-jvm-consumer-specs2_2.12-3.6.0
pact-jvm-consumer-specs2_2.12-3.6.0-rc.1
pact-jvm-consumer-specs2_2.12-3.6.0-rc.0
3.5.x
pact-jvm-consumer-specs2_2.12-3.5.25
pact-jvm-consumer-specs2_2.12-3.5.24
pact-jvm-consumer-specs2_2.12-3.5.23
pact-jvm-consumer-specs2_2.12-3.5.22
pact-jvm-consumer-specs2_2.12-3.5.21
pact-jvm-consumer-specs2_2.12-3.5.20
pact-jvm-consumer-specs2_2.12-3.5.19
pact-jvm-consumer-specs2_2.12-3.5.18
pact-jvm-consumer-specs2_2.12-3.5.17
pact-jvm-consumer-specs2_2.12-3.5.16
pact-jvm-consumer-specs2_2.12-3.5.15
pact-jvm-consumer-specs2_2.12-3.5.14
pact-jvm-consumer-specs2_2.12-3.5.13
pact-jvm-consumer-specs2_2.12-3.5.12
pact-jvm-consumer-specs2_2.12-3.5.11
pact-jvm-consumer-specs2_2.12-3.5.10
pact-jvm-consumer-specs2_2.12-3.5.9
pact-jvm-consumer-specs2_2.12-3.5.8
pact-jvm-consumer-specs2_2.12-3.5.7
pact-jvm-consumer-specs2_2.12-3.5.6
pact-jvm-consumer-specs2_2.12-3.5.5
pact-jvm-consumer-specs2_2.12-3.5.4-rc.1
pact-jvm-consumer-specs2_2.12-3.5.4-rc.0
How to add a dependency to Maven
Add the following au.com.dius : pact-jvm-consumer-specs2_2.12 maven dependency to the pom.xml file with your favorite IDE (IntelliJ / Eclipse / Netbeans):