pact-foundation / pact-jvm

JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
https://docs.pact.io
Apache License 2.0
1.08k stars 479 forks source link

pact-jvm-consumer-specs2: missing groovy classes #210

Closed rachelwilson closed 8 years ago

rachelwilson commented 8 years ago

We're a Scala team and evaluating PACT hoping to introduce it to our project. However we're having difficulties getting the example up and running because of missing class dependencies that look like Groovy classes.

We're already using specs2 and so we've been looking at the ExampleTestSpec in the https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-consumer-specs2 module.

We've copied the three classes: ExampleTestSpec, Fixtures and ConsumerContract locally to our porject, added the dependency "au.com.dius "%% "pact-jvm-consumer-specs2" % "3.0.4" to build.sbt and then we can see the following jar files in the projects dependencies

pact-jvm-consumer-specs2_2.11:3.0.4.jar pact-jvm-consumer_2.11:3.0.4.jar pact-jvm-matchers_2.11:3.0.4.jar pact_jvm.model_2.11:3.0.4.jar

The Fixtures.scala class however does not compile because it can't find RequestResponseInteraction or PactReader. Those two classes seem to be groovy classes found in https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-model/src/main/groovy/au/com/dius/pact/model, and are not found as classes in the pact_jvm.model_2.11:3.0.4.jar dependency.

Are we missing a step? Are these groovy classes in another dependency that we need to import separately?

Also (a more minor point but thought it was worth mentioning) the ConsumerService didnt initially compile because the HttpClient actually seems to be in the au.com.dius.pact.model.dispatch package rather than the import au.com.dius.pact.consumer.dispatch in the Fixtures.scala file we copied

I confess I dont know Groovy at all other than by name, so you might need to be gentle with me. Oh and I'm using IntelliJ 14 with all the scala and groovy plugins turned on.

uglyog commented 8 years ago

More than happy to help. Let me first double check that the published jar files are correct.

uglyog commented 8 years ago

The latest version is 3.2.2, you may as well use that.

You have listed the model jar as

pact_jvm.model_2.11:3.0.4.jar
    ^   ^

It should be pact-jvm-model_2.11 (with hyphens)

uglyog commented 8 years ago

The issue with the ConsumerService is due to a refactor that occurred between version 3.0.4 and 3.2.2, so if you update to the latest jars, the example code you copied from master should correspond to what is in the published jars.

Otherwise, copy the example from the 3_0_4 tag.

rachelwilson commented 8 years ago

Thanks very much for your reply.

Oops, excuse my bad typing re the model jar, it is as you describe but my fingers went awry

Wonderful, I updated the dependency version to 3.2.2 and - after I upgraded to specs2 v3 - everything compiles.

By the way, along with your README notice of the requirement for specs2v3.x, you might want to warn users that there's an incompatibility between specs2 v3.x and spray. Following these instructions resolves that problem https://groups.google.com/forum/#!msg/spray-user/2T6SBp4OJeI/AJlnJuAKPRsJ

Thanks again, looking forward to playing with your library....