refer to this for a working example: schema-like.feature
* def actual = [{ a: 1, b: 'x' }, { a: 2, b: 'y' }]
* def schema = { a: '#number', b: '#string' }
* def partSchema = { a: '#number' }
* def badSchema = { c: '#boolean' }
* def mixSchema = { a: '#number', c: '#boolean' }
* def shuffled = [{ a: 2, b: 'y' }, { b: 'x', a: 1 }]
* def first = { a: 1, b: 'x' }
* def part = { a: 1 }
* def mix = { b: 'y', c: true }
* def other = [{ a: 3, b: 'u' }, { a: 4, b: 'v' }]
* def some = [{ a: 1, b: 'x' }, { a: 5, b: 'w' }]
Normal Form | In-Line Form |
---|---|
* match actual[0] == schema |
* match actual[0] == '#(schema)' |
* match actual[0] contains partSchema |
* match actual[0] == '#(^partSchema)' |
* match actual[0] contains any mixSchema |
* match actual[0] == '#(^*mixSchema)' |
* match actual[0] !contains badSchema |
* match actual[0] == '#(!^badSchema)' |
* match each actual == schema |
* match actual == '#[] schema' |
* match each actual contains partSchema |
* match actual == '#[] ^partSchema' |
* match each actual contains any mixSchema |
* match actual == '#[] ^*mixSchema' |
* match each actual !contains badSchema |
* match actual == '#[] !^badSchema' |
* match actual contains only shuffled |
* match actual == '#(^^shuffled)' |
* match actual contains first |
* match actual == '#(^first)' |
* match actual contains any some |
* match actual == '#(^*some)' |
* match actual !contains other |
* match actual == '#(!^other)' |
* match actual contains deep part |
* match actual == '#(!+part)' |
* match actual contains '#(^part)' |
# NA |
* match actual contains '#(^*mix)' |
# NA |
* assert foo.length == 2 |
* match foo == '#[2]' |
How can i assert when i am expecting that the value of key should match any of the 2 values. how can i impose OR operation over here. Kindly help.$..test can have any of the two values i.e. null and #regex ^[ A-Za-z0-9-]*$
Ex: