-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Feature request: [contains only deep] #2093
Comments
@ericdriggs okay, will consider for investigation. the assumption was the order of arrays ALWAYS matters, for example a list of "history" items, etc. I do think a way to do an "exact but ignore array order" match is useful. suggestions welcome for alternate syntax. |
After looking through JSON specs, I agree that by default json array ordering is important and should be strict. |
@ericdriggs implemented. do try it out. so this should work: * def response = { foo: [ 'a', 'b' ] }
* match response contains only deep { foo: [ 'b', 'a' ] } once you test a few cases, we can consider a short-cut for this, for example: * match response ^= { foo: [ 'b', 'a' ] } I would vote for this being the only short-cut we allow in the |
contains only deep
contains only deep
1.3.0 released |
Feature: match contains deep only
#Current matchers don't have a syntax for a 1 line order insensitive exact values match
#Single line, order insensitive matching is actually they behavior I would prefer 99.99% of the time
#and it would be my vote to have this be the default behvaior of the == operator
#barring this, match deep only (or similar syntax) would address this use case
Background:
* def expected = { "a": [1, 2, 3, 4, 5] }
* def actualLarger = { "a": [1, 2, 3, 5, 4, 6] }
* def actualDifferentOrder = { "a": [1, 2, 3, 5, 4] }
#######
#fails per spec -- would love to see this pass by default as imo it's the least surprise behavior
Scenario: match equality per spec doesn't ignore order
* match expected == actualDifferentOrder
#######
#passes per spec -- this is the correct behavior
Scenario: by design 'match contains deep' ignores ordering but allows for extra entries
#######
#doesn't exist -- would solve this use case
#no preference on 'contains deep only' vs 'contains only deep'
Scenario: 'match contains deep only' would allow for order-insensitive exact value comparisons
The text was updated successfully, but these errors were encountered: