-
-
Notifications
You must be signed in to change notification settings - Fork 86
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
Added unbounded array patterns #17
Conversation
Hi @K-Phoen feature looks cool. It would be nice if you could you provide some real use case for it, you know maybe some kind of scenario. |
I'm writing (behat) tests for an API and this feature allows me to "strictly" check the first N results that are returned and just check the structure of the rest.
Concerning the pattern, I haven't a lot of other ideas. Would you prefer |
Oh yest, it might be useful for api testing. But I'm still not convinced about the pattern. I think the name should point out that this pattern can be used only for arrays. Maybe |
Hmm well i guess it makes sense for some scenarios, but i have a feeling with this implementation its confusing how to use it. Maybe we should introduce some repeatable array pattern? |
Can you be more explicit? |
Im thinking something like: Then the response should match json:
'''
{
"results": [
{
"id": @string@,
"foo": @string@,
"bar": @integer@
}
].repeat(0...1|Inf)
}
''' or something similar. I honestly dont see the point of matching two first values and then the rest pattern. |
But i guess this would be much more work to achieve that :P |
Yep, I also prefer this solution :) |
Here's a case: verify if a new entry was added to the response and ignore the rest. |
@jakzal but in scenario described here we can verify only if its on one of the first position. We cant check if it was addes as last one. |
To solve @jakzal use case I can think about two possible solutions Then the response should match json pattern:
'''
{
"results": @[email protected](["id": "@integer@", "name": "New"])
}
''' Then the response should match json pattern:
'''
{
"results": [
@...@,
{
"id": @integer@
"name": "Norbert"
},
@...@
]
}
''' |
btw. @K-Phoen I belive you can achieve your goal with Expression |
@K-Phoen could you please rebase this PR against master? It should be enough before 2.0 release where we plan to add pattern expanders. |
Done :) |
Added unbounded array patterns
Thanks! |
Can be useful when you want to test the structure of an array without knowing its size.