Skip to content

Commit

Permalink
Fix for issue with eachKeyLike not setting the wildcard matcher corre…
Browse files Browse the repository at this point in the history
…ctly #313
  • Loading branch information
Ronald Holshausen committed Sep 21, 2016
1 parent 94657cb commit 70c6261
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ public PactDslJsonBody eachKeyMappedToAnArrayLike(String exampleKey) {
* @param exampleKey Example key to use for generating bodies
*/
public PactDslJsonBody eachKeyLike(String exampleKey) {
matchers.put(".*", matchType());
matchers.put(rootPath + "*", matchType());
return new PactDslJsonBody(rootPath + "*.", exampleKey, this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
* For example, when you annotate a provider test class with:
* <pre><code>{@literal @}VersionedPactUrl(urls = {"http://artifactory:8081/artifactory/consumercontracts/foo-bar/${foo.version}/foo-bar-${foo.version}.json"})</code></pre>
* And pass a system property foo.version to the JVM, for example -Dfoo.version=123
* </p>
* <p>
* Then the pact tests will fetch the following contract:
* <pre><code>http://artifactory:8081/artifactory/consumercontracts/foo-bar/123/foo-bar-123.json</code></pre>
* </p>
*
* @see VersionedPactUrlLoader pact loader
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,34 @@
import au.com.dius.pact.provider.junit.target.HttpTarget;
import au.com.dius.pact.provider.junit.target.Target;
import au.com.dius.pact.provider.junit.target.TestTarget;
import com.github.restdriver.clientdriver.ClientDriverRule;
import org.apache.commons.io.IOUtils;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.runner.RunWith;

import java.io.IOException;
import java.nio.charset.Charset;

import static com.github.restdriver.clientdriver.RestClientDriver.giveEmptyResponse;
import static com.github.restdriver.clientdriver.RestClientDriver.giveResponse;
import static com.github.restdriver.clientdriver.RestClientDriver.onRequestTo;

@RunWith(PactRunner.class)
@Provider("ArticlesProvider")
@PactFolder("../pact-jvm-consumer-junit/build/2.11/pacts")
public class ArticlesContractTest {
@TestTarget
public final Target target = new HttpTarget(8000);
@TestTarget
public final Target target = new HttpTarget(8000);

@ClassRule
public static final ClientDriverRule embeddedService = new ClientDriverRule(8000);

@Before
public void before() throws IOException {
String json = IOUtils.toString(getClass().getResourceAsStream("/articles.json"), Charset.defaultCharset());
embeddedService.addExpectation(
onRequestTo("/articles.json"), giveResponse(json, "application/json")
);
}
}

0 comments on commit 70c6261

Please sign in to comment.