空手道测试 - 有什么方法可以在 "match each" 中进行 "or" 比赛?
Karate test - any way to do an "or" match in "match each"?
我有类似下面的东西。是否可以让空手道为 foo
和 bar
进行 "or" 比赛?
含义 - foo
以 fooStartWithChar
开头或 bar
以 barStartWithChar
开头
And match each response ==
"""
{
foo: '#? { _.charAt(0) == fooStartWithChar}',
bar: '#? { _.charAt(0) == barStartWithChar}',
}
"""
有时普通老 JS (+Java) 是你的朋友:
* def response = [{ foo: 'aa', bar: 'bb' }, { foo: 'ax', bar: 'by' }]
* def isValid = function(x){ return x.foo.startsWith('a') || x.bar.startsWith('b') }
* match each response == '#? isValid(_)'
* def nameStartsWith = function(x) { return x.foo.charAt(0) == fooStartWithChar || x.bar.charAt(0) == barStartWithChar}
And match each response == '#? nameStartsWith(_)'
我有类似下面的东西。是否可以让空手道为 foo
和 bar
进行 "or" 比赛?
含义 - foo
以 fooStartWithChar
开头或 bar
以 barStartWithChar
And match each response ==
"""
{
foo: '#? { _.charAt(0) == fooStartWithChar}',
bar: '#? { _.charAt(0) == barStartWithChar}',
}
"""
有时普通老 JS (+Java) 是你的朋友:
* def response = [{ foo: 'aa', bar: 'bb' }, { foo: 'ax', bar: 'by' }]
* def isValid = function(x){ return x.foo.startsWith('a') || x.bar.startsWith('b') }
* match each response == '#? isValid(_)'
* def nameStartsWith = function(x) { return x.foo.charAt(0) == fooStartWithChar || x.bar.charAt(0) == barStartWithChar}
And match each response == '#? nameStartsWith(_)'