Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bgoetzmann/aa830ed911f275dc3dfded4a73b9a50d to your computer and use it in GitHub Desktop.
Save bgoetzmann/aa830ed911f275dc3dfded4a73b9a50d to your computer and use it in GitHub Desktop.
def _makeAddItemCommand(Item item) {
{ Cart cart -> cart.addItem(item) }
}
def _makeRemoveItemCommand(Item item) {
{ Cart cart -> cart.removeItem(item) }
}
def actions = [
_makeAddItemCommand(new Item(name: 'Item1', price: 1)),
_makeAddItemCommand(new Item(name: 'Item2', price: 1)),
_makeRemoveItemCommand(new Item(name: 'Item1', price: 1))
]
def _fpCart = new Cart()
actions*.call(_fpCart)
assert _fpCart.items.keySet() == ['Item2'] as Set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment