Misc utils for testing, asserting and "helpers" in spock tests
Type Params | Return Type | Name and description |
---|---|---|
|
static List |
ensureList(Object obj) makes sure the passed in object is a list, if not then it wraps it in one helpful when creating spocks data pipes |
|
static boolean |
entityContains(GormEntity entity, Map expected) Checks if the GormEntity's properties contains whats in expected calls mapContains after is collects the entities properties into a map |
|
static boolean |
mapContains(Map full, Map subset, List<String> exclude = []) Loosely test 2 maps for equality asserts more or less that every keySet in [a: 1, b: 2] exists in [a: 1, b: 2, c: 3] which is true in this example mapContains([a: 1, b: 2], [a: 1, c: 3]) returns false mapContains([a: 2, b: 2], [a: 1, b: 2]) also returns false if subset is an empty map or null returns false |
makes sure the passed in object is a list, if not then it wraps it in one helpful when creating spocks data pipes
Checks if the GormEntity's properties contains whats in expected calls mapContains after is collects the entities properties into a map
Loosely test 2 maps for equality asserts more or less that every keySet in [a: 1, b: 2] exists in [a: 1, b: 2, c: 3] which is true in this example mapContains([a: 1, b: 2], [a: 1, c: 3]) returns false mapContains([a: 2, b: 2], [a: 1, b: 2]) also returns false if subset is an empty map or null returns false
full
- the map to look insubset
- the subset of values to make sure are in the fullexclude
- optional list of keys to exclude from the subset
http://csierra.github.io/posts/2013/02/12/loosely-test-for-map-equality-using-groovy/