Use matchers for keys instead of values
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?
@steffenbrem could you provide some real use cases for this feature?
@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.
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?