Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to specify interaction path to be a regex or support variables #11

Closed
mboudreau opened this issue Jan 28, 2015 · 9 comments
Closed

Comments

@mboudreau
Copy link

Since we do not want to setup each restful path and then test every single one for the same interactions, the ability to specify a generic path that works for all the same paths would be the best way to move forward.

This and the ability to test data schema would solve 90% of our use cases: #10

@bethesque
Copy link
Member

I did this the other day, and tagged you in the issue, didn't you see it?

@bethesque
Copy link
Member

Hm, wrong person, sorry. See this issue: DiUS/pact-consumer-js-dsl#25

@bethesque
Copy link
Member

Did that work?

@bethesque
Copy link
Member

Hey @mboudreau, did you get this working? I will close if so.

@mboudreau
Copy link
Author

@bethesque I actually haven't had the time just yet to test it out. Will try to get it going today if possible.

@mboudreau
Copy link
Author

Yep, works with pact-mock-service 0.2.4, except the function is as following:

function term(matcher, generate) {
    if(!matcher || !generate) {
        throw 'Matcher and Generate arguments must be specified to use Term';
    }
    return {
        "json_class": "Pact::Term",
        "data": {
            "generate": generate,
            "matcher": {
                "json_class": "Regexp",
                "o": 0,
                "s": matcher
            }
        }
    };
}

with an example usage:

provider
    .given('the form id based url')
    .uponReceiving('a GET request for that url')
    .withRequest('get',  term('/[a-zA-Z0-9]+', '/DSye5tXb'))
    .willRespondWith({
        status: 200,
        headers: {'Content-Type': 'application/json; charset=utf-8'},
        body: {id:'DSye5tXb'}
    });

@bethesque
Copy link
Member

Cool. We can put that in the DSL once we've finished the current PR.

@kaiserk
Copy link

kaiserk commented Jun 28, 2016

Hi @bethesque, A year too late in the party. Any update on this one? Just created an issue in pact-consumer-js-dsl, DiUS/pact-consumer-js-dsl#57 then noticed this ticket. I don't see any PR open, I can assume the PR has been merged already?

@YOU54F
Copy link
Member

YOU54F commented Aug 7, 2024

this is complete

@YOU54F YOU54F closed this as completed Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants