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

Provide a PactDslResponse matchHeader with noRegexp? #512

Closed
ehmkah opened this issue Aug 6, 2017 · 5 comments
Closed

Provide a PactDslResponse matchHeader with noRegexp? #512

ehmkah opened this issue Aug 6, 2017 · 5 comments

Comments

@ehmkah
Copy link
Contributor

ehmkah commented Aug 6, 2017

Would it be possible to provide a method matchHeaderExact(header, example) to PactDSLResponse that it is possible to add a header without a regexp?

My use-case: I like to test whether the expected media-type is returned from the server. I found a workaround to provide it like .matchHeader("Content-Type", ".", "application/vnd.ehmkah.app-1.0+json") which makes it difficult to read. Or is that the way I should do it with pact?

@uglyog
Copy link
Member

uglyog commented Aug 10, 2017

The default is to match using equality. Just use headers(Map<String, String> headers) to set the exact headers that are required.

@ehmkah
Copy link
Contributor Author

ehmkah commented Aug 11, 2017

Ok. I thought that message should be used when I want to match ALL headers. But I am only interested in one header. I do not care for the others.

@uglyog
Copy link
Member

uglyog commented Aug 13, 2017

It should be used to specify only the headers you want to match on (not all headers). You can set your single header value there.

@ehmkah
Copy link
Contributor Author

ehmkah commented Aug 15, 2017

I could change the documentation of headers to make it a little bit easier to understand:

/**
 * Response headers to return.
* 
* Provide the headers you want to validate, other headers willl be ignored.
 *
 * @param headers key-value pairs of headers
*/

uglyog pushed a commit that referenced this issue Aug 16, 2017
@ehmkah
Copy link
Contributor Author

ehmkah commented Aug 16, 2017

With the additional information the issue is closed for me.

@ehmkah ehmkah closed this as completed Aug 16, 2017
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

2 participants