Skip to content

Instantly share code, notes, and snippets.

@ptrthomas
Last active September 20, 2017 05:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ptrthomas/d6beb17e92a43220d254af942e3ed3d9 to your computer and use it in GitHub Desktop.
Save ptrthomas/d6beb17e92a43220d254af942e3ed3d9 to your computer and use it in GitHub Desktop.
Karate's set via table approach for payload building: https://github.com/intuit/karate#set-multiple
Scenario: set via table where variable does not exist
note how karate will create parent paths if needed
* set foo
| path | value |
| bar | 'baz' |
| a.b | 'c' |
| fizz | { d: 'e' } |
* match foo == { bar: 'baz', a: { b: 'c' }, fizz: { d: 'e' } }
Scenario: set via table with fancy array paths and multi-dimensional arrays
* set foo
| path | value |
| bar[0] | 'baz' |
| a[0].b | 'ban' |
| c[0] | [1, 2] |
| c[1] | [3, 4] |
* match foo == { bar: [ 'baz'], a: [{ b: 'ban' }], c: [[1, 2], [3, 4]] }
Scenario: set via table, and blanks are skipped
* set search
| path | 0 | 1 | 2 |
| name.first | 'John' | 'Jane' | |
| name.last | 'Smith' | 'Doe' | 'Waldo' |
| age | 20 | | |
* match search[0] == { name: { first: 'John', last: 'Smith' }, age: 20 }
* match search[1] == { name: { first: 'Jane', last: 'Doe' } }
* match search[2] == { name: { last: 'Waldo' } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment