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

Use matchers for keys instead of values #92

Open
koemeet opened this issue Dec 2, 2016 · 3 comments
Open

Use matchers for keys instead of values #92

koemeet opened this issue Dec 2, 2016 · 3 comments

Comments

@koemeet
Copy link

koemeet commented Dec 2, 2016

Hi,

Thanks for your work on this package, it's really nice!

In my test cases I am in need to use matchers for keys too, I saw this is currently not possible. In my case the key is an ID which is different in every test run. So I just want to test it like this:

{
    "@integer@": 9.95
}

Would something like this be a good feature to have in this library?

@norberttech
Copy link
Member

@steffenbrem could you provide some real use cases for this feature?

@koemeet
Copy link
Author

koemeet commented Mar 1, 2017

@norzechowicz Sure! I should have included it with the post, but here it is:

So I have a product where you can store multiple pricing configurations. For example you can configure a different price for a specific user group this way:

{
    "pricingConfiguration": {
        "groups": {
            "<group-id>": <price>
        }
    }
}

This use-case is what my initial issue was about. The key can be dynamic and I cannot know the ID beforehand, since it is different every time I run the tests. If it is possible to "wildcard" the keys too, I can properly test the above use case 🚀

Being able to wildcard the keys can be useful for any kind of dynamic configuration objects, where keys may not be known.

@norberttech
Copy link
Member

Yea, make sense. Right now we are using wildcard values in array matcher (json/xml but they inherit everything from array), but wildcard keys sounds even easier to implement since key can be only a string. Do you think you are able to create a pull request with this feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants